feat(#1826): add diagnostics.diagnostic_opts: vim.diagnostic.Opts will override diagnostics.severity and diagnostics.icons (#3190)
* feat(#1826): allow using config from vim.diagnostic for icons + severity * update help default options, add index --------- Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
parent
b70a741f5a
commit
fefa335f1c
@ -545,6 +545,7 @@ Following is the default configuration. See |nvim-tree-opts| for details. >lua
|
|||||||
warning = "",
|
warning = "",
|
||||||
error = "",
|
error = "",
|
||||||
},
|
},
|
||||||
|
diagnostic_opts = false,
|
||||||
},
|
},
|
||||||
modified = {
|
modified = {
|
||||||
enable = false,
|
enable = false,
|
||||||
@ -1329,6 +1330,10 @@ Icons for diagnostic severity.
|
|||||||
error = ""
|
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*
|
5.9 OPTS: MODIFIED *nvim-tree-opts-modified*
|
||||||
|
|
||||||
@ -3175,6 +3180,7 @@ highlight group is not, hard linking as follows: >
|
|||||||
|nvim-tree.actions.use_system_clipboard|
|
|nvim-tree.actions.use_system_clipboard|
|
||||||
|nvim-tree.auto_reload_on_write|
|
|nvim-tree.auto_reload_on_write|
|
||||||
|nvim-tree.diagnostics.debounce_delay|
|
|nvim-tree.diagnostics.debounce_delay|
|
||||||
|
|nvim-tree.diagnostics.diagnostic_opts|
|
||||||
|nvim-tree.diagnostics.enable|
|
|nvim-tree.diagnostics.enable|
|
||||||
|nvim-tree.diagnostics.icons|
|
|nvim-tree.diagnostics.icons|
|
||||||
|nvim-tree.diagnostics.severity|
|
|nvim-tree.diagnostics.severity|
|
||||||
|
|||||||
@ -420,6 +420,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
warning = "",
|
warning = "",
|
||||||
error = "",
|
error = "",
|
||||||
},
|
},
|
||||||
|
diagnostic_opts = false,
|
||||||
},
|
},
|
||||||
modified = {
|
modified = {
|
||||||
enable = false,
|
enable = false,
|
||||||
|
|||||||
@ -231,7 +231,10 @@ end
|
|||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
M.enable = opts.diagnostics.enable
|
M.enable = opts.diagnostics.enable
|
||||||
M.debounce_delay = opts.diagnostics.debounce_delay
|
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
|
if M.enable then
|
||||||
log.line("diagnostics", "setup")
|
log.line("diagnostics", "setup")
|
||||||
|
|||||||
@ -47,11 +47,23 @@ function DiagnosticsDecorator:new(args)
|
|||||||
self.highlight_range = self.explorer.opts.renderer.highlight_diagnostics or "none"
|
self.highlight_range = self.explorer.opts.renderer.highlight_diagnostics or "none"
|
||||||
self.icon_placement = self.explorer.opts.renderer.icons.diagnostics_placement 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
|
if self.explorer.opts.renderer.icons.show.diagnostics then
|
||||||
self.diag_icons = {}
|
self.diag_icons = {}
|
||||||
for name, sev in pairs(ICON_KEYS) do
|
for name, sev in pairs(ICON_KEYS) do
|
||||||
self.diag_icons[sev] = {
|
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] },
|
hl = { HG_ICON[sev] },
|
||||||
}
|
}
|
||||||
self:define_sign(self.diag_icons[sev])
|
self:define_sign(self.diag_icons[sev])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user