diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-07-05 20:43:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-07-05 20:43:22 +0800 |
commit | 55166a406c56de8fe9f6932fabf9ca1c3cca469a (patch) | |
tree | 1b4bce3dce19264823ad03b45e7616803348bf2e /script | |
parent | 2ab618716a33378449aa4938864db632a141719e (diff) | |
download | lua-language-server-55166a406c56de8fe9f6932fabf9ca1c3cca469a.zip |
resolve #899 no longer generate parameter types
with setting `completion.callSnippet`
Diffstat (limited to 'script')
-rw-r--r-- | script/core/completion/completion.lua | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index a8895f72..69488e36 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -160,32 +160,19 @@ local function buildFunctionSnip(source, value, oop) if oop then table.remove(args, 1) end - local len = #args - local truncated = false - if len > 0 and args[len]:match('^%s*%.%.%.:') then - table.remove(args) - truncated = true - end - for i = #args, 1, -1 do - if args[i]:match('^%s*[^?]+%?:') - or args[i]:match('^%.%.%.') then - table.remove(args) - truncated = true - else - break - end - end local snipArgs = {} for id, arg in ipairs(args) do - local str = arg:gsub('^(%s*)(.+)', function (sp, word) + local str, count = arg:gsub('^(%s*)(%.%.%.)(.+)', function (sp, word) return ('%s${%d:%s}'):format(sp, id, word) end) + if count == 0 then + str = arg:gsub('^(%s*)([^:]+)(.+)', function (sp, word) + return ('%s${%d:%s}'):format(sp, id, word) + end) + end table.insert(snipArgs, str) end - if truncated and #snipArgs == 0 then - snipArgs = {'$1'} - end return ('%s(%s)'):format(name, table.concat(snipArgs, ', ')) end |