-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/server: fix two bugs related to dynamic configuration
Fix two bugs related to dynamic configuration, that combine to prevent several clients from correctly configuring gopls, as reported in golang/go#65519 (Eglot), slack (lsp-mode), and team chat (Helix). The first bug has existed ~forever: when we make a workspace/configuration request in response to a didChangeConfiguration notification, we attempt to fetch the "global" settings by passing "scopeURI": "". The LSP spec defines "scopeURI" as a nullable URI: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#configurationItem Apparently, Javascript-based clients such as VS Code and coc.nvim (the two clients I regularly test with) will happily accept "" as a falsy value, and so this global query works. However, this query fails in Eglot (and likely other clients), causing didChangeConfiguration not to work. The second bug is new: When adding a new workspace folder we were failing to overwrite opts with the correct value (:= vs =, alas). This initial query had been masking the bug described above in Emacs, whereas in VS Code the (incorrectly) successful workspace/configuration request above masked the new bug. Since they both fail in Eglot, they are revealed. The fake editor is updated to reject the "" scope, highlighting the first bug. A new integration test is added to exercise the second bug, by way of a new integration test option to add per-folder configuration. Additionally, a marker test is added to exercise static configuration, which is when the client does not support the configuration capability at all. This wasn't actually broken, as first suspected, but the test is useful to include anyway, as we had no tests for this client behavior. Fixes golang/go#65519 Change-Id: Ie7170e3a26001546d4e334b83e6e73cd4ade10d8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/563475 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Findley <rfindley@google.com>
- Loading branch information
Showing
6 changed files
with
148 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
gopls/internal/test/marker/testdata/configuration/static.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
This test confirms that gopls honors configuration even if the client does not | ||
support dynamic configuration. | ||
|
||
-- capabilities.json -- | ||
{ | ||
"configuration": false | ||
} | ||
|
||
-- settings.json -- | ||
{ | ||
"usePlaceholders": true, | ||
"analyses": { | ||
"composites": false | ||
} | ||
} | ||
|
||
-- go.mod -- | ||
module example.com/config | ||
|
||
go 1.18 | ||
|
||
-- a/a.go -- | ||
package a | ||
|
||
import "example.com/config/b" | ||
|
||
func Identity[P ~int](p P) P { //@item(Identity, "Identity", "", "") | ||
return p | ||
} | ||
|
||
func _() { | ||
_ = b.B{2} | ||
_ = Identi //@snippet(" //", Identity, "Identity(${1:p P})"), diag("Ident", re"(undefined|undeclared)") | ||
} | ||
|
||
-- b/b.go -- | ||
package b | ||
|
||
type B struct { | ||
F int | ||
} |