stamblerre / gocode

An autocompletion daemon for the Go programming language
MIT License
394 stars 28 forks source link

No completions for external package at first tries (integrated with ycmd) #20

Closed magodo closed 4 years ago

magodo commented 5 years ago

Please answer these questions before submitting your issue. Thanks! Also, remember that to restart gocode, you have to run gocode close.

What version of Go are you using (go version)?

go1.11

What operating system and processor architecture are you using (go env)?

GOARCH="amd64" GOBIN="" GOCACHE="/home/magodo/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/magodo/go" GOPROXY="" GORACE="" GOROOT="/usr/lib/go" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/magodo/projects/udb-v2/go.mod" 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-build613089893=/tmp/go-build -gno-record-gcc-switches"

What editor are using?

vim

Description

I substitute mdempsky/gocode with this one in ycmd. I also added -source option for external package completion. It almost works besides when I first open a go file and complete some external package, it will fail with no completions found error. After several (~3 times) retries, it works.

stamblerre commented 5 years ago

I'm not able to reproduce this when opening files, but if you are opening new Go files, perhaps you are encountering https://github.com/stamblerre/gocode/issues/3?

magodo commented 5 years ago

I'm not able to reproduce this when opening files, but if you are opening new Go files, perhaps you are encountering #3?

No, sometimes when the external package is big/complex, it seems will fail. I think it is caused by some different reason. I don't know how to get the error from vim/ycmd (even i added -debug option for gocode, the output from ycm seems have no help).

stamblerre commented 5 years ago

To get the debug output, you will have to start gocode manually.

$ gocode close
$ gocode -s -debug

Then you should be able to open up Vim and type normally, and the completion output will show up in terminal.

maxbaird commented 5 years ago

Where should the -source option be added for external package completion?

stamblerre commented 5 years ago

-source is necessary to type-check packages from source (rather than export data from a build), so it shouldn't be necessary for external packages to be completed. The -source flag should be provided on the client side, so you will have to configure it in your editor settings.

stamblerre commented 4 years ago

Closing this issue, as the current recommendation for autocompletion is to use gopls.