summaryrefslogtreecommitdiff
path: root/server/src/core/completion.lua
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-05-30 10:27:14 +0800
committersumneko <sumneko@hotmail.com>2019-05-30 10:27:14 +0800
commit050dcbe14a6e2d6ca267193119b016d1432d121b (patch)
tree507c51d511c32465e267bf1e7313e40a57582d03 /server/src/core/completion.lua
parent4005de553a6108cf4eddc45b4c5792154b6209c7 (diff)
downloadlua-language-server-050dcbe14a6e2d6ca267193119b016d1432d121b.zip
去掉对toclose的特殊支持
Diffstat (limited to 'server/src/core/completion.lua')
-rw-r--r--server/src/core/completion.lua39
1 files changed, 6 insertions, 33 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 331eb6cc..a938d83c 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -373,19 +373,16 @@ end
local function searchAsLocal(vm, source, word, callback)
local loc = source:bindLocal()
- if loc then
- local close = loc:close()
- -- 因为闭包的关系落在局部变量finish到close范围内的全局变量一定能访问到该局部变量
- searchCloseGlobal(vm, source.finish, close, word, callback)
+ if not loc then
+ return
end
+ local close = loc:close()
+ -- 因为闭包的关系落在局部变量finish到close范围内的全局变量一定能访问到该局部变量
+ searchCloseGlobal(vm, source.finish, close, word, callback)
-- 特殊支持 local function
if matchKey(word, 'function') then
callback('function', nil, CompletionItemKind.Keyword)
end
- -- 特殊支持 local *toclose
- if word == '' and config.config.runtime.version == 'Lua 5.4' then
- callback('*toclose', nil, CompletionItemKind.Keyword)
- end
end
local function searchAsArg(vm, source, word, callback)
@@ -846,27 +843,6 @@ local function makeList(source, pos, word)
end, list
end
-local function searchToclose(text, source, word, callback)
- local pos = source.start
- if text:sub(pos-1, pos-1) ~= '*' then
- return false
- end
- if not matchKey(word, 'toclose') then
- return false
- end
- for i = pos-1, 1, -1 do
- if text:sub(i, i):match '[^%s%c]' then
- if text:sub(i - #'local' + 1, i) == 'local' then
- callback('toclose', nil, CompletionItemKind.Keyword)
- return true
- else
- return false
- end
- end
- end
- return false
-end
-
local function keywordSource(vm, word, pos)
if not KEYMAP[word] then
return nil
@@ -933,7 +909,7 @@ local function getSource(vm, pos, text, filter)
return source, pos, word
end
pos = findStartPos(pos, text)
- source = findSource(vm, pos, filter)
+ source = findSource(vm, pos, filter) or findSource(vm, pos-1, filter)
return source, pos, word
end
@@ -961,9 +937,6 @@ return function (vm, text, pos, oldText)
end
State = {}
local callback, list = makeList(source, pos, word)
- if searchToclose(text, source, word, callback) then
- return list
- end
searchSpecial(vm, source, word, callback, pos, text)
searchCallArg(vm, source, word, callback, pos)
searchSource(vm, source, word, callback, pos)