diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-02 16:34:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-02 16:34:55 +0800 |
commit | 25d3e051095ff1f1b7da58e591b2455a25d19328 (patch) | |
tree | 262b756f7d045fa1c080e23d3234f94a9f2a9acb | |
parent | 6aa49faddea1c572140b84a72a8bfa850d9143fd (diff) | |
download | lua-language-server-25d3e051095ff1f1b7da58e591b2455a25d19328.zip |
improve completion
-rw-r--r-- | script/core/completion/completion.lua | 5 | ||||
-rw-r--r-- | script/core/completion/keyword.lua (renamed from script/core/keyword.lua) | 0 | ||||
-rw-r--r-- | script/core/look-backward.lua | 1 | ||||
-rw-r--r-- | test/completion/common.lua | 9 |
4 files changed, 12 insertions, 3 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 2c3a354d..969de95a 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -11,7 +11,7 @@ local config = require 'config' local util = require 'utility' local markdown = require 'provider.markdown' local parser = require 'parser' -local keyWordMap = require 'core.keyword' +local keyWordMap = require 'core.completion.keyword' local workspace = require 'workspace' local furi = require 'file-uri' local rpath = require 'workspace.require-path' @@ -723,7 +723,7 @@ local function checkKeyWord(state, start, position, word, hasSpace, afterLocal, local text = state.lua local snipType = config.get(state.uri, 'Lua.completion.keywordSnippet') local symbol = lookBackward.findSymbol(text, guide.positionToOffset(state, start)) - local isExp = symbol == '(' or symbol == ',' or symbol == '=' + local isExp = symbol == '(' or symbol == ',' or symbol == '=' or symbol == '[' local info = { hasSpace = hasSpace, isExp = isExp, @@ -1473,7 +1473,6 @@ local function checkTableLiteralField(state, position, tbl, fields, results) results[#results+1] = { label = guide.getKeyName(field), kind = define.CompletionItemKind.Property, - insertText = ('%s = $0'):format(guide.getKeyName(field)), id = stack(function () ---@async return { detail = buildDetail(field), diff --git a/script/core/keyword.lua b/script/core/completion/keyword.lua index 5558106a..5558106a 100644 --- a/script/core/keyword.lua +++ b/script/core/completion/keyword.lua diff --git a/script/core/look-backward.lua b/script/core/look-backward.lua index 82f2ea1f..eea089bc 100644 --- a/script/core/look-backward.lua +++ b/script/core/look-backward.lua @@ -54,6 +54,7 @@ function m.findSymbol(text, offset) or char == ':' or char == '(' or char == ',' + or char == '[' or char == '=' then return char, i else diff --git a/test/completion/common.lua b/test/completion/common.lua index 818d0ac5..787549f7 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -3079,3 +3079,12 @@ TEST [[ if<??> ]] (EXISTS) + +TEST [[ +local t = x[<??>] +]] +(function (results) + for _, res in ipairs(results) do + assert(res.label ~= 'do') + end +end) |