diff --git a/autoload/go/config.vim b/autoload/go/config.vim index c08a3d5c91..db3e13e0ef 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -2,10 +2,6 @@ let s:cpo_save = &cpo set cpo&vim -function! go#config#AutodetectGopath() abort - return get(g:, 'go_autodetect_gopath', 0) -endfunction - function! go#config#ListTypeCommands() abort return get(g:, 'go_list_type_commands', {}) endfunction diff --git a/autoload/go/path.vim b/autoload/go/path.vim index 0d81d45312..c7827da672 100644 --- a/autoload/go/path.vim +++ b/autoload/go/path.vim @@ -69,60 +69,6 @@ function! s:HasPath(path) abort return hasA || hasB endfunction -" Detect returns the current GOPATH. If a package manager is used, such as -" Godeps, GB, it will modify the GOPATH so those directories take precedence -" over the current GOPATH. It also detects diretories whose are outside -" GOPATH. -function! go#path#Detect() abort - let gopath = go#path#Default() - - let current_dir = fnameescape(expand('%:p:h')) - - " TODO(arslan): this should be changed so folders or files should be - " fetched from a customizable list. The user should define any new package - " management tool by it's own. - - " 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() - - " gb vendor plugin - " (https://github.com/constabulary/gb/tree/master/cmd/gb-vendor) - let gb_vendor_root = src_path . "vendor" . go#util#PathSep() - if isdirectory(gb_vendor_root) && !s:HasPath(gb_vendor_root) - let gopath = gb_vendor_root . go#util#PathListSep() . gopath - endif - - if !s:HasPath(src_path) - let gopath = src_path . go#util#PathListSep() . gopath - endif - endif - - " Godeps - let godeps_root = finddir("Godeps", current_dir .";") - if !empty(godeps_root) - let godeps_path = join([fnamemodify(godeps_root, ':p:h:h'), "Godeps", "_workspace" ], go#util#PathSep()) - - if !s:HasPath(godeps_path) - let gopath = godeps_path . go#util#PathListSep() . gopath - endif - endif - - " Fix up the case where initial $GOPATH is empty, - " and we end up with a trailing : - let gopath = substitute(gopath, ":$", "", "") - return gopath -endfunction - " BinPath returns the binary path of installed go tools. function! go#path#BinPath() abort let bin_path = go#config#BinPath() diff --git a/doc/vim-go.txt b/doc/vim-go.txt index b4a8e65af4..8e53b5aaf8 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -1579,16 +1579,6 @@ There is also the |:GoBuildTags| convenience command to change or remove build tags. > let g:go_build_tags = '' -< - *'g:go_autodetect_gopath'* - -Automatically modify GOPATH for certain directory structures, such as for -the `godep` tool which stores dependencies in the `Godeps` folder. What this -means is that all tools are now working with the newly modified GOPATH. So -|:GoDef| for example jumps to the source inside the `Godeps` (vendored) -source. Currently `godep` and `gb` are supported. By default it's disabled. -> - let g:go_autodetect_gopath = 0 < *'g:go_textobj_enabled'* diff --git a/ftplugin/go.vim b/ftplugin/go.vim index 687f881e20..af8ef099f2 100644 --- a/ftplugin/go.vim +++ b/ftplugin/go.vim @@ -124,19 +124,6 @@ augroup vim-go-buffer " previous buffer's diagnostics aren't used. "autocmd BufWinEnter call go#lsp#ClearDiagnosticHighlights() endif - - autocmd BufEnter - \ if go#config#AutodetectGopath() && !exists('b:old_gopath') - \| let b:old_gopath = exists('$GOPATH') ? $GOPATH : -1 - \| let $GOPATH = go#path#Detect() - \| endif - autocmd BufLeave - \ if exists('b:old_gopath') - \| if b:old_gopath isnot -1 - \| let $GOPATH = b:old_gopath - \| endif - \| unlet b:old_gopath - \| endif augroup end " restore Vi compatibility settings diff --git a/plugin/go.vim b/plugin/go.vim index abf1d57fd9..ce7d7a26aa 100644 --- a/plugin/go.vim +++ b/plugin/go.vim @@ -279,12 +279,7 @@ function! s:register() return endif - let l:RestoreGopath = function('s:noop') - if go#config#AutodetectGopath() - let l:RestoreGopath = go#util#SetEnv('GOPATH', go#path#Detect()) - endif call go#lsp#DidOpen(expand(':p')) - call call(l:RestoreGopath, []) endfunction function! s:noop(...) abort