diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go index e83686119a5..fc55aae5329 100644 --- a/internal/lsp/lsp_test.go +++ b/internal/lsp/lsp_test.go @@ -389,31 +389,10 @@ func (c completions) collect(src token.Position, expected []token.Pos) { } func (i completionItems) collect(pos token.Pos, label, detail, kind string) { - var k protocol.CompletionItemKind - switch kind { - case "struct": - k = protocol.StructCompletion - case "func": - k = protocol.FunctionCompletion - case "var": - k = protocol.VariableCompletion - case "type": - k = protocol.TypeParameterCompletion - case "field": - k = protocol.FieldCompletion - case "interface": - k = protocol.InterfaceCompletion - case "const": - k = protocol.ConstantCompletion - case "method": - k = protocol.MethodCompletion - case "package": - k = protocol.ModuleCompletion - } i[pos] = &protocol.CompletionItem{ Label: label, Detail: detail, - Kind: k, + Kind: protocol.ParseCompletionItemKind(kind), } } diff --git a/internal/lsp/protocol/enums.go b/internal/lsp/protocol/enums.go index 3106471b178..ecb8af4d70a 100644 --- a/internal/lsp/protocol/enums.go +++ b/internal/lsp/protocol/enums.go @@ -53,31 +53,31 @@ func init() { namesDiagnosticTag[int(Unnecessary)] = "Unnecessary" - namesCompletionItemKind[int(TextCompletion)] = "TextCompletion" - namesCompletionItemKind[int(MethodCompletion)] = "MethodCompletion" - namesCompletionItemKind[int(FunctionCompletion)] = "FunctionCompletion" - namesCompletionItemKind[int(ConstructorCompletion)] = "ConstructorCompletion" - namesCompletionItemKind[int(FieldCompletion)] = "FieldCompletion" - namesCompletionItemKind[int(VariableCompletion)] = "VariableCompletion" - namesCompletionItemKind[int(ClassCompletion)] = "ClassCompletion" - namesCompletionItemKind[int(InterfaceCompletion)] = "InterfaceCompletion" - namesCompletionItemKind[int(ModuleCompletion)] = "ModuleCompletion" - namesCompletionItemKind[int(PropertyCompletion)] = "PropertyCompletion" - namesCompletionItemKind[int(UnitCompletion)] = "UnitCompletion" - namesCompletionItemKind[int(ValueCompletion)] = "ValueCompletion" - namesCompletionItemKind[int(EnumCompletion)] = "EnumCompletion" - namesCompletionItemKind[int(KeywordCompletion)] = "KeywordCompletion" - namesCompletionItemKind[int(SnippetCompletion)] = "SnippetCompletion" - namesCompletionItemKind[int(ColorCompletion)] = "ColorCompletion" - namesCompletionItemKind[int(FileCompletion)] = "FileCompletion" - namesCompletionItemKind[int(ReferenceCompletion)] = "ReferenceCompletion" - namesCompletionItemKind[int(FolderCompletion)] = "FolderCompletion" - namesCompletionItemKind[int(EnumMemberCompletion)] = "EnumMemberCompletion" - namesCompletionItemKind[int(ConstantCompletion)] = "ConstantCompletion" - namesCompletionItemKind[int(StructCompletion)] = "StructCompletion" - namesCompletionItemKind[int(EventCompletion)] = "EventCompletion" - namesCompletionItemKind[int(OperatorCompletion)] = "OperatorCompletion" - namesCompletionItemKind[int(TypeParameterCompletion)] = "TypeParameterCompletion" + namesCompletionItemKind[int(TextCompletion)] = "text" + namesCompletionItemKind[int(MethodCompletion)] = "method" + namesCompletionItemKind[int(FunctionCompletion)] = "func" + namesCompletionItemKind[int(ConstructorCompletion)] = "constructor" + namesCompletionItemKind[int(FieldCompletion)] = "field" + namesCompletionItemKind[int(VariableCompletion)] = "var" + namesCompletionItemKind[int(ClassCompletion)] = "class" + namesCompletionItemKind[int(InterfaceCompletion)] = "interface" + namesCompletionItemKind[int(ModuleCompletion)] = "package" + namesCompletionItemKind[int(PropertyCompletion)] = "property" + namesCompletionItemKind[int(UnitCompletion)] = "unit" + namesCompletionItemKind[int(ValueCompletion)] = "value" + namesCompletionItemKind[int(EnumCompletion)] = "enum" + namesCompletionItemKind[int(KeywordCompletion)] = "keyword" + namesCompletionItemKind[int(SnippetCompletion)] = "snippet" + namesCompletionItemKind[int(ColorCompletion)] = "color" + namesCompletionItemKind[int(FileCompletion)] = "file" + namesCompletionItemKind[int(ReferenceCompletion)] = "reference" + namesCompletionItemKind[int(FolderCompletion)] = "folder" + namesCompletionItemKind[int(EnumMemberCompletion)] = "enumMember" + namesCompletionItemKind[int(ConstantCompletion)] = "const" + namesCompletionItemKind[int(StructCompletion)] = "struct" + namesCompletionItemKind[int(EventCompletion)] = "event" + namesCompletionItemKind[int(OperatorCompletion)] = "operator" + namesCompletionItemKind[int(TypeParameterCompletion)] = "type" namesInsertTextFormat[int(PlainTextTextFormat)] = "PlainText" namesInsertTextFormat[int(SnippetTextFormat)] = "Snippet" diff --git a/internal/lsp/source/enums.go b/internal/lsp/source/enums.go index 5ceea99aae5..9cb88ccaf61 100644 --- a/internal/lsp/source/enums.go +++ b/internal/lsp/source/enums.go @@ -29,16 +29,16 @@ func init() { namesDiagnosticSeverity[SeverityError] = "Error" namesCompletionItemKind[Unknown] = "Unknown" - namesCompletionItemKind[InterfaceCompletionItem] = "InterfaceCompletion" - namesCompletionItemKind[StructCompletionItem] = "StructCompletion" - namesCompletionItemKind[TypeCompletionItem] = "TypeCompletion" - namesCompletionItemKind[ConstantCompletionItem] = "ConstantCompletion" - namesCompletionItemKind[FieldCompletionItem] = "FieldCompletion" - namesCompletionItemKind[ParameterCompletionItem] = "ParameterCompletion" - namesCompletionItemKind[VariableCompletionItem] = "VariableCompletion" - namesCompletionItemKind[FunctionCompletionItem] = "FunctionCompletion" - namesCompletionItemKind[MethodCompletionItem] = "MethodCompletion" - namesCompletionItemKind[PackageCompletionItem] = "PackageCompletion" + namesCompletionItemKind[InterfaceCompletionItem] = "interface" + namesCompletionItemKind[StructCompletionItem] = "struct" + namesCompletionItemKind[TypeCompletionItem] = "type" + namesCompletionItemKind[ConstantCompletionItem] = "const" + namesCompletionItemKind[FieldCompletionItem] = "field" + namesCompletionItemKind[ParameterCompletionItem] = "parameter" + namesCompletionItemKind[VariableCompletionItem] = "var" + namesCompletionItemKind[FunctionCompletionItem] = "func" + namesCompletionItemKind[MethodCompletionItem] = "method" + namesCompletionItemKind[PackageCompletionItem] = "package" } func formatEnum(f fmt.State, c rune, i int, names []string, unknown string) {