mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
LSP: Expose diagnostics grouped by bufnr (#11932)
Expose `vim.lsp.buf.diagnostics_by_buf` This makes it easier to customize the diagnostics behavior. For example to defer the update they can override the `textDocument/publishDiagnostics` callback to only call `buf_diagnostics_save_positions` and then defer the other actions to a autocmd event.
This commit is contained in:
committed by
GitHub
parent
78d58eaf61
commit
ef0398fe88
@@ -845,4 +845,20 @@ describe('LSP', function()
|
||||
eq({}, exec_lua([[return vim.lsp.util.text_document_completion_list_to_complete_items(...)]], {}, prefix))
|
||||
end)
|
||||
end)
|
||||
describe('buf_diagnostics_save_positions', function()
|
||||
it('stores the diagnostics in diagnostics_by_buf', function ()
|
||||
local diagnostics = {
|
||||
{ range = {}; message = "diag1" },
|
||||
{ range = {}; message = "diag2" },
|
||||
}
|
||||
exec_lua([[
|
||||
vim.lsp.util.buf_diagnostics_save_positions(...)]], 0, diagnostics)
|
||||
eq(1, exec_lua [[ return #vim.lsp.util.diagnostics_by_buf ]])
|
||||
eq(diagnostics, exec_lua [[
|
||||
for _, diagnostics in pairs(vim.lsp.util.diagnostics_by_buf) do
|
||||
return diagnostics
|
||||
end
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user