diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-10-01 22:50:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 22:50:28 -0700 |
commit | 724ffe7095424e7acdbde8d0b12f357809561fdf (patch) | |
tree | 1ad47cb50b263005b8da04c510f32856690cdbda | |
parent | 36408146ad7b2f3dafa260b765e0b7afcdc7c0dc (diff) | |
download | rneovim-724ffe7095424e7acdbde8d0b12f357809561fdf.tar.gz rneovim-724ffe7095424e7acdbde8d0b12f357809561fdf.tar.bz2 rneovim-724ffe7095424e7acdbde8d0b12f357809561fdf.zip |
feat(diagnostics): add vim.diagnostic.get_namespaces (#15866)
Many vim.diagnostic functions expect the user to pass in a namespace id.
This PR allows the user to list active diagnostic namespaces:
```lua
:lua print(vim.inspect(vim.diagnostic.get_namespaces()))
{
[7] = {
name = "vim.lsp.client-1",
opts = {},
sign_group = "vim.diagnostic.vim.lsp.client-1"
}
}
```
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index c9119b4c42..35badf8a02 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -646,6 +646,13 @@ function M.set(namespace, bufnr, diagnostics, opts) vim.api.nvim_command("doautocmd <nomodeline> User DiagnosticsChanged") end +--- Get current diagnostic namespaces. +--- +---@return table A list of active diagnostic namespaces |vim.diagnostic|. +function M.get_namespaces() + return vim.deepcopy(all_namespaces) +end + --- Get current diagnostics. --- ---@param bufnr number|nil Buffer number to get diagnostics from. Use 0 for |