Skip to content

Commit

Permalink
feat(diagnostic): support 0.10 extmark diagnostic signs
Browse files Browse the repository at this point in the history
  • Loading branch information
ofseed authored and ibhagwan committed Mar 7, 2024
1 parent ed031af commit 68145f6
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lua/fzf-lua/providers/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,24 @@ M.diagnostics = function(opts)
opts.__signs[v.severity] = {}

-- from vim.diagnostic
local sign_def = vim.fn.sign_getdefined(v.name)
-- can be empty when config set to (#480):
-- vim.diagnostic.config({ signs = false })
if vim.tbl_isempty(sign_def) then sign_def = nil end
opts.__signs[v.severity].text =
(not opts.diag_icons or not sign_def or not sign_def[1].text)
and v.default or vim.trim(sign_def[1].text)
opts.__signs[v.severity].texthl = sign_def and sign_def[1].texthl or nil
if utils.__HAS_NVIM_010 then
local sign_confs = vim.diagnostic.config().signs
local level = vim.diagnostic.severity[k:upper()]
if vim.tbl_isempty(sign_confs) then sign_confs = nil end
opts.__signs[v.severity].text =
(not opts.diag_icons or not sign_confs or not sign_confs.text[level])
and v.default or vim.trim(sign_confs.text[level])
opts.__signs[v.severity].texthl = v.name
else
local sign_def = vim.fn.sign_getdefined(v.name)
-- can be empty when config set to (#480):
-- vim.diagnostic.config({ signs = false })
if vim.tbl_isempty(sign_def) then sign_def = nil end
opts.__signs[v.severity].text =
(not opts.diag_icons or not sign_def or not sign_def[1].text)
and v.default or vim.trim(sign_def[1].text)
opts.__signs[v.severity].texthl = sign_def and sign_def[1].texthl or nil
end

-- from user config
if opts.signs and opts.signs[k] and opts.signs[k].text then
Expand Down

0 comments on commit 68145f6

Please sign in to comment.