From 4aa6d7a93967a54cf7be4bc696ff9d1e11b36265 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 2 Sep 2023 15:04:06 +1000 Subject: [PATCH 1/5] feat(#1917): add renderer.highlight_diagnostics --- doc/nvim-tree-lua.txt | 17 ++++++++++++++++- lua/nvim-tree.lua | 1 + lua/nvim-tree/colors.lua | 8 ++++++++ lua/nvim-tree/diagnostics.lua | 12 +----------- lua/nvim-tree/renderer/builder.lua | 7 +++++++ lua/nvim-tree/renderer/init.lua | 4 ++-- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 5bc23a4d693..e5a8c751e1f 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -345,6 +345,7 @@ applying configuration. add_trailing = false, group_empty = false, highlight_git = false, + highlight_diagnostics = false, full_name = false, highlight_opened_files = "none", highlight_modified = "none", @@ -923,11 +924,17 @@ UI rendering setup Type: `boolean`, Default: `false` *nvim-tree.renderer.highlight_git* - Enable file highlight for git attributes using `NvimTreeGit*` highlight groups. + Enable highlight for git attributes using `NvimTreeGit*` highlight groups. Requires |nvim-tree.git.enable| This can be used with or without the icons. Type: `boolean`, Default: `false` + *nvim-tree.renderer.highlight_diagnostics* + Enable highlight for diagnostics using `LspDiagnosticsError*Text` highlight groups. + Requires |nvim-tree.diagnostics.enable| + This can be used with or without the icons. + Type: `boolean`, Default: `false` + *nvim-tree.renderer.highlight_opened_files* Highlight icons and/or names for |bufloaded()| files using the `NvimTreeOpenedFile` highlight group. @@ -2079,6 +2086,14 @@ NvimTreeFileNew (NvimTreeGitNew) NvimTreeFileDeleted (NvimTreeGitDeleted) NvimTreeFileIgnored (NvimTreeGitIgnored) +There are also links for text highlight for diagnostic status, linked by +default to their icon equivalent. + +NvimTreeLspDiagnosticsErrorText (NvimTreeLspDiagnosticsError) +NvimTreeLspDiagnosticsWarningText (NvimTreeLspDiagnosticsWarning) +NvimTreeLspDiagnosticsInfoText (NvimTreeLspDiagnosticsInformation) +NvimTreeLspDiagnosticsHintText (NvimTreeLspDiagnosticsHint) + There are 2 highlight groups for the live filter feature NvimTreeLiveFilterPrefix diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index ec14dbc9a86..66ad8a0faed 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -409,6 +409,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS add_trailing = false, group_empty = false, highlight_git = false, + highlight_diagnostics = false, full_name = false, highlight_opened_files = "none", highlight_modified = "none", diff --git a/lua/nvim-tree/colors.lua b/lua/nvim-tree/colors.lua index 863e5075d72..8522f36e6c8 100644 --- a/lua/nvim-tree/colors.lua +++ b/lua/nvim-tree/colors.lua @@ -81,6 +81,14 @@ local function get_links() FileStaged = "NvimTreeGitStaged", FileDeleted = "NvimTreeGitDeleted", FileIgnored = "NvimTreeGitIgnored", + LspDiagnosticsError = "DiagnosticError", + LspDiagnosticsWarning = "DiagnosticWarn", + LspDiagnosticsInformation = "DiagnosticInfo", + LspDiagnosticsHint = "DiagnosticHint", + LspDiagnosticsErrorText = "NvimTreeLspDiagnosticsError", + LspDiagnosticsWarningText = "NvimTreeLspDiagnosticsWarning", + LspDiagnosticsInformationText = "NvimTreeLspDiagnosticsInformation", + LspDiagnosticsHintText = "NvimTreeLspDiagnosticsHintFile", Popup = "Normal", GitIgnored = "Comment", StatusLine = "StatusLine", diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index d0ddb63fb61..09bb3563fc3 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -139,16 +139,10 @@ function M.update() end end log.profile_end(profile) + require("nvim-tree.renderer").draw() end) end -local links = { - NvimTreeLspDiagnosticsError = "DiagnosticError", - NvimTreeLspDiagnosticsWarning = "DiagnosticWarn", - NvimTreeLspDiagnosticsInformation = "DiagnosticInfo", - NvimTreeLspDiagnosticsHint = "DiagnosticHint", -} - function M.setup(opts) M.enable = opts.diagnostics.enable M.debounce_delay = opts.diagnostics.debounce_delay @@ -164,10 +158,6 @@ function M.setup(opts) vim.fn.sign_define(sign_names[2][1], { text = opts.diagnostics.icons.warning, texthl = sign_names[2][2] }) vim.fn.sign_define(sign_names[3][1], { text = opts.diagnostics.icons.info, texthl = sign_names[3][2] }) vim.fn.sign_define(sign_names[4][1], { text = opts.diagnostics.icons.hint, texthl = sign_names[4][2] }) - - for lhs, rhs in pairs(links) do - vim.cmd("hi def link " .. lhs .. " " .. rhs) - end end return M diff --git a/lua/nvim-tree/renderer/builder.lua b/lua/nvim-tree/renderer/builder.lua index 5dca0dcc536..b6ed9ca732c 100644 --- a/lua/nvim-tree/renderer/builder.lua +++ b/lua/nvim-tree/renderer/builder.lua @@ -5,6 +5,7 @@ local git = require "nvim-tree.renderer.components.git" local pad = require "nvim-tree.renderer.components.padding" local icons = require "nvim-tree.renderer.components.icons" local modified = require "nvim-tree.renderer.components.modified" +local diagnostics = require "nvim-tree.renderer.components.diagnostics" local Builder = {} Builder.__index = Builder @@ -263,6 +264,12 @@ function Builder:_get_highlight_override(node, unloaded_bufnr) end end + -- diagnostic status + local diagnostic_highlight = diagnostics.get_highlight(node) + if diagnostic_highlight then + name_hl = diagnostic_highlight + end + return icon_hl, name_hl end diff --git a/lua/nvim-tree/renderer/init.lua b/lua/nvim-tree/renderer/init.lua index 9bd0b5c6aa6..f9bffc55c60 100644 --- a/lua/nvim-tree/renderer/init.lua +++ b/lua/nvim-tree/renderer/init.lua @@ -1,5 +1,4 @@ local core = require "nvim-tree.core" -local diagnostics = require "nvim-tree.diagnostics" local log = require "nvim-tree.log" local view = require "nvim-tree.view" local events = require "nvim-tree.events" @@ -9,6 +8,7 @@ local _padding = require "nvim-tree.renderer.components.padding" local icon_component = require "nvim-tree.renderer.components.icons" local full_name = require "nvim-tree.renderer.components.full-name" local git = require "nvim-tree.renderer.components.git" +local diagnostics = require "nvim-tree.renderer.components.diagnostics" local Builder = require "nvim-tree.renderer.builder" local live_filter = require "nvim-tree.live-filter" local marks = require "nvim-tree.marks" @@ -84,7 +84,6 @@ function M.draw(unloaded_bufnr) vim.api.nvim_win_set_cursor(view.get_winnr(), cursor) end - diagnostics.update() marks.draw() view.grow_from_content() @@ -102,6 +101,7 @@ function M.setup(opts) full_name.setup(opts) git.setup(opts) modified.setup(opts) + diagnostics.setup(opts) icon_component.setup(opts) end From 4fbe9a9d9b2a03e74c49d6bafe766f0934e117d6 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 2 Sep 2023 15:04:56 +1000 Subject: [PATCH 2/5] feat(#1917): add renderer.highlight_diagnostics --- .../renderer/components/diagnostics.lua | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lua/nvim-tree/renderer/components/diagnostics.lua diff --git a/lua/nvim-tree/renderer/components/diagnostics.lua b/lua/nvim-tree/renderer/components/diagnostics.lua new file mode 100644 index 00000000000..a27ff227cb7 --- /dev/null +++ b/lua/nvim-tree/renderer/components/diagnostics.lua @@ -0,0 +1,22 @@ +local log = require "nvim-tree.log" + +local M = {} + +local HL = {} + +function M.get_highlight(node) + return M.config.renderer.highlight_diagnostics and HL[node.diag_status] +end + +function M.setup(opts) + M.config = {} + M.config.diagnostics = opts.diagnostics + M.config.renderer = opts.renderer + + HL[vim.diagnostic.severity.ERROR] = "NvimTreeLspDiagnosticsErrorText" + HL[vim.diagnostic.severity.WARN] = "NvimTreeLspDiagnosticsWarningText" + HL[vim.diagnostic.severity.INFO] = "NvimTreeLspDiagnosticsInfoText" + HL[vim.diagnostic.severity.HINT] = "NvimTreeLspDiagnosticsHintText" +end + +return M From 95266cca7e4d6b6c43ec2e4c6280bf7e38728b54 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 2 Sep 2023 16:11:51 +1000 Subject: [PATCH 3/5] feat(#1917): add enderer.icons.diagnostics_placement --- doc/nvim-tree-lua.txt | 22 +++---- lua/nvim-tree.lua | 1 + lua/nvim-tree/diagnostics.lua | 33 ---------- lua/nvim-tree/renderer/builder.lua | 39 ++++++++++-- .../renderer/components/diagnostics.lua | 60 +++++++++++++++---- lua/nvim-tree/renderer/init.lua | 1 + 6 files changed, 94 insertions(+), 62 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index e5a8c751e1f..8d24e7cc5be 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -374,6 +374,7 @@ applying configuration. }, }, git_placement = "before", + diagnostics_placement = "signcolumn", modified_placement = "after", padding = " ", symlink_arrow = " ➛ ", @@ -690,15 +691,7 @@ Open a file or directory in your preferred application. Windows: `{ "/c", "start", '""' }` *nvim-tree.diagnostics* -Show LSP and COC diagnostics in the signcolumn -Note that the modified sign will take precedence over the diagnostics signs. - - `NOTE`: it will use the default diagnostic color groups to highlight the signs. - If you wish to customize, you can override these groups: - - `NvimTreeLspDiagnosticsError` - - `NvimTreeLspDiagnosticsWarning` - - `NvimTreeLspDiagnosticsInformation` - - `NvimTreeLspDiagnosticsHint` +Show LSP and COC diagnostics. *nvim-tree.diagnostics.enable* Enable/disable the feature. @@ -882,7 +875,7 @@ Window / buffer setup. Type: `boolean`, Default: `false` *nvim-tree.view.signcolumn* - Show diagnostic sign column. Value can be `"yes"`, `"auto"`, `"no"`. + Show |signcolumn|. Value can be `"yes"`, `"auto"`, `"no"`. Type: `string`, Default: `"yes"` *nvim-tree.view.float* @@ -986,6 +979,8 @@ UI rendering setup *nvim-tree.renderer.icons* Configuration options for icons. + Sign column icon precedence: git < modified < diagnostics + *nvim-tree.renderer.icons.web_devicons* Configure optional plugin `"nvim-tree/nvim-web-devicons"` @@ -1017,9 +1012,14 @@ UI rendering setup Place where the git icons will be rendered. Can be `"after"` or `"before"` filename (after the file/folders icons) or `"signcolumn"` (requires |nvim-tree.view.signcolumn| enabled). - Note that the diagnostic signs and the modified sign will take precedence over the git signs. Type: `string`, Default: `before` + *nvim-tree.renderer.icons.diagnostics_placement* + Place where the diagnostics icon will be rendered. + Can be `"after"` or `"before"` filename (after the file/folders icons) + or `"signcolumn"` (requires |nvim-tree.view.signcolumn| enabled). + Type: `string`, Default: `signcolumn` + *nvim-tree.renderer.icons.modified_placement* Place where the modified icon will be rendered. Can be `"after"` or `"before"` filename (after the file/folders icons) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 66ad8a0faed..53dade60ed3 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -438,6 +438,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS }, }, git_placement = "before", + diagnostics_placement = "signcolumn", modified_placement = "after", padding = " ", symlink_arrow = " ➛ ", diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index 09bb3563fc3..22463319315 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -5,24 +5,7 @@ local log = require "nvim-tree.log" local M = {} -local GROUP = "NvimTreeDiagnosticSigns" - local severity_levels = { Error = 1, Warning = 2, Information = 3, Hint = 4 } -local sign_names = { - { "NvimTreeSignError", "NvimTreeLspDiagnosticsError" }, - { "NvimTreeSignWarning", "NvimTreeLspDiagnosticsWarning" }, - { "NvimTreeSignInformation", "NvimTreeLspDiagnosticsInformation" }, - { "NvimTreeSignHint", "NvimTreeLspDiagnosticsHint" }, -} - -local function add_sign(linenr, severity) - local buf = view.get_bufnr() - if not vim.api.nvim_buf_is_valid(buf) or not vim.api.nvim_buf_is_loaded(buf) then - return - end - local sign_name = sign_names[severity][1] - vim.fn.sign_place(0, GROUP, sign_name, buf, { lnum = linenr, priority = 2 }) -end local function from_nvim_lsp() local buffer_severity = {} @@ -85,14 +68,6 @@ local function is_using_coc() return vim.g.coc_service_initialized == 1 end -function M.clear() - if not M.enable or not view.is_buf_valid(view.get_bufnr()) then - return - end - - vim.fn.sign_unplace(GROUP) -end - function M.update() if not M.enable or not core.get_explorer() or not view.is_buf_valid(view.get_bufnr()) then return @@ -108,8 +83,6 @@ function M.update() buffer_severity = from_nvim_lsp() end - M.clear() - local nodes_by_line = utils.get_nodes_by_line(core.get_explorer().nodes, core.get_nodes_starting_line()) for _, node in pairs(nodes_by_line) do node.diag_status = nil @@ -129,11 +102,9 @@ function M.update() then log.line("diagnostics", " matched fold node '%s'", node.absolute_path) node.diag_status = severity - add_sign(line, severity) elseif nodepath == bufpath then log.line("diagnostics", " matched file node '%s'", node.absolute_path) node.diag_status = severity - add_sign(line, severity) end end end @@ -154,10 +125,6 @@ function M.setup(opts) M.show_on_dirs = opts.diagnostics.show_on_dirs M.show_on_open_dirs = opts.diagnostics.show_on_open_dirs - vim.fn.sign_define(sign_names[1][1], { text = opts.diagnostics.icons.error, texthl = sign_names[1][2] }) - vim.fn.sign_define(sign_names[2][1], { text = opts.diagnostics.icons.warning, texthl = sign_names[2][2] }) - vim.fn.sign_define(sign_names[3][1], { text = opts.diagnostics.icons.info, texthl = sign_names[3][2] }) - vim.fn.sign_define(sign_names[4][1], { text = opts.diagnostics.icons.hint, texthl = sign_names[4][2] }) end return M diff --git a/lua/nvim-tree/renderer/builder.lua b/lua/nvim-tree/renderer/builder.lua index b6ed9ca732c..8b44a78e4c2 100644 --- a/lua/nvim-tree/renderer/builder.lua +++ b/lua/nvim-tree/renderer/builder.lua @@ -73,6 +73,14 @@ function Builder:configure_git_icons_placement(where) return self end +function Builder:configure_diagnostics_icon_placement(where) + if where ~= "after" and where ~= "before" and where ~= "signcolumn" then + where = "before" -- default before + end + self.diagnostics_placement = where + return self +end + function Builder:configure_modified_placement(where) if where ~= "after" and where ~= "before" and where ~= "signcolumn" then where = "after" -- default after @@ -207,20 +215,29 @@ end function Builder:_get_git_icons(node) local git_icons = git.get_icons(node) if git_icons and #git_icons > 0 and self.git_placement == "signcolumn" then - local sign = git_icons[1] - table.insert(self.signs, { sign = sign.hl, lnum = self.index + 1, priority = 1 }) + table.insert(self.signs, { sign = git_icons[1].hl, lnum = self.index + 1, priority = 1 }) git_icons = nil end return git_icons end +---@param node table +---@return HighlightedString[]|nil icon +function Builder:_get_diagnostics_icon(node) + local diagnostics_icon = diagnostics.get_icon(node) + if diagnostics_icon and self.diagnostics_placement == "signcolumn" then + table.insert(self.signs, { sign = diagnostics_icon.hl, lnum = self.index + 1, priority = 2 }) + diagnostics_icon = nil + end + return diagnostics_icon +end + ---@param node table ---@return HighlightedString|nil icon function Builder:_get_modified_icon(node) local modified_icon = modified.get_icon(node) if modified_icon and self.modified_placement == "signcolumn" then - local sign = modified_icon - table.insert(self.signs, { sign = sign.hl, lnum = self.index + 1, priority = 3 }) + table.insert(self.signs, { sign = modified_icon.hl, lnum = self.index + 1, priority = 3 }) modified_icon = nil end return modified_icon @@ -277,9 +294,10 @@ end ---@param icon HighlightedString ---@param name HighlightedString ---@param git_icons HighlightedString[]|nil +---@param diagnostics_icon HighlightedString|nil ---@param modified_icon HighlightedString|nil ---@return HighlightedString[] -function Builder:_format_line(padding, icon, name, git_icons, modified_icon) +function Builder:_format_line(padding, icon, name, git_icons, diagnostics_icon, modified_icon) local added_len = 0 local function add_to_end(t1, t2) for _, v in ipairs(t2) do @@ -305,13 +323,21 @@ function Builder:_format_line(padding, icon, name, git_icons, modified_icon) if modified_icon and self.modified_placement == "before" then add_to_end(line, { modified_icon }) end + if diagnostics_icon and self.diagnostics_placement == "before" then + add_to_end(line, { diagnostics_icon }) + end + add_to_end(line, { name }) + if git_icons and self.git_placement == "after" then add_to_end(line, git_icons) end if modified_icon and self.modified_placement == "after" then add_to_end(line, { modified_icon }) end + if diagnostics_icon and self.diagnostics_placement == "after" then + add_to_end(line, { diagnostics_icon }) + end return line end @@ -321,6 +347,7 @@ function Builder:_build_line(node, idx, num_children, unloaded_bufnr) local padding = pad.get_padding(self.depth, idx, num_children, node, self.markers) local git_icons = self:_get_git_icons(node) local modified_icon = self:_get_modified_icon(node) + local diagnostics_icon = self:_get_diagnostics_icon(node) -- main components local is_folder = node.nodes ~= nil @@ -343,7 +370,7 @@ function Builder:_build_line(node, idx, num_children, unloaded_bufnr) name.hl = name_hl end - local line = self:_format_line(padding, icon, name, git_icons, modified_icon) + local line = self:_format_line(padding, icon, name, git_icons, diagnostics_icon, modified_icon) self:_insert_line(self:_unwrap_highlighted_strings(line)) self.index = self.index + 1 diff --git a/lua/nvim-tree/renderer/components/diagnostics.lua b/lua/nvim-tree/renderer/components/diagnostics.lua index a27ff227cb7..7a4799d5d1d 100644 --- a/lua/nvim-tree/renderer/components/diagnostics.lua +++ b/lua/nvim-tree/renderer/components/diagnostics.lua @@ -1,22 +1,58 @@ -local log = require "nvim-tree.log" - local M = {} -local HL = {} +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) - return M.config.renderer.highlight_diagnostics and HL[node.diag_status] + 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 then + return I[node.diag_status] + end end function M.setup(opts) - M.config = {} - M.config.diagnostics = opts.diagnostics - M.config.renderer = opts.renderer - - HL[vim.diagnostic.severity.ERROR] = "NvimTreeLspDiagnosticsErrorText" - HL[vim.diagnostic.severity.WARN] = "NvimTreeLspDiagnosticsWarningText" - HL[vim.diagnostic.severity.INFO] = "NvimTreeLspDiagnosticsInfoText" - HL[vim.diagnostic.severity.HINT] = "NvimTreeLspDiagnosticsHintText" + 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 diff --git a/lua/nvim-tree/renderer/init.lua b/lua/nvim-tree/renderer/init.lua index f9bffc55c60..8785e175ef3 100644 --- a/lua/nvim-tree/renderer/init.lua +++ b/lua/nvim-tree/renderer/init.lua @@ -69,6 +69,7 @@ function M.draw(unloaded_bufnr) :configure_modified_highlighting(M.config.highlight_modified) :configure_icon_padding(M.config.icons.padding) :configure_git_icons_placement(M.config.icons.git_placement) + :configure_diagnostics_icon_placement(M.config.icons.diagnostics_placement) :configure_modified_placement(M.config.icons.modified_placement) :configure_symlink_destination(M.config.symlink_destination) :configure_filter(live_filter.filter, live_filter.prefix) From af9a3672ed5700d9d76ee7e790cfb0238de1c071 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 2 Sep 2023 16:20:52 +1000 Subject: [PATCH 4/5] feat(#1917): add renderer.icons.show.diagnostics --- doc/nvim-tree-lua.txt | 6 ++++++ lua/nvim-tree.lua | 1 + lua/nvim-tree/renderer/components/diagnostics.lua | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 8d24e7cc5be..486dd785604 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -383,6 +383,7 @@ applying configuration. folder = true, folder_arrow = true, git = true, + diagnostics = true, modified = true, }, glyphs = { @@ -1055,6 +1056,11 @@ UI rendering setup Requires |git.enable| `= true` Type: `boolean`, Default: `true` + *nvim-tree.renderer.icons.show.diagnostics* + Show a diagnostics status icon, see |renderer.icons.diagnostics_placement| + Requires |diagnostics.enable| `= true` + Type: `boolean`, Default: `true` + *nvim-tree.renderer.icons.show.modified* Show a modified icon, see |renderer.icons.modified_placement| Requires |modified.enable| `= true` diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 53dade60ed3..1cc65fa59f8 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -447,6 +447,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS folder = true, folder_arrow = true, git = true, + diagnostics = true, modified = true, }, glyphs = { diff --git a/lua/nvim-tree/renderer/components/diagnostics.lua b/lua/nvim-tree/renderer/components/diagnostics.lua index 7a4799d5d1d..890197b1fd1 100644 --- a/lua/nvim-tree/renderer/components/diagnostics.lua +++ b/lua/nvim-tree/renderer/components/diagnostics.lua @@ -16,7 +16,7 @@ end ---@param node table ---@return HighlightedString|nil modified icon function M.get_icon(node) - if M.config.diagnostics.enable then + if M.config.diagnostics.enable and M.config.renderer.icons.show.diagnostics then return I[node.diag_status] end end From 94da1009e8ee95050de55965389b30c22dbdc525 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 3 Sep 2023 12:27:21 +1000 Subject: [PATCH 5/5] feat(#1917): document highlight overrides --- doc/nvim-tree-lua.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 486dd785604..6d0ea1442d1 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -905,6 +905,8 @@ Window / buffer setup. *nvim-tree.renderer* UI rendering setup + Highlight override precedence: git < opened < modified < diagnostics + *nvim-tree.renderer.add_trailing* Appends a trailing slash to folder names. Type: `boolean`, Default: `false`