diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/completion.lua | 27 | ||||
-rw-r--r-- | server/src/matcher/vm.lua | 2 | ||||
-rw-r--r-- | server/src/method/initialize.lua | 2 |
3 files changed, 30 insertions, 1 deletions
diff --git a/server/src/matcher/completion.lua b/server/src/matcher/completion.lua index 1b07e5fb..f846bad3 100644 --- a/server/src/matcher/completion.lua +++ b/server/src/matcher/completion.lua @@ -441,6 +441,30 @@ local function searchInResult(result, source, vm, pos, callback) end end +local function searchSpecial(vm, pos, callback) + -- 尝试 # + local result, source = findResult(vm, pos, 2) + if source and source.op == '#' and source.index then + local name = {} + local var = result + while true do + var = var.parent + if not var then + break + end + if var.value and var.value.ENV then + break + end + local key = var.key + if type(key) ~= 'string' or key == '' then + return + end + table.insert(name, 1, key) + end + callback(table.concat(name, '.') .. '+1', CompletionItemKind.Snippet) + end +end + return function (vm, pos) local result, source = findResult(vm, pos) if not result then @@ -460,6 +484,9 @@ return function (vm, pos) if not inString then searchInResult(result, source, vm, pos, callback) end + if #list == 0 and result.key == '' then + searchSpecial(vm, pos, callback) + end if #list == 0 then return nil end diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index dfa0d0d9..3d3fc4e5 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -1005,6 +1005,8 @@ function mt:getSimple(simple, mode) self:addInfo(field, 'get', obj) end end + field.parent = lastField + lastField = field obj.object = object obj.parentName = parentName if obj.type == 'string' then diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua index 9ba890bc..aa4a5edc 100644 --- a/server/src/method/initialize.lua +++ b/server/src/method/initialize.lua @@ -1,5 +1,5 @@ local function allWords() - local str = [[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:('"[, ]] + local str = [[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:('"[,# ]] local list = {} for c in str:gmatch '.' do list[#list+1] = c |