Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old goimports -srcdir workaround and fix :GoFmtAutoSaveToggle #1787

Merged
merged 1 commit into from
Apr 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions autoload/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,8 @@ function! s:fmt_cmd(bin_name, source, target)
let opts = has_key(opts, a:bin_name) ? opts[a:bin_name] : ""
endif
call extend(cmd, split(opts, " "))

if a:bin_name == "goimports"
" lazy check if goimports support `-srcdir`. We should eventually remove
" this in the future
if !exists('b:goimports_vendor_compatible')
let [l:out, l:err] = go#util#Exec([a:bin_name, '--help'])
if l:out !~ "-srcdir"
call go#util#EchoWarning(printf("vim-go: goimports (%s) does not support srcdir. Update with: :GoUpdateBinaries", a:bin_name))
else
let b:goimports_vendor_compatible = 1
endif
endif

if exists('b:goimports_vendor_compatible') && b:goimports_vendor_compatible
let ssl_save = &shellslash
set noshellslash
" use the filename without the fully qualified name if the tree is
" symlinked into the GOPATH, goimports won't work properly.
call extend(cmd, ["-srcdir", a:target])
let &shellslash = ssl_save
endif
if a:bin_name is# 'goimports'
call extend(cmd, ["-srcdir", a:target])
endif

call add(cmd, a:source)
Expand Down Expand Up @@ -221,12 +202,12 @@ endfunction

function! go#fmt#ToggleFmtAutoSave() abort
if go#config#FmtAutosave()
call go#config#FmtAutosave(0)
call go#config#SetFmtAutosave(0)
call go#util#EchoProgress("auto fmt disabled")
return
end

call go#config#FmtAutosave(1)
call go#config#SetFmtAutosave(1)
call go#util#EchoProgress("auto fmt enabled")
endfunction

Expand Down