mirror of
https://github.com/neovim/neovim.git
synced 2026-07-26 18:52:08 +00:00
refactor(lsp): convert diagnostics to capability framework #40433
Problem: Diagnostic tracking used a separate bufstates table and manual LspDetach/LspNotify autocmd management via _enable()/_refresh(), duplicating the lifecycle logic already provided by the Capability framework. This caused inconsistencies in how client attach/detach and buffer teardown were handled compared to other LSP features. Solution: Replace the ad-hoc bufstate tracking and _enable/_refresh pattern in vim.lsp.diagnostic with a proper Diagnostics subclass of Capability. This cleans up a few random places in the main lsp module and client module that were poking the diagnostics. It also fixes some pre-existing bugs and inconsistencies that were discovered: - Refresh diagnostics immediately on attach instead of lazily by the first didOpen/didChange notification - Fix Capability.active lookup in M.enable() to key by it_bufnr instead of the filter bufnr - Set lsp defaults before calling the _text_document_did_open_handler in Client:on_attach() so defaults are there before any lsp notification occurs - Log (and return early) on any error from a diagnostic request result instead of only returning early for server cancelled errors
This commit is contained in:
@@ -871,9 +871,6 @@ function lsp._set_defaults(client, bufnr)
|
||||
end, { buf = bufnr, desc = 'vim.lsp.buf.hover()' })
|
||||
end
|
||||
end)
|
||||
if client:supports_method('textDocument/diagnostic') then
|
||||
lsp.diagnostic._enable(bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
--- @deprecated
|
||||
|
||||
Reference in New Issue
Block a user