summaryrefslogtreecommitdiffstats
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/rustfmt.vim22
-rw-r--r--autoload/terraform.vim6
2 files changed, 15 insertions, 13 deletions
diff --git a/autoload/rustfmt.vim b/autoload/rustfmt.vim
index 53ea9b28..514e4147 100644
--- a/autoload/rustfmt.vim
+++ b/autoload/rustfmt.vim
@@ -62,18 +62,19 @@ function! s:RustfmtWriteMode()
endif
endfunction
-function! s:RustfmtConfig()
+function! s:RustfmtConfigOptions()
let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';')
if l:rustfmt_toml !=# ''
- return '--config-path '.l:rustfmt_toml
+ return '--config-path '.fnamemodify(l:rustfmt_toml, ":p")
endif
let l:_rustfmt_toml = findfile('.rustfmt.toml', expand('%:p:h') . ';')
if l:_rustfmt_toml !=# ''
- return '--config-path '.l:_rustfmt_toml
+ return '--config-path '.fnamemodify(l:_rustfmt_toml, ":p")
endif
- return ''
+ " Default to edition 2018 in case no rustfmt.toml was found.
+ return '--edition 2018'
endfunction
function! s:RustfmtCommandRange(filename, line1, line2)
@@ -84,7 +85,7 @@ function! s:RustfmtCommandRange(filename, line1, line2)
let l:arg = {"file": shellescape(a:filename), "range": [a:line1, a:line2]}
let l:write_mode = s:RustfmtWriteMode()
- let l:rustfmt_config = s:RustfmtConfig()
+ let l:rustfmt_config = s:RustfmtConfigOptions()
" FIXME: When --file-lines gets to be stable, add version range checking
" accordingly.
@@ -98,14 +99,9 @@ function! s:RustfmtCommandRange(filename, line1, line2)
endfunction
function! s:RustfmtCommand()
- if g:rustfmt_emit_files
- let l:write_mode = "--emit=stdout"
- else
- let l:write_mode = "--write-mode=display"
- endif
- " rustfmt will pick on the right config on its own due to the
- " current directory change.
- return g:rustfmt_command . " ". l:write_mode . " " . g:rustfmt_options
+ let write_mode = g:rustfmt_emit_files ? '--emit=stdout' : '--write-mode=display'
+ let config = s:RustfmtConfigOptions()
+ return join([g:rustfmt_command, write_mode, config, g:rustfmt_options])
endfunction
function! s:DeleteLines(start, end) abort
diff --git a/autoload/terraform.vim b/autoload/terraform.vim
index b156b6b9..dc96ce0a 100644
--- a/autoload/terraform.vim
+++ b/autoload/terraform.vim
@@ -1,5 +1,8 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1
+let s:cpo_save = &cpoptions
+set cpoptions&vim
+
" Ensure no conflict with arguments from the environment
let $TF_CLI_ARGS_fmt=''
@@ -61,4 +64,7 @@ function! terraform#commands(ArgLead, CmdLine, CursorPos)
return join(l:commands, "\n")
endfunction
+let &cpoptions = s:cpo_save
+unlet s:cpo_save
+
endif