mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-22 08:45:42 +08:00
Adapt to new suda.vim version (#4100)
This commit is contained in:
parent
738dbdf580
commit
49663f002b
@ -15,12 +15,9 @@ function! SpaceVim#layers#sudo#plugins() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#sudo#config() abort
|
function! SpaceVim#layers#sudo#config() abort
|
||||||
let g:suda_startup = 0
|
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'W'], 'call call('
|
call SpaceVim#mapping#space#def('nnoremap', ['f', 'W'], 'SudaWrite', 'save buffer with sudo', 1)
|
||||||
\ . string(s:_function('s:SudoWriteCurrentFile')) . ', [])',
|
command! W SudaWrite
|
||||||
\ 'save buffer with sudo', 1)
|
|
||||||
command! W call <SID>SudoWriteCurrentFile()
|
|
||||||
cnoremap w!! W
|
cnoremap w!! W
|
||||||
else
|
else
|
||||||
" http://forrst.com/posts/Use_w_to_sudo_write_a_file_with_Vim-uAN
|
" http://forrst.com/posts/Use_w_to_sudo_write_a_file_with_Vim-uAN
|
||||||
@ -30,17 +27,6 @@ function! SpaceVim#layers#sudo#config() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SudoWriteCurrentFile() abort
|
|
||||||
let l:lhs = expand('%')
|
|
||||||
try
|
|
||||||
let l:echo_message = suda#write(l:lhs)
|
|
||||||
redraw | echo l:echo_message
|
|
||||||
finally
|
|
||||||
doautocmd BufWritePost l:lhs
|
|
||||||
checktime
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||||
function! s:_function(fstr) abort
|
function! s:_function(fstr) abort
|
||||||
return function(a:fstr)
|
return function(a:fstr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user