diff --git a/autoload/go/path.vim b/autoload/go/path.vim index 64921e5593..78c0aa396e 100644 --- a/autoload/go/path.vim +++ b/autoload/go/path.vim @@ -83,8 +83,16 @@ function! go#path#Detect() abort " fetched from a customizable list. The user should define any new package " management tool by it's own. - " src folder outside $GOPATH - let src_root = finddir("src", current_dir .";") + " src folders outside $GOPATH + let src_roots = finddir("src", current_dir .";", -1) + + " for cases like GOPATH/src/foo/src/bar, pick up GOPATH/src instead of + " GOPATH/src/foo/src + let src_root = "" + if len(src_roots) > 0 + let src_root = src_roots[-1] + endif + if !empty(src_root) let src_path = fnamemodify(src_root, ':p:h:h') . go#util#PathSep()