summaryrefslogtreecommitdiff
path: root/server/src/core/completion.lua
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-25 19:57:02 +0800
committersumneko <sumneko@hotmail.com>2019-04-25 19:57:02 +0800
commit3391ab935f18e928da414c19a84e7afc4acee779 (patch)
treecef22e7df9c64213e039935c7ca343e7f2c1f9be /server/src/core/completion.lua
parent86469f78d13bee5e53c4c073ad6c0961bc42f123 (diff)
downloadlua-language-server-3391ab935f18e928da414c19a84e7afc4acee779.zip
加个自动完成
Diffstat (limited to 'server/src/core/completion.lua')
-rw-r--r--server/src/core/completion.lua15
1 files changed, 15 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)