Skip to content

Commit 89112df

Browse files
committed
fix: get diagnostics icons from config (#1826)
1 parent f0e9951 commit 89112df

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

lua/nvim-tree.lua

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ local function manage_netrw(disable_netrw, hijack_netrw)
131131
end
132132
end
133133

134+
---@param severity vim.diagnostic.Severity
135+
---@return string?
136+
local function get_diagnostics_icons(severity)
137+
local config = vim.diagnostic.config() or {}
138+
local signs = config.signs or {}
139+
if type(signs) == "function" then
140+
signs = signs(0, 0)
141+
end
142+
return (type(signs) == "table" and signs.text and signs.text[severity]) or nil
143+
end
144+
134145
---@param name string|nil
135146
function M.change_dir(name)
136147
if name then
@@ -303,7 +314,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
303314
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
304315
hidden_display = "none",
305316
symlink_destination = true,
306-
decorators = { "Git", "Open", "Hidden", "Modified", "Bookmark", "Diagnostics", "Copied", "Cut", },
317+
decorators = { "Git", "Open", "Hidden", "Modified", "Bookmark", "Diagnostics", "Copied", "Cut" },
307318
highlight_git = "none",
308319
highlight_diagnostics = "none",
309320
highlight_opened_files = "none",
@@ -415,10 +426,10 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
415426
max = vim.diagnostic.severity.ERROR,
416427
},
417428
icons = {
418-
hint = "",
419-
info = "",
420-
warning = "",
421-
error = "",
429+
hint = get_diagnostics_icons(vim.diagnostic.severity.HINT) or "",
430+
info = get_diagnostics_icons(vim.diagnostic.severity.INFO) or "",
431+
warning = get_diagnostics_icons(vim.diagnostic.severity.WARN) or "",
432+
error = get_diagnostics_icons(vim.diagnostic.severity.ERROR) or "",
422433
},
423434
},
424435
modified = {
@@ -513,8 +524,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
513524
default_yes = false,
514525
},
515526
},
516-
experimental = {
517-
},
527+
experimental = {},
518528
log = {
519529
enable = false,
520530
truncate = false,

0 commit comments

Comments
 (0)