diff options
Diffstat (limited to '')
-rw-r--r-- | autoload/rust.vim | 13 | ||||
-rw-r--r-- | autoload/rust/tags.vim | 3 | ||||
-rw-r--r-- | autoload/rustfmt.vim | 16 |
3 files changed, 22 insertions, 10 deletions
diff --git a/autoload/rust.vim b/autoload/rust.vim index e8a675f3..b6ab1c68 100644 --- a/autoload/rust.vim +++ b/autoload/rust.vim @@ -398,10 +398,19 @@ function! s:RmDir(path) echoerr 'Attempted to delete empty path' return 0 elseif a:path ==# '/' || a:path ==# $HOME - echoerr 'Attempted to delete protected path: ' . a:path + let l:path = expand(a:path) + if l:path ==# '/' || l:path ==# $HOME + echoerr 'Attempted to delete protected path: ' . a:path + return 0 + endif + endif + + if !isdirectory(a:path) return 0 endif - return system("rm -rf " . shellescape(a:path)) + + " delete() returns 0 when removing file successfully + return delete(a:path, 'rf') == 0 endfunction " Executes {cmd} with the cwd set to {pwd}, without changing Vim's cwd. diff --git a/autoload/rust/tags.vim b/autoload/rust/tags.vim index 21faaabb..e75fb208 100644 --- a/autoload/rust/tags.vim +++ b/autoload/rust/tags.vim @@ -8,7 +8,8 @@ let s:checked_ctags = 0 function! rust#tags#IsUCtags() abort if s:checked_ctags == 0 - if system('ctags --version') =~? 'universal ctags' + let l:ctags_bin = get(g:, 'tagbar_ctags_bin', 'ctags') + if system(l:ctags_bin.' --version') =~? 'universal ctags' let s:ctags_is_uctags = 1 endif let s:checked_ctags = 1 diff --git a/autoload/rustfmt.vim b/autoload/rustfmt.vim index 151ac82d..53ea9b28 100644 --- a/autoload/rustfmt.vim +++ b/autoload/rustfmt.vim @@ -112,7 +112,7 @@ function! s:DeleteLines(start, end) abort silent! execute a:start . ',' . a:end . 'delete _' endfunction -function! s:RunRustfmt(command, tmpname, fail_silently) +function! s:RunRustfmt(command, tmpname, from_writepre) mkview! let l:stderr_tmpname = tempname() @@ -149,8 +149,10 @@ function! s:RunRustfmt(command, tmpname, fail_silently) let l:open_lwindow = 0 if v:shell_error == 0 - " remove undo point caused via BufWritePre - try | silent undojoin | catch | endtry + if a:from_writepre + " remove undo point caused via BufWritePre + try | silent undojoin | catch | endtry + endif if a:tmpname ==# '' let l:content = l:out @@ -170,7 +172,7 @@ function! s:RunRustfmt(command, tmpname, fail_silently) call setloclist(0, []) let l:open_lwindow = 1 endif - elseif g:rustfmt_fail_silently == 0 && a:fail_silently == 0 + elseif g:rustfmt_fail_silently == 0 && !a:from_writepre " otherwise get the errors and put them in the location list let l:errors = [] @@ -224,12 +226,12 @@ function! rustfmt#FormatRange(line1, line2) let l:tmpname = tempname() call writefile(getline(1, '$'), l:tmpname) let command = s:RustfmtCommandRange(l:tmpname, a:line1, a:line2) - call s:RunRustfmt(command, l:tmpname, 0) + call s:RunRustfmt(command, l:tmpname, v:false) call delete(l:tmpname) endfunction function! rustfmt#Format() - call s:RunRustfmt(s:RustfmtCommand(), '', 0) + call s:RunRustfmt(s:RustfmtCommand(), '', v:false) endfunction function! rustfmt#Cmd() @@ -257,7 +259,7 @@ function! rustfmt#PreWrite() return endif - call s:RunRustfmt(s:RustfmtCommand(), '', 1) + call s:RunRustfmt(s:RustfmtCommand(), '', v:true) endfunction |