From 99d250b72f3bd3365bc3e625d782986a472dc40d Mon Sep 17 00:00:00 2001 From: Martin Hamrle Date: Mon, 22 Feb 2016 22:00:08 +0100 Subject: [PATCH] add support for goimports -srcdir in Format "goimports -srcdir" fixes problems with vendoring. --- autoload/go/fmt.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/autoload/go/fmt.vim b/autoload/go/fmt.vim index 6d474b319e..8b800d1798 100644 --- a/autoload/go/fmt.vim +++ b/autoload/go/fmt.vim @@ -100,6 +100,17 @@ function! go#fmt#Format(withGoimport) if a:withGoimport != 1 let command = command . g:go_fmt_options endif + if fmt_command == "goimports" + let out = system("goimports --help") + if out !~ "-srcdir" + echohl WarningMsg + echomsg "vim-go: goimports does not support srcdir." + echomsg " update with: :GoUpdateBinaries" + echohl None + else + let command = command . '-srcdir ' . fnameescape(expand("%:p:h")) + endif + endif " execute our command... let out = system(command . " " . l:tmpname)