Skip to content

Commit 25d3e05

Browse files
committed
improve completion
1 parent 6aa49fa commit 25d3e05

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

script/core/completion/completion.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local config = require 'config'
1111
local util = require 'utility'
1212
local markdown = require 'provider.markdown'
1313
local parser = require 'parser'
14-
local keyWordMap = require 'core.keyword'
14+
local keyWordMap = require 'core.completion.keyword'
1515
local workspace = require 'workspace'
1616
local furi = require 'file-uri'
1717
local rpath = require 'workspace.require-path'
@@ -723,7 +723,7 @@ local function checkKeyWord(state, start, position, word, hasSpace, afterLocal,
723723
local text = state.lua
724724
local snipType = config.get(state.uri, 'Lua.completion.keywordSnippet')
725725
local symbol = lookBackward.findSymbol(text, guide.positionToOffset(state, start))
726-
local isExp = symbol == '(' or symbol == ',' or symbol == '='
726+
local isExp = symbol == '(' or symbol == ',' or symbol == '=' or symbol == '['
727727
local info = {
728728
hasSpace = hasSpace,
729729
isExp = isExp,
@@ -1473,7 +1473,6 @@ local function checkTableLiteralField(state, position, tbl, fields, results)
14731473
results[#results+1] = {
14741474
label = guide.getKeyName(field),
14751475
kind = define.CompletionItemKind.Property,
1476-
insertText = ('%s = $0'):format(guide.getKeyName(field)),
14771476
id = stack(function () ---@async
14781477
return {
14791478
detail = buildDetail(field),

script/core/look-backward.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function m.findSymbol(text, offset)
5454
or char == ':'
5555
or char == '('
5656
or char == ','
57+
or char == '['
5758
or char == '=' then
5859
return char, i
5960
else

test/completion/common.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,3 +3079,12 @@ TEST [[
30793079
if<??>
30803080
]]
30813081
(EXISTS)
3082+
3083+
TEST [[
3084+
local t = x[<??>]
3085+
]]
3086+
(function (results)
3087+
for _, res in ipairs(results) do
3088+
assert(res.label ~= 'do')
3089+
end
3090+
end)

0 commit comments

Comments
 (0)