diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-06-27 21:42:53 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-06-27 21:42:53 +0800 |
commit | 07c2cec7341676e587fe73f7ecbd361c9eb9a5b9 (patch) | |
tree | bc60eabd9893cc8f3c639bc962501aaade36ed21 /server/src | |
parent | 4db019185cc52a046fbc630078bed743b9819144 (diff) | |
download | lua-language-server-07c2cec7341676e587fe73f7ecbd361c9eb9a5b9.zip |
自动完成支持enum.comment
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/core/completion.lua | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 37527ac2..ddbe7271 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -663,6 +663,17 @@ local function searchEnumAsLib(vm, source, word, callback, pos, args, lib) end end +local function buildEmmyEnumComment(option, data) + if not option or not option.comment then + return data + end + if not data then + data = {} + end + data.documentation = tostring(option.comment) + return data +end + local function searchEnumAsEmmyParams(vm, source, word, callback, pos, args, func) local select = #args + 1 for i, arg in ipairs(args) do @@ -677,18 +688,18 @@ local function searchEnumAsEmmyParams(vm, source, word, callback, pos, args, fun return end - param:eachEnum(function (str) + param:eachEnum(function (str, option) if matchKey(word, str) then local strSource = parser:ast(tostring(str), 'String') if strSource then if source.type == 'string' then local data = buildTextEdit(source.start, source.finish, strSource[1], source[2]) - callback(str, nil, CompletionItemKind.EnumMember, data) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(option, data)) else - callback(str, nil, CompletionItemKind.EnumMember) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(option)) end else - callback(str, nil, CompletionItemKind.EnumMember) + callback(str, nil, CompletionItemKind.EnumMember, buildEmmyEnumComment(option)) end end end) |