aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorMayrom <32033791+nhruo123@users.noreply.github.com>2024-03-27 02:08:54 +0200
committerGitHub <noreply@github.com>2024-03-26 19:08:54 -0500
commitfc6d713dd8066f3132f7234a94ac059ae6d596a7 (patch)
tree25c60071862320fb8b0b0a600ee812ed0035cf11 /runtime/lua/vim
parent77458e613b67b9e7607ae781bcfbdc2ff6b1b2ef (diff)
downloadrneovim-fc6d713dd8066f3132f7234a94ac059ae6d596a7.tar.gz
rneovim-fc6d713dd8066f3132f7234a94ac059ae6d596a7.tar.bz2
rneovim-fc6d713dd8066f3132f7234a94ac059ae6d596a7.zip
feat(diagnostic): add support for many namespaces filtering in GetOpts (#28045)
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/diagnostic.lua21
1 files changed, 16 insertions, 5 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index d5075d7d3d..57491d155d 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -682,6 +682,13 @@ local function get_diagnostics(bufnr, opts, clamp)
opts = opts or {}
local namespace = opts.namespace
+
+ if type(namespace) == 'number' then
+ namespace = { namespace }
+ end
+
+ ---@cast namespace integer[]
+
local diagnostics = {}
-- Memoized results of buf_line_count per bufnr
@@ -742,11 +749,15 @@ local function get_diagnostics(bufnr, opts, clamp)
end
elseif bufnr == nil then
for b, t in pairs(diagnostic_cache) do
- add_all_diags(b, t[namespace] or {})
+ for _, iter_namespace in ipairs(namespace) do
+ add_all_diags(b, t[iter_namespace] or {})
+ end
end
else
bufnr = get_bufnr(bufnr)
- add_all_diags(bufnr, diagnostic_cache[bufnr][namespace] or {})
+ for _, iter_namespace in ipairs(namespace) do
+ add_all_diags(bufnr, diagnostic_cache[bufnr][iter_namespace] or {})
+ end
end
if opts.severity then
@@ -785,7 +796,7 @@ end
--- @param search_forward boolean
--- @param bufnr integer
--- @param opts vim.diagnostic.GotoOpts
---- @param namespace integer
+--- @param namespace integer[]|integer
--- @return vim.Diagnostic?
local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
position[1] = position[1] - 1
@@ -1115,8 +1126,8 @@ end
--- A table with the following keys:
--- @class vim.diagnostic.GetOpts
---
---- Limit diagnostics to the given namespace.
---- @field namespace? integer
+--- Limit diagnostics to one or more namespaces.
+--- @field namespace? integer[]|integer
---
--- Limit diagnostics to the given line number.
--- @field lnum? integer