diff --git a/autoload/go/complete.vim b/autoload/go/complete.vim index 9460b46204..a5992c63ad 100644 --- a/autoload/go/complete.vim +++ b/autoload/go/complete.vim @@ -9,6 +9,15 @@ function! s:gocodeCommand(cmd, args) abort let cmd = [bin_path] let cmd = extend(cmd, ['-sock', socket_type]) let cmd = extend(cmd, ['-f', 'vim']) + + if go#config#GocodeProposeBuiltins() + let cmd = extend(cmd, ['-builtin']) + endif + + if go#config#GocodeProposeSource() + let cmd = extend(cmd, ['-source']) + endif + let cmd = extend(cmd, [a:cmd]) let cmd = extend(cmd, a:args) @@ -43,31 +52,7 @@ function! s:sync_gocode(cmd, args, input) abort return l:result endfunction -let s:optionsEnabled = 0 -function! s:gocodeEnableOptions() abort - if s:optionsEnabled - return - endif - - let l:bin_path = go#path#CheckBinPath("gocode") - if empty(l:bin_path) - return - endif - - let s:optionsEnabled = 1 - - call go#util#Exec(['gocode', 'set', 'propose-builtins', s:toBool(go#config#GocodeProposeBuiltins())]) - call go#util#Exec(['gocode', 'set', 'autobuild', s:toBool(go#config#GocodeAutobuild())]) - call go#util#Exec(['gocode', 'set', 'unimported-packages', s:toBool(go#config#GocodeUnimportedPackages())]) -endfunction - -function! s:toBool(val) abort - if a:val | return 'true' | else | return 'false' | endif -endfunction - function! s:gocodeAutocomplete() abort - call s:gocodeEnableOptions() - " use the offset as is, because the cursor position is the position for " which autocomplete candidates are needed. return s:sync_gocode('autocomplete', diff --git a/autoload/go/config.vim b/autoload/go/config.vim index 140e41c5c0..8e72b1a83a 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -135,10 +135,6 @@ function! go#config#SetGuruScope(scope) abort endif endfunction -function! go#config#GocodeUnimportedPackages() abort - return get(g:, 'go_gocode_unimported_packages', 0) -endfunction - let s:sock_type = (has('win32') || has('win64')) ? 'tcp' : 'unix' function! go#config#GocodeSocketType() abort return get(g:, 'go_gocode_socket_type', s:sock_type) @@ -148,8 +144,8 @@ function! go#config#GocodeProposeBuiltins() abort return get(g:, 'go_gocode_propose_builtins', 1) endfunction -function! go#config#GocodeAutobuild() abort - return get(g:, 'go_gocode_autobuild', 1) +function! go#config#GocodeProposeSource() abort + return get(g:, 'go_gocode_propose_source', 0) endfunction function! go#config#EchoCommandInfo() abort diff --git a/doc/vim-go.txt b/doc/vim-go.txt index 638a2765d2..33015f40bb 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -1574,14 +1574,6 @@ same. let g:go_gorename_prefill = 'expand("") =~# "^[A-Z]"' . \ '? go#util#pascalcase(expand(""))' . \ ': go#util#camelcase(expand(""))' -< - *'g:go_gocode_autobuild'* - -Specifies whether `gocode` should automatically build out-of-date packages -when their source fields are modified, in order to obtain the freshest -autocomplete results for them. By default it is enabled. -> - let g:go_gocode_autobuild = 1 < *'g:go_gocode_propose_builtins'* @@ -1590,14 +1582,14 @@ to an autocompletion proposals. By default it is enabled. > let g:go_gocode_propose_builtins = 1 < - *'g:go_gocode_unimported_packages'* + *'g:go_gocode_propose_source'* -Specifies whether `gocode` should include suggestions from unimported -packages. By default it is disabled. +Specifies whether `gocode` should use source files instead of binary packages +for autocompletion proposals. By default it is disabled because it is +currently much slower. > - let g:go_gocode_unimported_packages = 0 + let g:go_gocode_propose_source = 0 < - *'g:go_gocode_socket_type'* Specifies whether `gocode` should use a different socket type. By default diff --git a/plugin/go.vim b/plugin/go.vim index 95bf7fd524..01e19b7d93 100644 --- a/plugin/go.vim +++ b/plugin/go.vim @@ -35,7 +35,7 @@ let s:packages = { \ 'dlv': ['github.com/derekparker/delve/cmd/dlv'], \ 'errcheck': ['github.com/kisielk/errcheck'], \ 'fillstruct': ['github.com/davidrjenni/reftools/cmd/fillstruct'], - \ 'gocode': ['github.com/nsf/gocode', {'windows': ['-ldflags', '-H=windowsgui']}], + \ 'gocode': ['github.com/mdempsky/gocode', {'windows': ['-ldflags', '-H=windowsgui']}], \ 'godef': ['github.com/rogpeppe/godef'], \ 'gogetdoc': ['github.com/zmb3/gogetdoc'], \ 'goimports': ['golang.org/x/tools/cmd/goimports'],