summaryrefslogtreecommitdiff
path: root/script-beta/core/completion.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-10 14:10:01 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-10 14:10:01 +0800
commit328db97c169dfa44607acebd09bd63ca22491733 (patch)
tree752c84602e1d56fb6cf72b55aa3031222f560e05 /script-beta/core/completion.lua
parent680d5e7e34290d978abe1cba1c43b5321e5f5e79 (diff)
downloadlua-language-server-328db97c169dfa44607acebd09bd63ca22491733.zip
更新函数完成
Diffstat (limited to 'script-beta/core/completion.lua')
-rw-r--r--script-beta/core/completion.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index 3d14779f..8e7dfdf9 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -117,8 +117,15 @@ end
local function buildFunctionSnip(source)
local name = getName(source)
- local arg = getArg(source)
- return ('%s(%s)'):format(name, arg)
+ local args = getArg(source)
+ local id = 0
+ args = args:gsub('[^,]+', function (arg)
+ id = id + 1
+ return arg:gsub('^(%s*)(.+)', function (sp, word)
+ return ('%s${%d:%s}'):format(sp, id, word)
+ end)
+ end)
+ return ('%s(%s)'):format(name, args)
end
local function buildFunction(results, source, oop, data)
@@ -131,6 +138,7 @@ local function buildFunction(results, source, oop, data)
snipData.kind = ckind.Snippet
snipData.label = snipData.label .. '()'
snipData.insertText = buildFunctionSnip(source)
+ snipData.insertTextFormat = 2
results[#results+1] = snipData
end
end