go-langserver icon indicating copy to clipboard operation
go-langserver copied to clipboard

Add build tag support for "Go to Definition" feature

Open ramya-rao-a opened this issue 8 years ago • 3 comments

See https://github.com/Microsoft/vscode-go/issues/1024

The language server doesnt return definition location when there is a build tag in the file

ramya-rao-a avatar Jun 09 '17 23:06 ramya-rao-a

@ramya-rao-a we actually support an unofficial extension to LSP to specify the build tags to use https://sourcegraph.com/github.com/sourcegraph/go-langserver/-/blob/langserver/lspx.go#L41

So your initialize request would additionally specify something like

{
  ...
  "BuildContext": {
    "BuildTags": ["integration"]
  }
}

keegancsmith avatar Feb 13 '18 12:02 keegancsmith

Am not sure how to include that when creating the language client. I can set the intializationOptions which you will get in https://sourcegraph.com/github.com/sourcegraph/go-langserver/-/blob/pkg/lsp/service.go#L18:2

ramya-rao-a avatar Feb 14 '18 05:02 ramya-rao-a

@ramya-rao-a To clarify what @keegancsmith said above a bit, you would specify the initializationOptions like this:

"initializationOptions": {
  ...your existing initialization options...
  "BuildContext": {
    "BuildTags": ["integration"]
  }
}

That is to say, the language server supports an unofficial extension to LSP where you can specify that BuildContext field in the initializationOptions field you normally sent on LSP client init.

emidoots avatar Feb 14 '18 05:02 emidoots