Skip to content

Commit 97df485

Browse files
authored
Merge pull request #1051 from fredrikekre/fe/completion-kinds
Use CompletionItemKinds named tuple instead of literals
2 parents eddcb92 + bc475c4 commit 97df485

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

src/requests/completions.jl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,28 +284,30 @@ end
284284
function _completion_kind(b)
285285
if b isa StaticLint.Binding
286286
if b.type == StaticLint.CoreTypes.String
287-
return 1
287+
return CompletionItemKinds.Text
288288
elseif b.type == StaticLint.CoreTypes.Function
289-
return 2
289+
return CompletionItemKinds.Method
290290
elseif b.type == StaticLint.CoreTypes.Module
291-
return 9
291+
return CompletionItemKinds.Module
292292
elseif b.type == Int || b.type == StaticLint.CoreTypes.Float64
293-
return 12
293+
return CompletionItemKinds.Value
294294
elseif b.type == StaticLint.CoreTypes.DataType
295-
return 22
295+
return CompletionItemKinds.Struct
296+
elseif b.type === nothing || b.type isa SymbolServer.DataTypeStore
297+
return CompletionItemKinds.Variable
296298
else
297-
return 13
299+
return CompletionItemKinds.Enum
298300
end
299301
elseif b isa SymbolServer.ModuleStore || b isa SymbolServer.VarRef
300-
return 9
302+
return CompletionItemKinds.Module
301303
elseif b isa SymbolServer.MethodStore
302-
return 2
304+
return CompletionItemKinds.Method
303305
elseif b isa SymbolServer.FunctionStore
304-
return 3
306+
return CompletionItemKinds.Function
305307
elseif b isa SymbolServer.DataTypeStore
306-
return 22
308+
return CompletionItemKinds.Struct
307309
else
308-
return 6
310+
return CompletionItemKinds.Variable
309311
end
310312
end
311313

test/requests/completions.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,17 @@ end
133133
@test any(item.label == "βbb" for item in completion_test(4, 2).items)
134134
@test any(item.label == "bβb" for item in completion_test(5, 2).items)
135135
end
136+
137+
@testset "completion kinds" begin
138+
Kinds = LanguageServer.CompletionItemKinds
139+
# issue #872
140+
settestdoc("""
141+
function f(kind_variable_arg)
142+
kind_variable_local = 1
143+
kind_variable_
144+
end
145+
""")
146+
items = completion_test(2, 18).items
147+
@test any(i -> i.label == "kind_variable_local" && i.kind == Kinds.Variable, items)
148+
@test any(i -> i.label == "kind_variable_arg" && i.kind == Kinds.Variable, items)
149+
end

0 commit comments

Comments
 (0)