diff options
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/completion.lua | 12 | ||||
-rw-r--r-- | script-beta/core/hover/arg.lua | 1 | ||||
-rw-r--r-- | script-beta/provider/init.lua | 9 | ||||
-rw-r--r-- | script-beta/vm/eachRef.lua | 3 |
4 files changed, 19 insertions, 6 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 diff --git a/script-beta/core/hover/arg.lua b/script-beta/core/hover/arg.lua index 983cc84e..9d557e3b 100644 --- a/script-beta/core/hover/arg.lua +++ b/script-beta/core/hover/arg.lua @@ -38,4 +38,5 @@ return function (source, caller) if source.type == 'function' then return asFunction(source, caller) end + return '' end diff --git a/script-beta/provider/init.lua b/script-beta/provider/init.lua index 6faae12e..d6cac333 100644 --- a/script-beta/provider/init.lua +++ b/script-beta/provider/init.lua @@ -312,13 +312,14 @@ proto.on('textDocument/completion', function (params) if not result then return nil end - local items = {} for i, res in ipairs(result) do items[i] = { - label = res.label, - kind = res.kind, - sortText = ('%04d'):format(i), + label = res.label, + kind = res.kind, + sortText = ('%04d'):format(i), + insertText = res.insertText, + insertTextFormat = res.insertTextFormat, } end diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index 972efc2d..4f653e00 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -406,6 +406,9 @@ local function ofGlobal(source, callback) end local function ofField(source, callback) + if not source then + return + end local parent = source.parent local key = guide.getKeyName(source) if parent.type == 'tablefield' |