Skip to content

Commit

Permalink
config: remove support for g:go_autodetect_gopath
Browse files Browse the repository at this point in the history
Remove support for g:go_autodetect_gopath; it was only necessary for
tools like gb and godep. Both of those were long ago archived and
there's no need for them now with Go modules and vendoring.

Fixes fatih#3065
  • Loading branch information
bhcleek committed Nov 1, 2020
1 parent 96cf06b commit d0e94f9
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 151 deletions.
4 changes: 0 additions & 4 deletions autoload/go/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 0 additions & 54 deletions autoload/go/path.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 0 additions & 10 deletions doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'*

Expand Down
13 changes: 0 additions & 13 deletions ftplugin/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,6 @@ augroup vim-go-buffer
" previous buffer's diagnostics aren't used.
"autocmd BufWinEnter <buffer> call go#lsp#ClearDiagnosticHighlights()
endif

autocmd BufEnter <buffer>
\ if go#config#AutodetectGopath() && !exists('b:old_gopath')
\| let b:old_gopath = exists('$GOPATH') ? $GOPATH : -1
\| let $GOPATH = go#path#Detect()
\| endif
autocmd BufLeave <buffer>
\ 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
Expand Down
5 changes: 0 additions & 5 deletions plugin/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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('<afile>:p'))
call call(l:RestoreGopath, [])
endfunction

function! s:noop(...) abort
Expand Down
65 changes: 0 additions & 65 deletions test/gopath_test.vim

This file was deleted.

0 comments on commit d0e94f9

Please sign in to comment.