From 239f2d6fea49a91e7c81b9f90caba4b78def88dd Mon Sep 17 00:00:00 2001 From: Reviakin Evgeny Date: Fri, 24 Dec 2021 13:47:23 +0200 Subject: [PATCH] show diagnostics on parent dirs if nodes with diagnostics are not visible (#862) --- doc/nvim-tree-lua.txt | 6 ++++++ lua/nvim-tree.lua | 1 + lua/nvim-tree/diagnostics.lua | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 02c924ad..e72b5f1f 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -85,6 +85,7 @@ function. update_cwd = false, diagnostics = { enable = false, + show_on_dirs = false, icons = { hint = "", info = "", @@ -231,6 +232,11 @@ Here is a list of the options available in the setup call: type: `boolean` default: `false` + - diagnostics.show_on_dirs: if the node with diagnostic is not visible, + then show diagnostic in the parent directory + type: `boolean` + default: `false` + - |diagnostics.icons|: icons for diagnostic severity type: `table` default: `{ hint = "", info = "", warning = "", error = "" }` diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 4eb9c49c..a91db7db 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -431,6 +431,7 @@ local DEFAULT_OPTS = { }, diagnostics = { enable = false, + show_on_dirs = false, icons = { hint = "", info = "", diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index 9a934c60..8f109dc0 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -125,7 +125,11 @@ function M.update() for bufname, severity in pairs(buffer_severity) do if 0 < severity and severity < 5 then local node, line = utils.find_node(nodes, function(node) - return node.absolute_path == bufname + if M.show_on_dirs and not node.open then + return vim.startswith(bufname, node.absolute_path) + else + return node.absolute_path == bufname + end end) if node then add_sign(line, severity) end end @@ -142,6 +146,7 @@ local links = { function M.setup(opts) M.enable = opts.diagnostics.enable + M.show_on_dirs = opts.diagnostics.show_on_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] })