summaryrefslogtreecommitdiffstats
path: root/autoload/rustfmt.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2019-10-16 14:56:00 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2019-10-16 14:56:00 +0200
commit199846c6d87c9ea60eb5f9f8f68e2d9ea4f02b2a (patch)
tree43a35af46ea780decdd9146601eef6af561cb14c /autoload/rustfmt.vim
parentf95026252c5a31242903a98c741887696dfbb11f (diff)
downloadvim-polyglot-199846c6d87c9ea60eb5f9f8f68e2d9ea4f02b2a.tar.gz
vim-polyglot-199846c6d87c9ea60eb5f9f8f68e2d9ea4f02b2a.zip
Update
Diffstat (limited to 'autoload/rustfmt.vim')
-rw-r--r--autoload/rustfmt.vim16
1 files changed, 9 insertions, 7 deletions
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