Skip to content

Commit 5821ea7

Browse files
committed
feat(#1826): use diagnostics icons from vim.diagnostic
1 parent f0e9951 commit 5821ea7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lua/nvim-tree/renderer/decorator/diagnostics.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ local diagnostics = require("nvim-tree.diagnostics")
33
local Decorator = require("nvim-tree.renderer.decorator")
44
local DirectoryNode = require("nvim-tree.node.directory")
55

6+
---@param severity vim.diagnostic.Severity
7+
---@return string?
8+
local function get_diagnostics_icons(severity)
9+
local config = vim.diagnostic.config() or {}
10+
local signs = config.signs or {}
11+
if type(signs) == "function" then
12+
signs = signs(0, 0)
13+
end
14+
return (type(signs) == "table" and signs.text and signs.text[severity]) or nil
15+
end
16+
617
-- highlight groups by severity
718
local HG_ICON = {
819
[vim.diagnostic.severity.ERROR] = "NvimTreeDiagnosticErrorIcon",
@@ -51,7 +62,7 @@ function DiagnosticsDecorator:new(args)
5162
self.diag_icons = {}
5263
for name, sev in pairs(ICON_KEYS) do
5364
self.diag_icons[sev] = {
54-
str = self.explorer.opts.diagnostics.icons[name],
65+
str = get_diagnostics_icons(sev) or self.explorer.opts.diagnostics.icons[name],
5566
hl = { HG_ICON[sev] },
5667
}
5768
self:define_sign(self.diag_icons[sev])

0 commit comments

Comments
 (0)