From 92f20b0e516526294fb933bd5640a1f5f1c0671a Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Wed, 6 Dec 2017 13:04:31 +0000 Subject: [PATCH] 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. --- autoload/ale/fixers/goimports.vim | 2 +- test/fixers/test_goimports_fixer_callback.vader | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/ale/fixers/goimports.vim b/autoload/ale/fixers/goimports.vim index f569513..783d020 100644 --- a/autoload/ale/fixers/goimports.vim +++ b/autoload/ale/fixers/goimports.vim @@ -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, diff --git a/test/fixers/test_goimports_fixer_callback.vader b/test/fixers/test_goimports_fixer_callback.vader index 1d2763c..cec0635 100644 --- a/test/fixers/test_goimports_fixer_callback.vader +++ b/test/fixers/test_goimports_fixer_callback.vader @@ -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(''))