sourcegraph / go-langserver

Go language server to add Go support to editors and other tools that use the Language Server Protocol (LSP)
https://sourcegraph.com
MIT License
1.17k stars 89 forks source link

Unable to auto complete the modules #319

Closed seagle0128 closed 6 years ago

seagle0128 commented 6 years ago

I upgraded to the latest go-langserver, and found the local modules including vendor/ and others (e.g. common/, lib/ etc.) couldn't autocomplete. I reverted to d0a69e92f6bdce74c7acdd59fdca57cca2a9587e, and it works well. I doubt the issue is related to 28e52ba21ccbf22a81d274d5cfdd2179cac04b79.

Running go1.10.4 darwin/amd64

seagle0128 commented 6 years ago

Actually I found there is no output in $GOPATH/pkg, but should be there. This issue is related to https://github.com/mdempsky/gocode/issues/47, I believe, since go install vendor/... fix it manually. Please follow up.

keegancsmith commented 6 years ago

cc @anjmao who recently updated our vendored gocode.

anjmao commented 6 years ago

I'm using vscode and there is no such problem. Probably because vscode-go automatically builds to pkg. Even if I remove pkg folder on save I get pkg back. vscode output

Finished running tool: /usr/local/go/bin/go build -i -o /var/folders/jc/1233a/T/go-code-check.1693675331 do/cmd/server
Finished running tool: /usr/local/go/bin/go vet ./...

In go-langserver gocode binary cache is enabled by default. The only solution I see if you are not using vscode is to build vendor manually since gocode should not be responsible for doing that, but editor extension should.

seagle0128 commented 6 years ago

@anjmao did you try cleaning all pkg and cache?

go clean -cache
rm -rf $GOAPTH/pkg

Basically I agree with you. But I revert to https://github.com/sourcegraph/go-langserver/commit/d0a69e92f6bdce74c7acdd59fdca57cca2a9587e , all work fine. All binary cache is generated automatically,while the latest build won't. The behaviors are different. Please check.

@keegancsmith @anjmao This commit https://github.com/sourcegraph/go-langserver/commit/28e52ba21ccbf22a81d274d5cfdd2179cac04b79 updated the gocode.

anjmao commented 6 years ago

@seagle0128 Which editor are you using is it atom + go-plus?

seagle0128 commented 6 years ago

@anjmao I am using Emacs + lsp-mode.

seagle0128 commented 6 years ago

I tried eglot which is another lsp client of Emacs. The same issue.

udaykumar106 commented 6 years ago

Same problem with neovim + deoplete + LanguageClient-neovim. As @seagle0128 says, if I revert go-langserver to 28e52ba, everything works. @keegancsmith , @anjmao

keegancsmith commented 6 years ago

We depend on upstream gocode, so until mdempsky/gocode#47 is solved, I don't think we have a solution. Something we could possible do is run go install as part of go-langserver doing diagnostics.

alecthomas commented 6 years ago

They just closed that issue with "won't fix"...

seagle0128 commented 6 years ago

I don't understand why. It's a regression issue IMO.

seagle0128 commented 6 years ago

https://github.com/mdempsky/gocode/issues/47 has been fixed by https://github.com/mdempsky/gocode/commit/a07fefd98fdcd9d2c16aa3f61d8e89eda396bf99. Please merge. Thanks.

BTW: I noticed VS Code has switch to use https://github.com/stamblerre/gocode now.

seagle0128 commented 6 years ago

Thanks a lot!

keegancsmith commented 6 years ago

Thanks @imjustfly!

udaykumar106 commented 6 years ago

Thank you