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

Support for go 1.11 / go modules #316

Open robbyoconnor opened 6 years ago

robbyoconnor commented 6 years ago

Things need to be updated to support go 1.11, currently, things don't work correctly in go 1.11.

robbyoconnor commented 6 years ago

Also worth referencing: https://github.com/mdempsky/gocode/issues/46

doodleEsc commented 6 years ago

I currently have a simple solution

  1. go get -u github.com/visualfc/gocode (it supports go 1.11) and go get -u github.com/visualfc/gotools (needed by visualfc/gocode)
  2. create your project outside fo GOPATH, for example: /home/user/demo
  3. link the project under $GOPATH/src, ln -s /home/user/demo $GOPATH/src/demo

then it works for me now.

slimsag commented 6 years ago

https://github.com/sourcegraph/go-langserver/pull/305 should ultimately fix the PANIC issue once merged I think

anjmao commented 6 years ago

Hi, I could work on gocode autocomplete support for go 1.11.

  1. gbimporter can probably to be removed since it was used to support gb based projects.
  2. golang.org/x/tools/go/packages needs to be added
  3. go.mod file needs to be added for vendor libraries

@keegancsmith It looks that this change will potentially break go 1.9-1.10 support, which is something I don't like, but I will see how it goes.

The implementation depends on the Go 1.11 go command; support for earlier versions will be added soon.

anjmao commented 6 years ago

Before working on this issue we should probably implement https://github.com/sourcegraph/go-langserver/issues/320.

imjustfly commented 6 years ago

not only the code completion, also, find references doesn't work when project is out of gopath.

Tried to dig into this issue, but language server's implementation is too complicated.

imjustfly commented 6 years ago

I think I find the solution for finding references. Working on it.

imjustfly commented 6 years ago

321 makes references and lint available outside the GOPATH.

But in my own opinion, the best direction is rewriting the project with golang.org/x/tools/go/packages, which needs lots of works and is not compatible with older versions of go.

So I concern what's the plan for it ? @keegancsmith

dzhou121 commented 6 years ago

There is a new fork of gocode which works for modules https://github.com/stamblerre/gocode

vscode-go is starting to use it, and it's shown in golang issue trackers for tools supporting modules: https://github.com/golang/go/issues/24661

keegancsmith commented 6 years ago

Note: The go tools team at Google is working on a language server which will support go/packages from the get go. Here is some more information on that https://go-review.googlesource.com/c/tools/+/136676#message-11c783bc9a9f6adf6119bbb85c89510fda25abe9

Unless someone from the community does this for go-langserver, I suspect the server from google will be ready before we have time to work on this.

saibing commented 5 years ago

@robbyoconnor @keegancsmith @dzhou121

bingo is a new go language server that support go 1.11 modules

please try it.

mbana commented 5 years ago

Note: The go tools team at Google is working on a language server which will support go/packages from the get go. Here is some more information on that https://go-review.googlesource.com/c/tools/+/136676#message-11c783bc9a9f6adf6119bbb85c89510fda25abe9

Unless someone from the community does this for go-langserver, I suspect the server from google will be ready before we have time to work on this.

Thanks for sharing the link.

So, how does one use the new cmd/golsp?

keegancsmith commented 5 years ago

If you are using vscode check out https://github.com/golang/tools/tree/master/cmd/gopls/integration/vscode

mbana commented 5 years ago

@keegancsmith Thanks a lot.

I was able to get it working with golsp but I've found bingo to be more stable and faster so I am using bingo. I didn't have to install the extension that you linked to (https://github.com/golang/tools/tree/master/cmd/gopls/integration/vscode). vscode-go worked fine.

I've written a post about setting up the two: https://bana.io/blog/go-language-server/. I've happy to modify the contents of the blog post if you spot issues or have better ideas.

https://github.com/golang/tools/tree/master/cmd/gopls really needs a detailed README.md explaining how to get started and how to contribute. I've spotted a new panics that I know I can fix but looking at repo and it lack of documentation makes me think it's not getting much love, I could be wrong.

keegancsmith commented 5 years ago

gopls is under active development by google's go tools team. What I linked to is likely early days, although I believe it is getting close to some sort of announcement. bingo is a good alternative until then.

guiguan commented 5 years ago

Tried golsp along with its vscode extension. It gave me The gopls server crashed 5 times in the last 3 minutes. The server will not be restarted. error and couldn't figure out why.

@saibing your bingo works nicely. Thanks for the great work!

robbyoconnor commented 5 years ago

golsp worked for me fine...

On 2/27/19 9:35 PM, Guan Gui wrote:

Tried |golsp| along with its |vscode| extension. It gave me |The gopls server crashed 5 times in the last 3 minutes. The server will not be restarted.| error and couldn't figure out why.

@saibing https://github.com/saibing your |bingo| works nicely. Thanks for the great work!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sourcegraph/go-langserver/issues/316#issuecomment-468113019, or mute the thread https://github.com/notifications/unsubscribe-auth/AABaMFqFMASNmHRDK4C8mExv7xtZebVTks5vR0BUgaJpZM4WXCQr.