Skip to content

Provide Support for Installing Alternate gocode #1873

@naftulikay

Description

@naftulikay

What did you do? (required. The issue will be closed when not provided.)

Installed vim-go using vim-plug in Neovim.

What did you expect to happen?

I expected vim-go to provide me an option to choose github.com/mdempsky/gocode rather than github.com/nsf/gocode, as nsf/gocode doesn't work with the latest Go for local completions: mdempsky/gocode#32

Standard library completions work, but local file completion does not.

What happened instead?

It installed nsf/gocode without giving me an option to choose.

Configuration (MUST fill this out):

  • vim-go version:

Master: 155836d.

  • vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):
call plug#begin('~/.local/share/nvim/plugged')

Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'mdempsky/gocode', { 'rtp': 'nvim', 'do': '~/.local/share/nvim/plugged/gocode/nvim/symlink.sh' }
Plug 'zchee/deoplete-go', { 'do': 'make' }

call plug#end()

set completeopt+=noselect

let g:deoplete#enable_at_startup = 1
let g:deoplete#sources#go#gocode_binary = $HOME.'/devel/bin/gocode'
let g:deoplete#sources#go#sort_class = ['package', 'func', 'type', 'var', 'const']
let g:deoplete#sources#go#source_importer = 1
  • Vim version (first three lines from :version):
NVIM v0.2.2
Build type: RelWithDebInfo
LuaJIT 2.0.4
Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-HJnLxJ/neovim-0.2.2/build/config -I/build/neovim-HJnLxJ/neovim-0.2.2/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim-HJnLxJ/neovim-0.2.2/build/src/nvim/auto -I/build/neovim-HJnLxJ/neovim-0.2.2/build/include
  • Go version (go version):
go version go1.10.2 linux/amd64
  • Go environment (go env):
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/naftuli/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/naftuli/devel"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build403276097=/tmp/go-build -gno-record-gcc-switches"

In order to get things working with the above vimrc, I have to do the following things:

Patch autocomplete/go/complete.vim:

diff --git a/autoload/go/complete.vim b/autoload/go/complete.vim
index 127d57f..279b10c 100644
--- a/autoload/go/complete.vim
+++ b/autoload/go/complete.vim
@@ -9,6 +9,7 @@ function! s:gocodeCommand(cmd, args) abort
   let cmd = [bin_path]
   let cmd = extend(cmd, ['-sock', socket_type])
   let cmd = extend(cmd, ['-f', 'vim'])
+  let cmd = extend(cmd, ['-source'])
   let cmd = extend(cmd, [a:cmd])
   let cmd = extend(cmd, a:args)

This uses the -source flag which is unique to mdempsky/gocode. Again, I must use this gocode because otherwise local completions do not work.

Manually install github.com/mdempsky/gocode instead of github.com/nsf/gocode:

go get -u github.com/mdempsky/gocode

Manually configure deoplete-go to use source completion:

let g:deoplete#sources#go#source_importer = 1

Proposed Solution

If vim-go would allow me to specify that I want to use the mdempsky/gocode binary as opposed to nsf/gocode and support adding that -source flag, then everything would be a lot easier. Otherwise I have to patch the file on my local system which isn't very reusable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions