mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 10:31:48 +00:00
feat(diagnostic): pass diagnostics as data to DiagnosticChanged autocmd (#20173)
This commit is contained in:
@@ -295,10 +295,18 @@ option in the "signs" table of |vim.diagnostic.config()| or 10 if unset).
|
||||
EVENTS *diagnostic-events*
|
||||
|
||||
*DiagnosticChanged*
|
||||
DiagnosticChanged After diagnostics have changed.
|
||||
DiagnosticChanged After diagnostics have changed. When used from Lua,
|
||||
the new diagnostics are passed to the autocmcd
|
||||
callback in the "data" table.
|
||||
|
||||
Example: >
|
||||
autocmd DiagnosticChanged * lua vim.diagnostic.setqflist({ open = false })
|
||||
|
||||
vim.api.nvim_create_autocmd('DiagnosticChanged', {
|
||||
callback = function(args)
|
||||
local diagnostics = args.data.diagnostics
|
||||
vim.pretty_print(diagnostics)
|
||||
end,
|
||||
})
|
||||
<
|
||||
==============================================================================
|
||||
Lua module: vim.diagnostic *diagnostic-api*
|
||||
|
||||
@@ -727,6 +727,7 @@ function M.set(namespace, bufnr, diagnostics, opts)
|
||||
vim.api.nvim_exec_autocmds('DiagnosticChanged', {
|
||||
modeline = false,
|
||||
buffer = bufnr,
|
||||
data = { diagnostics = diagnostics },
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user