From 7f9547be6881c16cdf6d0977acf4c726c6e15348 Mon Sep 17 00:00:00 2001 From: kevinhwang91 Date: Sun, 3 Apr 2022 22:24:29 +0800 Subject: 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. --- script/core/completion/completion.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'script/core/completion/completion.lua') 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 -- cgit v1.2.3