Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(diagnostic): prefer the signs from vim.diagnostic.config() #3146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions lua/telescope/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1140,19 +1140,31 @@ end
function make_entry.gen_from_diagnostics(opts)
opts = opts or {}

local diagnostic_config = vim.diagnostic.config()
local diagnostic_signs = {}
if type(diagnostic_config.signs) == "table" then
diagnostic_signs = diagnostic_config.signs.text or {}
end

local type_diagnostic = vim.diagnostic.severity
local signs = (function()
if opts.no_sign then
return
end
local signs = {}
for _, severity in ipairs(type_diagnostic) do
local status, sign = pcall(function()
-- only the first char is upper all others are lowercalse
return vim.trim(vim.fn.sign_getdefined("DiagnosticSign" .. severity:lower():gsub("^%l", string.upper))[1].text)
end)
if not status then
sign = severity:sub(1, 1)
local sign = diagnostic_signs[severity]
if not sign then
local status
status, sign = pcall(function()
-- only the first char is upper all others are lowercalse
return vim.trim(
vim.fn.sign_getdefined("DiagnosticSign" .. severity:lower():gsub("^%l", string.upper))[1].text
)
end)
if not status then
sign = severity:sub(1, 1)
end
end
signs[severity] = sign
end
Expand Down