Skip to content

Commit d0e94f9

Browse files
committed
config: remove support for g:go_autodetect_gopath
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 #3065
1 parent 96cf06b commit d0e94f9

File tree

6 files changed

+0
-151
lines changed

6 files changed

+0
-151
lines changed

autoload/go/config.vim

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
let s:cpo_save = &cpo
33
set cpo&vim
44

5-
function! go#config#AutodetectGopath() abort
6-
return get(g:, 'go_autodetect_gopath', 0)
7-
endfunction
8-
95
function! go#config#ListTypeCommands() abort
106
return get(g:, 'go_list_type_commands', {})
117
endfunction

autoload/go/path.vim

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -69,60 +69,6 @@ function! s:HasPath(path) abort
6969
return hasA || hasB
7070
endfunction
7171

72-
" Detect returns the current GOPATH. If a package manager is used, such as
73-
" Godeps, GB, it will modify the GOPATH so those directories take precedence
74-
" over the current GOPATH. It also detects diretories whose are outside
75-
" GOPATH.
76-
function! go#path#Detect() abort
77-
let gopath = go#path#Default()
78-
79-
let current_dir = fnameescape(expand('%:p:h'))
80-
81-
" TODO(arslan): this should be changed so folders or files should be
82-
" fetched from a customizable list. The user should define any new package
83-
" management tool by it's own.
84-
85-
" src folders outside $GOPATH
86-
let src_roots = finddir("src", current_dir .";", -1)
87-
88-
" for cases like GOPATH/src/foo/src/bar, pick up GOPATH/src instead of
89-
" GOPATH/src/foo/src
90-
let src_root = ""
91-
if len(src_roots) > 0
92-
let src_root = src_roots[-1]
93-
endif
94-
95-
if !empty(src_root)
96-
let src_path = fnamemodify(src_root, ':p:h:h') . go#util#PathSep()
97-
98-
" gb vendor plugin
99-
" (https://github.com/constabulary/gb/tree/master/cmd/gb-vendor)
100-
let gb_vendor_root = src_path . "vendor" . go#util#PathSep()
101-
if isdirectory(gb_vendor_root) && !s:HasPath(gb_vendor_root)
102-
let gopath = gb_vendor_root . go#util#PathListSep() . gopath
103-
endif
104-
105-
if !s:HasPath(src_path)
106-
let gopath = src_path . go#util#PathListSep() . gopath
107-
endif
108-
endif
109-
110-
" Godeps
111-
let godeps_root = finddir("Godeps", current_dir .";")
112-
if !empty(godeps_root)
113-
let godeps_path = join([fnamemodify(godeps_root, ':p:h:h'), "Godeps", "_workspace" ], go#util#PathSep())
114-
115-
if !s:HasPath(godeps_path)
116-
let gopath = godeps_path . go#util#PathListSep() . gopath
117-
endif
118-
endif
119-
120-
" Fix up the case where initial $GOPATH is empty,
121-
" and we end up with a trailing :
122-
let gopath = substitute(gopath, ":$", "", "")
123-
return gopath
124-
endfunction
125-
12672
" BinPath returns the binary path of installed go tools.
12773
function! go#path#BinPath() abort
12874
let bin_path = go#config#BinPath()

doc/vim-go.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,16 +1579,6 @@ There is also the |:GoBuildTags| convenience command to change or remove build
15791579
tags.
15801580
>
15811581
let g:go_build_tags = ''
1582-
<
1583-
*'g:go_autodetect_gopath'*
1584-
1585-
Automatically modify GOPATH for certain directory structures, such as for
1586-
the `godep` tool which stores dependencies in the `Godeps` folder. What this
1587-
means is that all tools are now working with the newly modified GOPATH. So
1588-
|:GoDef| for example jumps to the source inside the `Godeps` (vendored)
1589-
source. Currently `godep` and `gb` are supported. By default it's disabled.
1590-
>
1591-
let g:go_autodetect_gopath = 0
15921582
<
15931583
*'g:go_textobj_enabled'*
15941584

ftplugin/go.vim

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,6 @@ augroup vim-go-buffer
124124
" previous buffer's diagnostics aren't used.
125125
"autocmd BufWinEnter <buffer> call go#lsp#ClearDiagnosticHighlights()
126126
endif
127-
128-
autocmd BufEnter <buffer>
129-
\ if go#config#AutodetectGopath() && !exists('b:old_gopath')
130-
\| let b:old_gopath = exists('$GOPATH') ? $GOPATH : -1
131-
\| let $GOPATH = go#path#Detect()
132-
\| endif
133-
autocmd BufLeave <buffer>
134-
\ if exists('b:old_gopath')
135-
\| if b:old_gopath isnot -1
136-
\| let $GOPATH = b:old_gopath
137-
\| endif
138-
\| unlet b:old_gopath
139-
\| endif
140127
augroup end
141128

142129
" restore Vi compatibility settings

plugin/go.vim

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,7 @@ function! s:register()
279279
return
280280
endif
281281

282-
let l:RestoreGopath = function('s:noop')
283-
if go#config#AutodetectGopath()
284-
let l:RestoreGopath = go#util#SetEnv('GOPATH', go#path#Detect())
285-
endif
286282
call go#lsp#DidOpen(expand('<afile>:p'))
287-
call call(l:RestoreGopath, [])
288283
endfunction
289284

290285
function! s:noop(...) abort

test/gopath_test.vim

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)