summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/completion/completion.lua5
-rw-r--r--script/core/completion/keyword.lua (renamed from script/core/keyword.lua)0
-rw-r--r--script/core/look-backward.lua1
-rw-r--r--test/completion/common.lua9
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)