diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-04 16:55:03 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-04 16:55:03 +0800 |
commit | a694873f15841e7138228b92f1fb28d8f4756900 (patch) | |
tree | d6800b63bfefb00850f328bc2fd2206e40712480 /script/provider | |
parent | 8d4cdc453a89077d7f5ed7ec96f1dacce4bc4f4d (diff) | |
download | lua-language-server-a694873f15841e7138228b92f1fb28d8f4756900.zip |
fix diagnostic
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/diagnostic.lua | 37 | ||||
-rw-r--r-- | script/provider/init.lua | 1 |
2 files changed, 12 insertions, 26 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 0b607bd4..a9132e70 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -13,7 +13,6 @@ local converter = require 'proto.converter' ---@class diagnosticProvider local m = {} -m._start = false m.cache = {} m.sleepRest = 0.0 m.coroutineUri = setmetatable({}, { __mode = 'k' }) @@ -170,11 +169,7 @@ function m.syntaxErrors(uri, ast) end function m.diagnostics(uri, diags) - if not m._start then - return - end - - if not ws.isReady() then + if not ws.isReady(uri) then return end @@ -272,7 +267,7 @@ function m.doDiagnostic(uri) end function m.refresh(uri) - if not m._start then + if not ws.isReady(uri) then return end await.close('diag:' .. uri) @@ -333,18 +328,12 @@ local function askForDisable() end end -function m.diagnosticsAll(force) - for _, scp in ipairs(ws.folders) do - m.diagnosticsScope(scp.uri, force) - end -end - function m.diagnosticsScope(uri, force) - if not force and not config.get(uri, 'Lua.diagnostics.enable') then - m.clearAll() + if not ws.isReady(uri) then return end - if not m._start then + if not force and not config.get(uri, 'Lua.diagnostics.enable') then + m.clearAll() return end local delay = config.get(uri, 'Lua.diagnostics.workspaceDelay') / 1000 @@ -380,16 +369,6 @@ function m.diagnosticsScope(uri, force) end, 'files.version', 'diagnosticsScope') end -function m.start() - m._start = true - m.diagnosticsAll() -end - -function m.pause() - m._start = false - await.close 'diagnosticsScope' -end - function m.checkStepResult(uri) if await.hasID 'diagnosticsScope' then return @@ -427,6 +406,12 @@ function m.checkWorkspaceDiag(uri) return false end +ws.watch(function (ev, uri) + if ev == 'reload' then + m.diagnosticsScope(uri) + end +end) + files.watch(function (ev, uri) ---@async if ev == 'remove' then m.clear(uri) diff --git a/script/provider/init.lua b/script/provider/init.lua index a69fbab3..dfba351a 100644 --- a/script/provider/init.lua +++ b/script/provider/init.lua @@ -1 +1,2 @@ +require 'provider.diagnostic' return require 'provider.provider' |