summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-04 19:35:28 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-04 19:35:28 +0800
commit87834511ff48f68a1e972c8e8ec78c8d2dcf71e7 (patch)
tree3e8c29923720a2a23b4da59e146e29f11bff3118 /script/provider
parenta694873f15841e7138228b92f1fb28d8f4756900 (diff)
downloadlua-language-server-87834511ff48f68a1e972c8e8ec78c8d2dcf71e7.zip
update
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/capability.lua1
-rw-r--r--script/provider/diagnostic.lua9
-rw-r--r--script/provider/provider.lua33
3 files changed, 30 insertions, 13 deletions
diff --git a/script/provider/capability.lua b/script/provider/capability.lua
index b712defc..8d75d7fe 100644
--- a/script/provider/capability.lua
+++ b/script/provider/capability.lua
@@ -81,6 +81,7 @@ function m.getIniter()
},
executeCommandProvider = {
commands = {
+ -- TODO: 不再需要 get_id
'lua.removeSpace:' .. sp:get_id(),
'lua.solve:' .. sp:get_id(),
'lua.jsonToLua:' .. sp:get_id(),
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index a9132e70..34ac1e17 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -283,7 +283,7 @@ function m.refresh(uri)
end
---@async
-local function askForDisable()
+local function askForDisable(uri)
if m.dontAskedForDisable then
return
end
@@ -315,6 +315,7 @@ local function askForDisable()
key = 'Lua.diagnostics.workspaceDelay',
action = 'set',
value = delay * 1000,
+ uri = uri,
}
}
elseif item.title == lang.script.WINDOW_DISABLE_DIAGNOSTIC then
@@ -323,6 +324,7 @@ local function askForDisable()
key = 'Lua.diagnostics.workspaceDelay',
action = 'set',
value = -1,
+ uri = uri,
}
}
end
@@ -351,7 +353,10 @@ function m.diagnosticsScope(uri, force)
bar:onCancel(function ()
log.debug('Cancel workspace diagnostics')
cancelled = true
- await.call(askForDisable)
+ ---@async
+ await.call(function ()
+ askForDisable(uri)
+ end)
end)
local uris = files.getAllUris()
for i, uri in ipairs(uris) do
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index baf7e705..77c45778 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -19,13 +19,13 @@ local json = require 'json'
local scope = require 'workspace.scope'
---@async
-local function updateConfig()
- local specified = cfgLoader.loadLocalConfig(CONFIGPATH)
+local function updateConfig(uri)
+ local specified = cfgLoader.loadLocalConfig(uri, CONFIGPATH)
if specified then
log.debug('Load config from specified', CONFIGPATH)
log.debug(util.dump(specified))
-- watch directory
- filewatch.watch(workspace.getAbsolutePath(CONFIGPATH):gsub('[^/\\]+$', ''))
+ filewatch.watch(workspace.getAbsolutePath(uri, CONFIGPATH):gsub('[^/\\]+$', ''))
config.update(scope.override, specified, json.null)
end
@@ -66,13 +66,22 @@ function m.register(method)
end
filewatch.event(function (changes) ---@async
- local configPath = CONFIGPATH and workspace.getAbsolutePath(CONFIGPATH)
- local rcPath = workspace.getAbsolutePath('.luarc.json')
for _, change in ipairs(changes) do
- if change.path == configPath
- or change.path == rcPath then
- updateConfig()
- return
+ if (CONFIGPATH and util.stringEndWith(change.path, CONFIGPATH)) then
+ for _, scp in ipairs(workspace.folders) do
+ local configPath = workspace.getAbsolutePath(scp.uri, CONFIGPATH)
+ if change.path == configPath then
+ updateConfig(scp.uri)
+ end
+ end
+ end
+ if util.stringEndWith(change.path, '.luarc.json') then
+ for _, scp in ipairs(workspace.folders) do
+ local rcPath = workspace.getAbsolutePath(scp.uri, '.luarc.json')
+ if change.path == rcPath then
+ updateConfig(scp.uri)
+ end
+ end
end
end
end)
@@ -903,7 +912,9 @@ m.register '$/status/click' {
end
if result == titleDiagnostic then
local diagnostic = require 'provider.diagnostic'
- diagnostic.diagnosticsAll(true)
+ for _, scp in ipairs(workspace.folders) do
+ diagnostic.diagnosticsScope(scp.uri, true)
+ end
end
end
}
@@ -1043,7 +1054,7 @@ end)
m.register '$/status/refresh' { refreshStatusBar }
files.watch(function (ev, uri)
- if not workspace.isReady() then
+ if not workspace.isReady(uri) then
return
end
if ev == 'update'