Skip to content

Commit

Permalink
fix: maintain backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed May 19, 2024
1 parent 9ae49d7 commit 6ffe93d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/bufferline/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,21 @@ local function is_insert() -- insert or replace
return mode == "i" or mode == "ic" or mode == "ix" or mode == "R" or mode == "Rc" or mode == "Rx"
end

local function diagnostic_is_enabled(d)
if vim.fn.has("nvim-0.10") == 1 then
return vim.diagnostic.is_enabled({ ns_id = d.namespace, bufnr = d.bufnr })
else
-- neovim 0.9.x
return not vim.diagnostic.is_disabled(d.bufnr, d.namespace)
end
end

local get_diagnostics = {
nvim_lsp = function()
local results = {}
local diagnostics = vim.diagnostic.get()
for _, d in pairs(diagnostics) do
if vim.diagnostic.is_enabled({ ns_id = d.namespace, bufnr = d.bufnr }) then
if diagnostic_is_enabled(d) then
if not results[d.bufnr] then results[d.bufnr] = {} end
table.insert(results[d.bufnr], d)
end
Expand Down

0 comments on commit 6ffe93d

Please sign in to comment.