mirror of
https://github.com/neovim/neovim.git
synced 2026-03-30 20:32:08 +00:00
fix(lsp): improve diagnostics handling and comments
- Add TODO comments for aggregating diagnostics from all pull namespaces and for clearing diagnostics when an empty array is received, referencing the LSP specification. - Update diagnostics refresh logic to safely access previousResultId, preventing potential nil errors.
This commit is contained in:
@@ -1365,6 +1365,7 @@ function M.code_action(opts)
|
||||
params.context = context
|
||||
else
|
||||
local ns_push = lsp.diagnostic.get_namespace(client.id, false)
|
||||
-- TODO(tris203): should we aggregate diagnostics from all the possible pull namespaces?
|
||||
local ns_pull = lsp.diagnostic.get_namespace(client.id, true)
|
||||
local diagnostics = {}
|
||||
local lnum = api.nvim_win_get_cursor(0)[1] - 1
|
||||
|
||||
@@ -261,6 +261,8 @@ end
|
||||
---@param params lsp.PublishDiagnosticsParams
|
||||
---@param ctx lsp.HandlerContext
|
||||
function M.on_publish_diagnostics(_, params, ctx)
|
||||
-- TODO(tris203): if empty array then clear diags
|
||||
-- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics
|
||||
handle_diagnostics(params.uri, ctx.client_id, params.diagnostics, false)
|
||||
end
|
||||
|
||||
@@ -396,7 +398,9 @@ function M._refresh(bufnr, client_id, only_visible)
|
||||
local params = {
|
||||
identifier = cap.identifier,
|
||||
textDocument = util.make_text_document_params(bufnr),
|
||||
previousResultId = bufstate.client_result_id[key],
|
||||
previousResultId = bufstate
|
||||
and bufstate.client_result_id
|
||||
and bufstate.client_result_id[key],
|
||||
}
|
||||
client:request(method, params, nil, bufnr)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user