-
Notifications
You must be signed in to change notification settings - Fork 648
Add support for bingo & golsp language server (#2143) #2158
Conversation
You can use the isModSupported function to figure out if the current workspace supports modules or not. Based on this, you can then decide whether to use bingo or not. |
Just want to clarify a little more on this, if the user configured their vscode settings to
|
Yes, thats right. |
d62d0d2
to
af37c17
Compare
Not sure if there's a better place to check
|
src/goInstallTools.ts
Outdated
if (activeFileUri !== null) { | ||
const isModSupportedResult = await isModSupported(activeFileUri); | ||
if (languageServer === 'bingo' && !isModSupportedResult) { | ||
vscode.window.showInformationMessage('The Go language server (bingo) does not support non-go module projects. Falling back to default behavior.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this commit saibing/bingo@f9f872a
Bingo already supports non-go module projects. I tested it in GOPATH without modules and it was working fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bingo already supports non-go module project, I have done some manual test cases, it looks like everything is fine, I will add some automation test cases in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anjmao Thanks for the heads up! Kudos to @saibing for adding support for non-go module projects in such a short period of time 😅
@ramya-rao-a I guess I can remove the isModSupported
checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tohjustin Yes, I just tested it out with GOPATH, and it works. So we can remove the isModSupported
checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -40,6 +42,8 @@ const _allTools: { [key: string]: string } = { | |||
'golangci-lint': 'github.com/golangci/golangci-lint/cmd/golangci-lint', | |||
'revive': 'github.com/mgechev/revive', | |||
'go-langserver': 'github.com/sourcegraph/go-langserver', | |||
'bingo': 'github.com/saibing/bingo', | |||
'golsp': 'golang.org/x/tools/cmd/golsp', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stamblerre Would this be the right import path to use in go get
for the language server from your team?
src/goInstallTools.ts
Outdated
@@ -183,6 +195,8 @@ export function installAllTools(updateExistingToolsOnly: boolean = false) { | |||
'golangci-lint': 'Linter)', | |||
'revive': '\t\t(Linter)', | |||
'go-langserver': '(Language Server)', | |||
'bingo': '(Language Server)', | |||
'golsp': '(Language Server)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To help users differentiate lets add some suffixes here like
- Language Server by Sourcegraph
- Language Server by Google
- Language Server by saibing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/goInstallTools.ts
Outdated
if (activeFileUri !== null) { | ||
const isModSupportedResult = await isModSupported(activeFileUri); | ||
if (languageServer === 'bingo' && !isModSupportedResult) { | ||
vscode.window.showInformationMessage('The Go language server (bingo) does not support non-go module projects. Falling back to default behavior.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tohjustin The README.md would also need an update. There is a section there on the language server usage |
src/goInstallTools.ts
Outdated
tools.push('go-langserver'); | ||
} | ||
|
||
if (goConfig['useLanguageServer'] === 'bingo') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bingo is only supported from Go 1.11 onwards, so we should include that check here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah missed that out, will add the check in the following patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
0c0c09d
to
5d21bf4
Compare
Reworded quite a bit of the language server section (also ran it through Grammarly), please do let me know if you think it still needs more work 😅 |
c0f4d1b
to
6d65664
Compare
Hi @ramya-rao-a , I saw the issue opened by @stamblerre in saibing/bingo#13 & seems like the plan is to focus on golsp development. Any updates on this PR? 😅 |
* Changes made to the `go.useLanguageServer` setting requires VS Code to be reloaded to take effect. | ||
* To collect traces, set `"go.languageServerFlags": ["-trace"]`. | ||
* To collect errors from the language server in a log file, set `"go.languageServerFlags": ["-trace", "-logfile", "path to a text file that exists"]`. | ||
* Use the `go.languageServerExperimentalFeatures` setting to opt-in to experimental features such as Code Completion and Code Formatting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramya-rao-a @tohjustin Can we make go.languageServerExperimentalFeatures autocomplete and code formatting to be true by default? If I'm using LSP all I want to set by default is go. useLanguageServer
setting and get all the LSP features.
@anjmao Yes, we can do that
@tohjustin Given that there is a good likelihood of all 3 language servers merging into 1 (Sourcegraph plans to use the one from Google, @saibing and Google are planning to work together, I want to avoid changing the schema of the Instead, if one wants to use another language server, they can use the
This would need some changes from the extension which I have already made in ecb691c. @anjmao, @tohjustin Can you try the latest beta version with the above setting and let me know if you see any issues? |
@anjmao On second thoughts, I don't want to enable the formatting feature by the language server by default just yet. This is because the language server doesn't respect the formatFlags or the formalTool settings. I don't want to enable the auto-completion feature by language server by default, because the language server doesn't support completions for unimported packages yet. Once these 2 features from the language server has complete parity with what the extension does, I will turn them on by default. |
@ramya-rao-a Really appreciate the update! Yup the the
I guess I'll leave it up to you to close this PR or put it on hold until the new Go language server is ready. 👍 |
Thanks for confirming the beta version @tohjustin! I have updated the wiki on Go modules support in VS Code appropriately.
I believe closing this PR is the right thing to do as I want to avoid changes in settings schema as much as possible. Thanks for all your work on this @tohjustin, it is very much appreciated. |
Hi @ramya-rao-a, here's my attempt to add support for bingo & golsp language servers to the extension.
This Closes #2143.
Additional Notes
<MY_PROJECT_DIR>/go.mod does not exist, please use 'go mod init' to create it
errors (since bingo only supports Go Module based projects).