diff options
author | Rebecca Stambler <rstambler@golang.org> | 2021-09-24 14:09:49 -0400 |
---|---|---|
committer | Rebecca Stambler <rstambler@golang.org> | 2021-10-13 03:12:54 +0000 |
commit | 24389d4d0ca5f0b2458e2bcc37605b70d64c581b (patch) | |
tree | bca01d367d250a9f031385bfadd2e29072dfeacd /internal | |
parent | 074820e17b39fd2279bcad5e07f9734aac976428 (diff) | |
download | golang-x-tools-24389d4d0ca5f0b2458e2bcc37605b70d64c581b.tar.gz |
internal/lsp: use the correct dynamic registration booleans
I mistakenly used DynamicConfigurationSupported for all capabilities,
not just the workspace/configuration one.
Fixes golang/go#48600
Change-Id: Ie9b205d89da6e4d110a5310b31fc1ba22f2b5383
Reviewed-on: https://go-review.googlesource.com/c/tools/+/352055
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'internal')
-rw-r--r-- | internal/lsp/general.go | 23 | ||||
-rw-r--r-- | internal/lsp/source/options.go | 41 |
2 files changed, 32 insertions, 32 deletions
diff --git a/internal/lsp/general.go b/internal/lsp/general.go index 3c409d3d0..e6991887d 100644 --- a/internal/lsp/general.go +++ b/internal/lsp/general.go @@ -188,20 +188,17 @@ func (s *Server) initialized(ctx context.Context, params *protocol.InitializedPa } s.pendingFolders = nil + var registrations []protocol.Registration if options.ConfigurationSupported && options.DynamicConfigurationSupported { - registrations := []protocol.Registration{ - { - ID: "workspace/didChangeConfiguration", - Method: "workspace/didChangeConfiguration", - }, - { - ID: "workspace/didChangeWorkspaceFolders", - Method: "workspace/didChangeWorkspaceFolders", - }, - } - if options.SemanticTokens { - registrations = append(registrations, semanticTokenRegistration(options.SemanticTypes, options.SemanticMods)) - } + registrations = append(registrations, protocol.Registration{ + ID: "workspace/didChangeConfiguration", + Method: "workspace/didChangeConfiguration", + }) + } + if options.SemanticTokens && options.DynamicRegistrationSemanticTokensSupported { + registrations = append(registrations, semanticTokenRegistration(options.SemanticTypes, options.SemanticMods)) + } + if len(registrations) > 0 { if err := s.client.RegisterCapability(ctx, &protocol.RegistrationParams{ Registrations: registrations, }); err != nil { diff --git a/internal/lsp/source/options.go b/internal/lsp/source/options.go index cb4b11d96..4875111ac 100644 --- a/internal/lsp/source/options.go +++ b/internal/lsp/source/options.go @@ -81,13 +81,14 @@ func DefaultOptions() *Options { } defaultOptions = &Options{ ClientOptions: ClientOptions{ - InsertTextFormat: protocol.PlainTextTextFormat, - PreferredContentFormat: protocol.Markdown, - ConfigurationSupported: true, - DynamicConfigurationSupported: true, - DynamicWatchedFilesSupported: true, - LineFoldingOnly: false, - HierarchicalDocumentSymbolSupport: true, + InsertTextFormat: protocol.PlainTextTextFormat, + PreferredContentFormat: protocol.Markdown, + ConfigurationSupported: true, + DynamicConfigurationSupported: true, + DynamicRegistrationSemanticTokensSupported: true, + DynamicWatchedFilesSupported: true, + LineFoldingOnly: false, + HierarchicalDocumentSymbolSupport: true, }, ServerOptions: ServerOptions{ SupportedCodeActions: map[FileKind]map[protocol.CodeActionKind]bool{ @@ -183,18 +184,19 @@ type Options struct { // ClientOptions holds LSP-specific configuration that is provided by the // client. type ClientOptions struct { - InsertTextFormat protocol.InsertTextFormat - ConfigurationSupported bool - DynamicConfigurationSupported bool - DynamicWatchedFilesSupported bool - PreferredContentFormat protocol.MarkupKind - LineFoldingOnly bool - HierarchicalDocumentSymbolSupport bool - SemanticTypes []string - SemanticMods []string - RelatedInformationSupported bool - CompletionTags bool - CompletionDeprecated bool + InsertTextFormat protocol.InsertTextFormat + ConfigurationSupported bool + DynamicConfigurationSupported bool + DynamicRegistrationSemanticTokensSupported bool + DynamicWatchedFilesSupported bool + PreferredContentFormat protocol.MarkupKind + LineFoldingOnly bool + HierarchicalDocumentSymbolSupport bool + SemanticTypes []string + SemanticMods []string + RelatedInformationSupported bool + CompletionTags bool + CompletionDeprecated bool } // ServerOptions holds LSP-specific configuration that is provided by the @@ -655,6 +657,7 @@ func (o *Options) ForClientCapabilities(caps protocol.ClientCapabilities) { // Check if the client supports configuration messages. o.ConfigurationSupported = caps.Workspace.Configuration o.DynamicConfigurationSupported = caps.Workspace.DidChangeConfiguration.DynamicRegistration + o.DynamicRegistrationSemanticTokensSupported = caps.TextDocument.SemanticTokens.DynamicRegistration o.DynamicWatchedFilesSupported = caps.Workspace.DidChangeWatchedFiles.DynamicRegistration // Check which types of content format are supported by this client. |