summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-03 19:13:01 +0800
committersumneko <sumneko@hotmail.com>2019-04-03 19:13:01 +0800
commit289a780f38c24a7ee0f4ca9502214b41fe11fc30 (patch)
tree394a8b94a072b6f567a6918150cb683d8ecaef96 /server
parentb1f9435c0bc21fb2d27677745e7726c9333b3c06 (diff)
downloadlua-language-server-289a780f38c24a7ee0f4ca9502214b41fe11fc30.zip
自动完成的 child 过滤关键字
Diffstat (limited to 'server')
-rw-r--r--server/src/core/completion.lua13
-rw-r--r--server/test/completion/init.lua11
-rw-r--r--server/test/diagnostics/init.lua2
3 files changed, 20 insertions, 6 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 2204c369..83f684f3 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -30,6 +30,12 @@ local CompletionItemKind = {
TypeParameter = 25,
}
+local KEYS = {'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'goto', 'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while', 'toclose'}
+local KEYMAP = {}
+for _, k in ipairs(KEYS) do
+ KEYMAP[k] = true
+end
+
local function matchKey(me, other)
if me == other then
return true
@@ -223,6 +229,9 @@ local function searchFields(vm, source, word, callback)
if map[k] then
return
end
+ if KEYMAP[k] then
+ return
+ end
if info.type ~= 'set child' and info.type ~= 'get child' then
return
end
@@ -244,6 +253,9 @@ local function searchFields(vm, source, word, callback)
if map[k] then
return
end
+ if KEYMAP[k] then
+ return
+ end
if not v:getLib() then
return
end
@@ -292,7 +304,6 @@ local function searchCloseGlobal(vm, source, word, callback)
end)
end
-local KEYS = {'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'goto', 'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while', 'toclose'}
local function searchKeyWords(vm, source, word, callback)
for _, key in ipairs(KEYS) do
if matchKey(word, key) then
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index b34d567d..2f965bcb 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -700,10 +700,6 @@ end
label = 'b',
kind = CompletionItemKind.Field,
},
- {
- label = 'end',
- kind = CompletionItemKind.Field,
- },
}
TEST [[
@@ -731,3 +727,10 @@ TEST [[
function table.i@
]]
(EXISTS)
+
+TEST [[
+do
+ xx.@
+end
+]]
+(nil)
diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua
index f1efca70..dc060ba4 100644
--- a/server/test/diagnostics/init.lua
+++ b/server/test/diagnostics/init.lua
@@ -245,4 +245,4 @@ ROOT = 1
TEST [[
local f = load('')
f(1, 2, 3)
-]] \ No newline at end of file
+]]