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:
parent
73054e8977
commit
a96101f168
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue