Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ Following is the default configuration. See |nvim-tree-opts| for details. >lua
warning = "",
error = "",
},
diagnostic_opts = false,
},
modified = {
enable = false,
Expand Down Expand Up @@ -1329,6 +1330,10 @@ Icons for diagnostic severity.
error = ""
}
<
*nvim-tree.diagnostics.diagnostic_opts*
|vim.diagnostic.Opts| overrides |nvim-tree.diagnostics.severity| and
|nvim-tree.diagnostics.icons|
Type: `boolean`, Default: `false`
==============================================================================
5.9 OPTS: MODIFIED *nvim-tree-opts-modified*

Expand Down Expand Up @@ -3175,6 +3180,7 @@ highlight group is not, hard linking as follows: >
|nvim-tree.actions.use_system_clipboard|
|nvim-tree.auto_reload_on_write|
|nvim-tree.diagnostics.debounce_delay|
|nvim-tree.diagnostics.diagnostic_opts|
|nvim-tree.diagnostics.enable|
|nvim-tree.diagnostics.icons|
|nvim-tree.diagnostics.severity|
Expand Down
1 change: 1 addition & 0 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
warning = "",
error = "",
},
diagnostic_opts = false,
},
modified = {
enable = false,
Expand Down
5 changes: 4 additions & 1 deletion lua/nvim-tree/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ end
function M.setup(opts)
M.enable = opts.diagnostics.enable
M.debounce_delay = opts.diagnostics.debounce_delay
M.severity = opts.diagnostics.severity
M.severity = opts.diagnostics.diagnostic_opts and {
min = vim.diagnostic.severity.HINT,
max = vim.diagnostic.severity.ERROR
} or opts.diagnostics.severity

if M.enable then
log.line("diagnostics", "setup")
Expand Down
22 changes: 17 additions & 5 deletions lua/nvim-tree/renderer/decorator/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,29 @@ local DiagnosticsDecorator = Decorator:extend()
---@protected
---@param args DecoratorArgs
function DiagnosticsDecorator:new(args)
self.explorer = args.explorer
self.explorer = args.explorer

self.enabled = true
self.highlight_range = self.explorer.opts.renderer.highlight_diagnostics or "none"
self.icon_placement = self.explorer.opts.renderer.icons.diagnostics_placement or "none"
self.enabled = true
self.highlight_range = self.explorer.opts.renderer.highlight_diagnostics or "none"
self.icon_placement = self.explorer.opts.renderer.icons.diagnostics_placement or "none"

local vim_diagnostic_icons = {}

if self.explorer.opts.diagnostics.diagnostic_opts then
local vim_diagnostic_config = vim.diagnostic.config() or {}
local signs = vim_diagnostic_config.signs or {}
if type(signs) == "function" then
signs = signs(0, 0)
end

vim_diagnostic_icons = (type(signs) == "table" and signs.text) or {}
end

if self.explorer.opts.renderer.icons.show.diagnostics then
self.diag_icons = {}
for name, sev in pairs(ICON_KEYS) do
self.diag_icons[sev] = {
str = self.explorer.opts.diagnostics.icons[name],
str = vim_diagnostic_icons[sev] or self.explorer.opts.diagnostics.icons[name],
hl = { HG_ICON[sev] },
}
self:define_sign(self.diag_icons[sev])
Expand Down
Loading