goimports fixer doesn't work for vendored libraries

In Go you can "vendor" packages by putting them in the `vendor/`
directory for a project. Adding the `-srcdir` argument makes `goimports`
pick up these packages, in addition to what you have in GOPATH.

Without this, `goimports` is not very useful, since most projects vendor
their packages.
This commit is contained in:
Martin Tournoij 2017-12-06 13:04:31 +00:00
parent 7d932a239c
commit 92f20b0e51
No known key found for this signature in database
GPG Key ID: A6258419189EE585
2 changed files with 3 additions and 3 deletions

View File

@ -14,7 +14,7 @@ function! ale#fixers#goimports#Fix(buffer) abort
return {
\ 'command': ale#Escape(l:executable)
\ . ' -l -w'
\ . ' -l -w -srcdir %s'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t',
\ 'read_temporary_file': 1,

View File

@ -25,7 +25,7 @@ Execute(The goimports callback should the command when the executable test passe
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w %t'
\ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w -srcdir %s %t'
\ },
\ ale#fixers#goimports#Fix(bufnr(''))
@ -36,6 +36,6 @@ Execute(The goimports callback should include extra options):
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w --xxx %t'
\ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w -srcdir %s --xxx %t'
\ },
\ ale#fixers#goimports#Fix(bufnr(''))