diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 2f840a40..c79770c8 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -201,10 +201,10 @@ Subsequent calls to setup will replace the previous configuration. indent_markers = { enable = false, icons = { - corner = "└ ", - edge = "│ ", - item = "│ ", - none = " ", + corner = "└", + edge = "│", + item = "│", + none = " ", }, }, icons = { @@ -644,7 +644,7 @@ UI rendering setup *nvim-tree.renderer.indent_markers.icons* Icons shown before the file/directory. - Type: `table`, Default: `{ corner = "└ ", edge = "│ ", item = "│ ", none = " ", }` + Type: `table`, Default: `{ corner = "└", edge = "│", item = "│", none = " ", }` *nvim-tree.renderer.icons* Configuration options for icons. diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 0a393538..e162f1b4 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -449,10 +449,10 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS indent_markers = { enable = false, icons = { - corner = "└ ", - edge = "│ ", - item = "│ ", - none = " ", + corner = "└", + edge = "│", + item = "│", + none = " ", }, }, icons = { diff --git a/lua/nvim-tree/renderer/components/padding.lua b/lua/nvim-tree/renderer/components/padding.lua index a95312a4..aaa1aabc 100644 --- a/lua/nvim-tree/renderer/components/padding.lua +++ b/lua/nvim-tree/renderer/components/padding.lua @@ -1,21 +1,44 @@ local M = {} +local function check_siblings_for_folder(node, with_arrows) + if with_arrows then + for _, n in pairs(node.parent.nodes) do + if n.nodes then + return true + end + end + end + return false +end + local function get_padding_indent_markers(depth, idx, nodes_number, markers, with_arrows, node) - local default_padding = with_arrows and (not node.nodes or depth > 0) and " " or "" - local padding = depth == 0 and default_padding or "" + local base_padding = with_arrows and (not node.nodes or depth > 0) and " " or "" + local padding = base_padding if depth > 0 then + local has_folder_sibling = check_siblings_for_folder(node, with_arrows) local rdepth = depth / 2 markers[rdepth] = idx ~= nodes_number for i = 1, rdepth do + local glyph if idx == nodes_number and i == rdepth then - padding = padding .. default_padding .. M.config.indent_markers.icons.corner + glyph = M.config.indent_markers.icons.corner elseif markers[i] and i == rdepth then - padding = padding .. default_padding .. M.config.indent_markers.icons.item + glyph = M.config.indent_markers.icons.item elseif markers[i] then - padding = padding .. default_padding .. M.config.indent_markers.icons.edge + glyph = M.config.indent_markers.icons.edge else - padding = padding .. default_padding .. M.config.indent_markers.icons.none + glyph = M.config.indent_markers.icons.none + end + + if not with_arrows or i == 1 then + padding = padding .. glyph .. " " + elseif idx == nodes_number and i == rdepth and has_folder_sibling then + padding = padding .. base_padding .. glyph .. "── " + elseif rdepth == i and not node.nodes and has_folder_sibling then + padding = padding .. base_padding .. glyph .. " " .. base_padding + else + padding = padding .. base_padding .. glyph .. " " end end end