aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2022-09-13 08:33:39 -0600
committerGitHub <noreply@github.com>2022-09-13 08:33:39 -0600
commit1970d2ac43059639e4e2c83223d86397b38786ff (patch)
tree169a18d24903e19e64cc3114bbc6b5620bfb9763 /runtime
parentf19e91acd8b90eaddaaa6070db260acf8de9aa10 (diff)
downloadrneovim-1970d2ac43059639e4e2c83223d86397b38786ff.tar.gz
rneovim-1970d2ac43059639e4e2c83223d86397b38786ff.tar.bz2
rneovim-1970d2ac43059639e4e2c83223d86397b38786ff.zip
feat(diagnostic): pass diagnostics as data to DiagnosticChanged autocmd (#20173)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/diagnostic.txt12
-rw-r--r--runtime/lua/vim/diagnostic.lua1
2 files changed, 11 insertions, 2 deletions
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
index e1b52746be..78254c6f2b 100644
--- a/runtime/doc/diagnostic.txt
+++ b/runtime/doc/diagnostic.txt
@@ -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*
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 4f7d8cccd5..172bd867c7 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -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