summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
authorkevinhwang91 <kevin.hwang@live.com>2022-04-03 22:24:29 +0800
committerkevinhwang91 <kevin.hwang@live.com>2022-04-03 22:34:22 +0800
commit7f9547be6881c16cdf6d0977acf4c726c6e15348 (patch)
tree69109d07b6b84223030a7dbc659afc8818c51798 /script/core
parenteae37dadcf034cc6b0816712efae9ec6f32fcdb2 (diff)
downloadlua-language-server-7f9547be6881c16cdf6d0977acf4c726c6e15348.zip
feat(completion): truncate arguments for callSnippet
The callSnippet always expands all the optional arguments and variable argument that is annoying. To truncate optional arguments and variable arguments help users more frequently use `callSnippet`. We already have the label and signature to get the total arguments. This behavior is like tsserver.
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion/completion.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index 30df047c..05b035af 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -158,11 +158,14 @@ local function buildFunctionSnip(source, value, oop)
local args = getArg(value, oop)
local id = 0
args = args:gsub('[^,]+', function (arg)
+ if arg:match('^%s+[^?]+%?:') or arg:match('^%s+%.%.%.:') then
+ return ''
+ end
id = id + 1
return arg:gsub('^(%s*)(.+)', function (sp, word)
return ('%s${%d:%s}'):format(sp, id, word)
end)
- end)
+ end):gsub(',+$', '')
return ('%s(%s)'):format(name, args)
end