* feat(#1917): add renderer.highlight_diagnostics * feat(#1917): add renderer.highlight_diagnostics * feat(#1917): add enderer.icons.diagnostics_placement * feat(#1917): add renderer.icons.show.diagnostics * feat(#1917): document highlight overrides
This commit is contained in:
committed by
GitHub
parent
28c3980b25
commit
323f65cb9c
58
lua/nvim-tree/renderer/components/diagnostics.lua
Normal file
58
lua/nvim-tree/renderer/components/diagnostics.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
local M = {}
|
||||
|
||||
local H = {}
|
||||
local I = {}
|
||||
|
||||
---diagnostics text highlight group if there is a status
|
||||
---@param node table
|
||||
---@return string|nil highlight
|
||||
function M.get_highlight(node)
|
||||
if M.config.diagnostics.enable and M.config.renderer.highlight_diagnostics then
|
||||
return H[node.diag_status]
|
||||
end
|
||||
end
|
||||
|
||||
---diagnostics icon if there is a status
|
||||
---@param node table
|
||||
---@return HighlightedString|nil modified icon
|
||||
function M.get_icon(node)
|
||||
if M.config.diagnostics.enable and M.config.renderer.icons.show.diagnostics then
|
||||
return I[node.diag_status]
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = {
|
||||
diagnostics = opts.diagnostics,
|
||||
renderer = opts.renderer,
|
||||
}
|
||||
|
||||
H[vim.diagnostic.severity.ERROR] = "NvimTreeLspDiagnosticsErrorText"
|
||||
H[vim.diagnostic.severity.WARN] = "NvimTreeLspDiagnosticsWarningText"
|
||||
H[vim.diagnostic.severity.INFO] = "NvimTreeLspDiagnosticsInfoText"
|
||||
H[vim.diagnostic.severity.HINT] = "NvimTreeLspDiagnosticsHintText"
|
||||
|
||||
I[vim.diagnostic.severity.ERROR] = {
|
||||
str = M.config.diagnostics.icons.error,
|
||||
hl = "NvimTreeLspDiagnosticsError",
|
||||
}
|
||||
|
||||
I[vim.diagnostic.severity.WARN] = {
|
||||
str = M.config.diagnostics.icons.warning,
|
||||
hl = "NvimTreeLspDiagnosticsWarning",
|
||||
}
|
||||
I[vim.diagnostic.severity.INFO] = {
|
||||
str = M.config.diagnostics.icons.info,
|
||||
hl = "NvimTreeLspDiagnosticsInfo",
|
||||
}
|
||||
I[vim.diagnostic.severity.HINT] = {
|
||||
str = M.config.diagnostics.icons.hint,
|
||||
hl = "NvimTreeLspDiagnosticsHint",
|
||||
}
|
||||
|
||||
for _, i in ipairs(I) do
|
||||
vim.fn.sign_define(i.hl, { text = i.str, texthl = i.hl })
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user