Open felixfbecker opened 5 years ago
Ooh sweet, will do!
Ok, so I tried it out and it didn't work out of the box, but the issues appear fixable:
initializationOptions
(to include zipURL
, which is based on the rootUri). I think this has to be different from the rootUri because the go-langserver uses the rootUri to determine the import path or something.originalRootUri
to be set in the InitParams
, not sure how necessary this is, though.I submitted a PR that fixes these two: https://github.com/sourcegraph/lsp-client/pull/11
However, even after that, it looks like lsp-client just go stuck after the initialize request and didn't send any hover requests: Edit I had the wrong document selector https://github.com/sourcegraph/sourcegraph-go/pull/36#discussion_r262581023
Here's a WIP for sourcegraph-go https://github.com/sourcegraph/sourcegraph-go/pull/36 in case you want to try to repro locally.
Thanks for trying it!
- I need a way to set
initializationOptions
(to includezipURL
, which is based on the rootUri). I think this has to be different from the rootUri because the go-langserver uses the rootUri to determine the import path or something.
Why can't it figure out the import path from rootUri
?
- go-langserver expects
originalRootUri
to be set in theInitParams
, not sure how necessary this is, though.
What is it used for / what is it set to?
However, even after that, it looks like lsp-client just go stuck after the initialize request and didn't send any hover requests:
Does the Go langserver return the hover capability?
Why can't it figure out the import path from
rootUri
?
You mean go-langserver could be taught how to strip the noise like /-/raw
from rootUri
to get the github.com/org/repo
part?
I was curious what go-langserver did with the rootUri
, and I found that it mounts the files in the VFS at a path like $GOPATH/src/<rootUri>
https://github.com/sourcegraph/go-langserver/blob/f9fdcbb3871320e0655530b707a3d276d561311a/langserver/handler_common.go#L35
What is it (originalRootUri) used for / what is it set to?
It's pretty much the same as rootUri
, needs more investigation to determine whether or not we could drop it and use rootUri
.
Does the Go langserver return the hover capability?
Edit I had the wrong document selector. https://github.com/sourcegraph/sourcegraph-go/pull/36#discussion_r262581023
Yeah, you can see it in the screenshot:
You mean go-langserver could be taught how to strip the noise like /-/raw from rootUri to get the github.com/org/repo part?
I mean, it already needs to do something right now since the rootUri
can't be set to github.com/org/repo
Oh, that's what originalRootUri
is for. Maybe we can feed two birds with one seed by moving originalRootUri
into initializationOptions
and letting consumers of lsp-client set custom values in initializationOptions
?
I in any way possible I would like to avoid supporting things like that because it's against the indented use of initializationOptions
and won't be compatible with multi-root support.
How does Go know from looking at a file which import path it has?
Then I need to determine whether or not go-langserver can work without knowing where to mount the repo in the VFS, which deprioritizes this in my TODO list https://github.com/sourcegraph/sourcegraph/issues/2452
@felixfbecker I'd be happy to implement custom initializationOptions
in lsp-client 😃 I'll be responsible for any use of it in the Go extension.
originalRootUri
must be passed at the top level because some users are running old/current versions of go-langserver which expect it to be there.
Ok, I got lsp-client (mostly) working with these changes:
Xrefs don't work yet. Any idea how lsp-client can support custom references providers such as this?
Oh, I think the Go extension can use the LSPClient
that's returned by register
.
sourcegraph-go:insiders@sha256:9b2eb14e6acdd41c3e7fe312b79a72200efa4cac096eb13e2ecd86ee67821a62
was pushed 10 minutes ago with support for more lsp-compliant initialization options.
Next steps:
@sourcegraph/lsp-client
package https://github.com/sourcegraph/sourcegraph-go/pull/36
@sourcegraph/lsp-client
is ready to use, please adopt it and give feedback :)