summaryrefslogtreecommitdiff
path: root/script/provider/completion.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-30 19:46:03 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-30 19:46:03 +0800
commit76af92ca93ff4c9bf4b6fc62bbc49481a17ea044 (patch)
treeddd3f3ba07551c9b6ce5be4b74618bd47983c7db /script/provider/completion.lua
parentb1c20a1f24cc7e17d446b2ac4e4118c36173dc20 (diff)
downloadlua-language-server-76af92ca93ff4c9bf4b6fc62bbc49481a17ea044.zip
update
Diffstat (limited to 'script/provider/completion.lua')
-rw-r--r--script/provider/completion.lua25
1 files changed, 14 insertions, 11 deletions
diff --git a/script/provider/completion.lua b/script/provider/completion.lua
index 6c215f15..ec2ac6c7 100644
--- a/script/provider/completion.lua
+++ b/script/provider/completion.lua
@@ -2,6 +2,7 @@ local proto = require 'proto'
local nonil = require 'without-check-nil'
local client = require 'client'
local config = require 'config'
+local ws = require 'workspace'
local isEnable = false
@@ -13,15 +14,17 @@ local function allWords()
list[#list+1] = c
mark[c] = true
end
- local postfix = config.get(uri, 'Lua.completion.postfix')
- if postfix ~= '' and not mark[postfix] then
- list[#list+1] = postfix
- mark[postfix] = true
+ for _, scp in ipairs(ws.folders) do
+ local postfix = config.get(scp.uri, 'Lua.completion.postfix')
+ if postfix ~= '' and not mark[postfix] then
+ list[#list+1] = postfix
+ mark[postfix] = true
+ end
end
return list
end
-local function enable()
+local function enable(uri)
if isEnable then
return
end
@@ -46,7 +49,7 @@ local function enable()
})
end
-local function disable()
+local function disable(uri)
if not isEnable then
return
end
@@ -67,18 +70,18 @@ local function disable()
})
end
-config.watch(function (key, value)
+config.watch(function (uri, key, value)
if key == 'Lua.completion.enable' then
if value == true then
- enable()
+ enable(uri)
else
- disable()
+ disable(uri)
end
end
if key == 'Lua.completion.postfix' then
if config.get(uri, 'Lua.completion.enable') then
- disable()
- enable()
+ disable(uri)
+ enable(uri)
end
end
end)