mirror of
https://github.com/neovim/neovim.git
synced 2026-08-30 02:51:48 +00:00
fix(lsp): retrigger diagnostics request on server cancellation (#31345)
Co-authored-by: Jesse <github@jessebakker.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -659,7 +659,8 @@ for k, fn in pairs(M) do
|
||||
})
|
||||
end
|
||||
|
||||
if err then
|
||||
-- ServerCancelled errors should be propagated to the request handler
|
||||
if err and err.code ~= protocol.ErrorCodes.ServerCancelled then
|
||||
-- LSP spec:
|
||||
-- interface ResponseError:
|
||||
-- code: integer;
|
||||
|
||||
@@ -174,6 +174,7 @@ local constants = {
|
||||
-- Defined by the protocol.
|
||||
RequestCancelled = -32800,
|
||||
ContentModified = -32801,
|
||||
ServerCancelled = -32802,
|
||||
},
|
||||
|
||||
-- Describes the content type that a client supports in various
|
||||
|
||||
Reference in New Issue
Block a user