diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/matcher/completion.lua | 22 | ||||
-rw-r--r-- | server/src/method/initialize.lua | 2 |
2 files changed, 14 insertions, 10 deletions
diff --git a/server/src/matcher/completion.lua b/server/src/matcher/completion.lua index 29a86d10..9e9d7919 100644 --- a/server/src/matcher/completion.lua +++ b/server/src/matcher/completion.lua @@ -217,6 +217,9 @@ local function searchAsArg(vm, pos, result, callback) end local function searchAsGlobal(vm, pos, result, callback) + if result.key == '' then + return + end searchLocals(vm, pos, result.key, function (var) callback(var, CompletionItemKind.Variable) end) @@ -258,10 +261,15 @@ local function searchInArg(vm, inCall, inString, callback) -- 其他库函数,根据参数位置找枚举值 if lib.args and lib.enums then - local name = lib.args[inCall.select].name + local arg = lib.args[inCall.select] + local name = arg and arg.name for _, enum in ipairs(lib.enums) do if enum.name == name and enum.enum then - callback(enum.enum, CompletionItemKind.EnumMember, nil, enum.description) + if inString then + callback(enum.enum, CompletionItemKind.EnumMember, nil, enum.description) + else + callback(('%q'):format(enum.enum), CompletionItemKind.EnumMember, nil, enum.description) + end end end end @@ -347,10 +355,10 @@ end local function findArgCount(args, pos) for i, arg in ipairs(args) do if isContainPos(arg, pos) then - return i, arg + return i end end - return #args + 1, nil + return #args + 1 end -- 找出范围包含pos的call @@ -358,10 +366,7 @@ local function findCall(vm, pos) local results = {} for _, call in ipairs(vm.results.calls) do if isContainPos(call.args, pos) then - local n, arg = findArgCount(call.args, pos) - if arg and arg.type ~= 'string' then - return nil - end + local n = findArgCount(call.args, pos) local var = vm.results.sources[call.lastObj] if var then results[#results+1] = { @@ -387,7 +392,6 @@ end return function (vm, pos) local result, source = findResult(vm, pos) if not result then - isClose = true result, source = findClosePos(vm, pos) if not result then return nil diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua index 0f5b840a..9ba890bc 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 |