---@class Biscuit.Actions
local M = {}
local loader = require('biscuit.loader')
local function get_config()
return require('biscuit').config
end
---Check if diagnostic code matches any configured code
---@param diag_code string|number|nil
---@param codes string[]
---@return boolean
local function code_matches(diag_code, codes)
if diag_code == nil then
return false
end
local code_str = tostring(diag_code)
for _, c in ipairs(codes) do
if code_str == c then
return true
end
end
return false
end
---Get matching diagnostics grouped by buffer
---@param codes string[]
---@return table<integer, table[]> by_buffer
local function get_diagnostics_by_buffer(codes)
local by_buffer = {}
for _, diag in ipairs(vim.diagnostic.get()) do
if code_matches(diag.code, codes) then
if not by_buffer[diag.bufnr] then
by_buffer[diag.bufnr] = {}
end
table.insert(by_buffer[diag.bufnr], diag)
end
end
return by_buffer