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>
This commit is contained in:
Rebecca Stambler 2019-03-29 18:16:43 -04:00
parent 73054e8977
commit a96101f168
3 changed files with 14 additions and 5 deletions

View File

@ -46,6 +46,7 @@ func toProtocolCompletionItems(candidates []source.CompletionItem, prefix string
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.

View File

@ -1017,8 +1017,11 @@ type InnerClientCapabilities struct {
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

View File

@ -93,9 +93,14 @@ func (s *Server) Initialize(ctx context.Context, params *protocol.InitializePara
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