diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-07 16:37:29 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-07 16:37:29 +0800 |
commit | a8c95b64d7e8a8481cbe961b8b872ef0710d618f (patch) | |
tree | 7cae49375d0387d2a813f37ce82718f01ebd1505 /script | |
parent | 24b83882cfca469a797bf5536f2d5c68762189bb (diff) | |
download | lua-language-server-a8c95b64d7e8a8481cbe961b8b872ef0710d618f.zip |
fix call snip
Diffstat (limited to 'script')
-rw-r--r-- | script/core/completion.lua | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua index 60c3e16d..ee61029d 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -121,17 +121,9 @@ local function findParentInStringIndex(ast, text, offset) return parent.node, false end -local function buildFunctionSnip(source, oop) +local function buildFunctionSnip(source, value, oop) local name = getName(source):gsub('^.+[$.:]', '') - local defs = vm.getDefs(source, 0) - local args = '' - for _, def in ipairs(defs) do - local defArgs = getArg(def, oop) - if defArgs ~= '' then - args = defArgs - break - end - end + local args = getArg(value, oop) local id = 0 args = args:gsub('[^,]+', function (arg) id = id + 1 @@ -191,7 +183,7 @@ local function buildDesc(source) return md:string() end -local function buildFunction(results, source, oop, data) +local function buildFunction(results, source, value, oop, data) local snipType = config.config.completion.callSnippet if snipType == 'Disable' or snipType == 'Both' then results[#results+1] = data @@ -199,7 +191,7 @@ local function buildFunction(results, source, oop, data) if snipType == 'Both' or snipType == 'Replace' then local snipData = util.deepCopy(data) snipData.kind = define.CompletionItemKind.Snippet - snipData.insertText = buildFunctionSnip(source, oop) + snipData.insertText = buildFunctionSnip(source, value, oop) snipData.insertTextFormat = 2 snipData.id = stack(function () return { @@ -286,7 +278,7 @@ local function checkLocal(ast, word, offset, results) if def.type == 'function' or def.type == 'doc.type.function' then local funcLabel = name .. getParams(def, false) - buildFunction(results, source, false, { + buildFunction(results, source, def, false, { label = funcLabel, insertText = name, kind = define.CompletionItemKind.Function, @@ -434,7 +426,7 @@ local function checkFieldThen(name, src, word, start, offset, parent, oop, resul else kind = define.CompletionItemKind.Function end - buildFunction(results, src, oop, { + buildFunction(results, src, value, oop, { label = name, kind = kind, insertText = name:match '^[^(]+', |