diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-10-17 20:20:18 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-10-17 20:20:18 +0800 |
commit | 4e647a342a525eda45418398f1409c8e5a57adff (patch) | |
tree | 5d0ccd3849e2f545b02c5c6f50c4be2d539cb36e /script/provider/diagnostic.lua | |
parent | 279c1ad7b88e464535971143660712fb0ea259ca (diff) | |
download | lua-language-server-4e647a342a525eda45418398f1409c8e5a57adff.zip |
new setting `Lua.diagnostics.workspaceEvent`
set the time to trigger workspace diagnostics.
resolve #1626
Diffstat (limited to 'script/provider/diagnostic.lua')
-rw-r--r-- | script/provider/diagnostic.lua | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 583173f0..0fac3e17 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -391,23 +391,22 @@ function m.pullDiagnostic(uri, isScopeDiag) return full end +---@param event string ---@param uri uri -function m.refresh(uri) +function m.refreshScopeDiag(event, uri) if not ws.isReady(uri) then return end - - await.close('diag:' .. uri) - ---@async - await.call(function () - await.setID('diag:' .. uri) - await.sleep(0.1) - xpcall(m.doDiagnostic, log.error, uri) - end) - local scp = scope.getScope(uri) local scopeID = 'diagnosticsScope:' .. scp:getName() await.close(scopeID) + + local eventConfig = config.get(uri, 'Lua.diagnostics.workspaceEvent') + + if eventConfig ~= event then + return + end + ---@async await.call(function () local delay = config.get(uri, 'Lua.diagnostics.workspaceDelay') / 1000 @@ -419,6 +418,21 @@ function m.refresh(uri) end) end +---@param uri uri +function m.refresh(uri) + if not ws.isReady(uri) then + return + end + + await.close('diag:' .. uri) + ---@async + await.call(function () + await.setID('diag:' .. uri) + await.sleep(0.1) + xpcall(m.doDiagnostic, log.error, uri) + end) +end + ---@async local function askForDisable(uri) if m.dontAskedForDisable then @@ -613,6 +627,7 @@ files.watch(function (ev, uri) ---@async m.refresh(uri) elseif ev == 'update' then m.refresh(uri) + m.refreshScopeDiag('OnChange', uri) elseif ev == 'open' then if ws.isReady(uri) then m.resendDiagnostic(uri) @@ -623,6 +638,8 @@ files.watch(function (ev, uri) ---@async or ws.isIgnored(uri) then m.clear(uri) end + elseif ev == 'save' then + m.refreshScopeDiag('OnSave', uri) end end) |