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,
|
End: pos,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
InsertTextFormat: insertTextFormat,
|
||||||
// This is a hack so that the client sorts completion results in the order
|
// 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
|
// according to their score. This can be removed upon the resolution of
|
||||||
// https://github.com/Microsoft/language-server-protocol/issues/348.
|
// https://github.com/Microsoft/language-server-protocol/issues/348.
|
||||||
|
|
|
@ -1017,8 +1017,11 @@ type InnerClientCapabilities struct {
|
||||||
Experimental interface{} `json:"experimental,omitempty"`
|
Experimental interface{} `json:"experimental,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientCapabilities is:
|
// TODO(rstambler): Remove this when golang.org/issue/31090 is resolved.
|
||||||
type ClientCapabilities struct {
|
type ClientCapabilities map[string]interface{}
|
||||||
|
|
||||||
|
// clientCapabilities is:
|
||||||
|
type clientCapabilities struct {
|
||||||
InnerClientCapabilities
|
InnerClientCapabilities
|
||||||
ImplementationClientCapabilities
|
ImplementationClientCapabilities
|
||||||
TypeDefinitionClientCapabilities
|
TypeDefinitionClientCapabilities
|
||||||
|
|
|
@ -93,9 +93,14 @@ func (s *Server) Initialize(ctx context.Context, params *protocol.InitializePara
|
||||||
s.initialized = true // mark server as initialized now
|
s.initialized = true // mark server as initialized now
|
||||||
|
|
||||||
// Check if the client supports snippets in completion items.
|
// Check if the client supports snippets in completion items.
|
||||||
capText := params.Capabilities.InnerClientCapabilities.TextDocument
|
if x, ok := params.Capabilities["textDocument"].(map[string]interface{}); ok {
|
||||||
if capText != nil && capText.Completion != nil && capText.Completion.CompletionItem != nil {
|
if x, ok := x["completion"].(map[string]interface{}); ok {
|
||||||
s.snippetsSupported = capText.Completion.CompletionItem.SnippetSupport
|
if x, ok := x["completionItem"].(map[string]interface{}); ok {
|
||||||
|
if x, ok := x["snippetSupport"].(bool); ok {
|
||||||
|
s.snippetsSupported = x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s.signatureHelpEnabled = true
|
s.signatureHelpEnabled = true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue