diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-25 19:57:02 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-25 19:57:02 +0800 |
commit | 3391ab935f18e928da414c19a84e7afc4acee779 (patch) | |
tree | cef22e7df9c64213e039935c7ca343e7f2c1f9be /server | |
parent | 86469f78d13bee5e53c4c073ad6c0961bc42f123 (diff) | |
download | lua-language-server-3391ab935f18e928da414c19a84e7afc4acee779.zip |
加个自动完成
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/completion.lua | 15 | ||||
-rw-r--r-- | server/test/completion/init.lua | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index eb4e9a1d..1ae88c8f 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -436,6 +436,21 @@ local function searchEmmyFunctionParam(vm, source, word, callback) if not func.args then return end + if word == '' then + local list = {} + local args = {} + for i, arg in ipairs(func.args) do + args[i] = arg.name + if i == 1 then + list[i] = ('%s any'):format(arg.name) + else + list[i] = ('---@param %s any'):format(arg.name) + end + end + callback(('(%s)'):format(table.concat(args, ', ')), nil, CompletionItemKind.Snippet, { + insertText = table.concat(list, '\n') + }) + end for _, arg in ipairs(func.args) do if matchKey(word, arg.name) then callback(arg.name, arg, CompletionItemKind.Interface) diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua index f8d1bef0..60e197bc 100644 --- a/server/test/completion/init.lua +++ b/server/test/completion/init.lua @@ -850,6 +850,14 @@ end ]] { { + label = '(a, b, c)', + kind = CompletionItemKind.Snippet, + insertText = [[ +a any +---@param b any +---@param c any]] + }, + { label = 'a', kind = CompletionItemKind.Interface, }, |