internal/lsp: add a work-around for golang.org/issue/31090
Change-Id: I6be1a61bc0b573913ef86b7a47e9f71d036f84e3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170011
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
diff --git a/internal/lsp/completion.go b/internal/lsp/completion.go
index f0d8bcb..c2c8cda 100644
--- a/internal/lsp/completion.go
+++ b/internal/lsp/completion.go
@@ -46,6 +46,7 @@
End: pos,
},
},
+ InsertTextFormat: insertTextFormat,
// This is a hack so that the client sorts completion results in the order
// according to their score. This can be removed upon the resolution of
// https://github.com/Microsoft/language-server-protocol/issues/348.
diff --git a/internal/lsp/protocol/tsprotocol.go b/internal/lsp/protocol/tsprotocol.go
index c0cba77..11962ac 100644
--- a/internal/lsp/protocol/tsprotocol.go
+++ b/internal/lsp/protocol/tsprotocol.go
@@ -1017,8 +1017,11 @@
Experimental interface{} `json:"experimental,omitempty"`
}
-// ClientCapabilities is:
-type ClientCapabilities struct {
+// TODO(rstambler): Remove this when golang.org/issue/31090 is resolved.
+type ClientCapabilities map[string]interface{}
+
+// clientCapabilities is:
+type clientCapabilities struct {
InnerClientCapabilities
ImplementationClientCapabilities
TypeDefinitionClientCapabilities
diff --git a/internal/lsp/server.go b/internal/lsp/server.go
index c3e5090..0ea0085 100644
--- a/internal/lsp/server.go
+++ b/internal/lsp/server.go
@@ -93,9 +93,14 @@
s.initialized = true // mark server as initialized now
// Check if the client supports snippets in completion items.
- capText := params.Capabilities.InnerClientCapabilities.TextDocument
- if capText != nil && capText.Completion != nil && capText.Completion.CompletionItem != nil {
- s.snippetsSupported = capText.Completion.CompletionItem.SnippetSupport
+ if x, ok := params.Capabilities["textDocument"].(map[string]interface{}); ok {
+ if x, ok := x["completion"].(map[string]interface{}); ok {
+ if x, ok := x["completionItem"].(map[string]interface{}); ok {
+ if x, ok := x["snippetSupport"].(bool); ok {
+ s.snippetsSupported = x
+ }
+ }
+ }
}
s.signatureHelpEnabled = true