Skip to content

Commit 7fcb48c

Browse files
authored
feat: add option for folder arrows to be inline with indent markers (#1468)
1 parent ac90664 commit 7fcb48c

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

doc/nvim-tree-lua.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Subsequent calls to setup will replace the previous configuration.
201201
root_folder_modifier = ":~",
202202
indent_markers = {
203203
enable = false,
204+
inline_arrows = true,
204205
icons = {
205206
corner = "└",
206207
edge = "│",
@@ -670,6 +671,11 @@ UI rendering setup
670671
Display indent markers when folders are open
671672
Type: `boolean`, Default: `false`
672673

674+
*nvim-tree.renderer.indent_markers.inline_arrows*
675+
Display folder arrows in the same column as indent marker
676+
when using |renderer.icons.show.folder_arrow|
677+
Type: `boolean`, Default: `true`
678+
673679
*nvim-tree.renderer.indent_markers.icons*
674680
Icons shown before the file/directory.
675681
Type: `table`, Default: `{ corner = "└", edge = "│", item = "│", none = " ", }`

lua/nvim-tree.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
464464
root_folder_modifier = ":~",
465465
indent_markers = {
466466
enable = false,
467+
inline_arrows = true,
467468
icons = {
468469
corner = "",
469470
edge = "",

lua/nvim-tree/renderer/components/padding.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ local function check_siblings_for_folder(node, with_arrows)
1919
return false
2020
end
2121

22-
local function get_padding_indent_markers(depth, idx, nodes_number, markers, with_arrows, node)
22+
local function get_padding_indent_markers(depth, idx, nodes_number, markers, with_arrows, inline_arrows, node)
2323
local base_padding = with_arrows and (not node.nodes or depth > 0) and " " or ""
24-
local padding = base_padding
24+
local padding = (inline_arrows or depth == 0) and base_padding or ""
2525

2626
if depth > 0 then
2727
local has_folder_sibling = check_siblings_for_folder(node, with_arrows)
@@ -39,8 +39,10 @@ local function get_padding_indent_markers(depth, idx, nodes_number, markers, wit
3939
glyph = M.config.indent_markers.icons.none
4040
end
4141

42-
if not with_arrows or i == 1 then
42+
if not with_arrows or (inline_arrows and (rdepth ~= i or not node.nodes)) then
4343
padding = padding .. glyph .. " "
44+
elseif inline_arrows then
45+
padding = padding
4446
elseif idx == nodes_number and i == rdepth and has_folder_sibling then
4547
padding = padding .. base_padding .. glyph .. "── "
4648
elseif rdepth == i and not node.nodes and has_folder_sibling then
@@ -68,9 +70,10 @@ function M.get_padding(depth, idx, nodes_number, node, markers)
6870

6971
local show_arrows = M.config.icons.show.folder_arrow
7072
local show_markers = M.config.indent_markers.enable
73+
local inline_arrows = M.config.indent_markers.inline_arrows
7174

7275
if show_markers then
73-
padding = padding .. get_padding_indent_markers(depth, idx, nodes_number, markers, show_arrows, node)
76+
padding = padding .. get_padding_indent_markers(depth, idx, nodes_number, markers, show_arrows, inline_arrows, node)
7477
else
7578
padding = padding .. string.rep(" ", depth)
7679
end

0 commit comments

Comments
 (0)