aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/diagnostic.lua
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2024-11-25 11:48:11 -0600
committerGitHub <noreply@github.com>2024-11-25 11:48:11 -0600
commit29c72cdf4a4913c152f037865cb28c78a8930340 (patch)
treef55d404286962095163e701c5942beb3d7496628 /runtime/lua/vim/lsp/diagnostic.lua
parent8d55cc218cfed54136677398ca76c45987b15f29 (diff)
downloadrneovim-29c72cdf4a4913c152f037865cb28c78a8930340.tar.gz
rneovim-29c72cdf4a4913c152f037865cb28c78a8930340.tar.bz2
rneovim-29c72cdf4a4913c152f037865cb28c78a8930340.zip
fix(lsp): retrigger diagnostics request on server cancellation (#31345)
Co-authored-by: Jesse <github@jessebakker.com>
Diffstat (limited to 'runtime/lua/vim/lsp/diagnostic.lua')
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 12984f8c26..3f135d84f3 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -246,10 +246,18 @@ end
---
--- See |vim.diagnostic.config()| for configuration options.
---
----@param _ lsp.ResponseError?
+---@param error lsp.ResponseError?
---@param result lsp.DocumentDiagnosticReport
---@param ctx lsp.HandlerContext
-function M.on_diagnostic(_, result, ctx)
+function M.on_diagnostic(error, result, ctx)
+ if error ~= nil and error.code == protocol.ErrorCodes.ServerCancelled then
+ if error.data == nil or error.data.retriggerRequest ~= false then
+ local client = assert(vim.lsp.get_client_by_id(ctx.client_id))
+ client:request(ctx.method, ctx.params)
+ end
+ return
+ end
+
if result == nil or result.kind == 'unchanged' then
return
end