@@ -25,30 +25,33 @@ local function get_padding_indent_markers(depth, idx, nodes_number, markers, wit
25
25
26
26
if depth > 0 then
27
27
local has_folder_sibling = check_siblings_for_folder (node , with_arrows )
28
- local rdepth = depth / 2
29
- markers [rdepth ] = idx ~= nodes_number
30
- for i = 1 , rdepth do
28
+ local indent = string.rep ( " " , M . config . indent_width - 1 )
29
+ markers [depth ] = idx ~= nodes_number
30
+ for i = 1 , depth do
31
31
local glyph
32
- if idx == nodes_number and i == rdepth then
32
+ if idx == nodes_number and i == depth then
33
+ local bottom_width = M .config .indent_width
34
+ - 2
35
+ + (with_arrows and not inline_arrows and has_folder_sibling and 2 or 0 )
33
36
glyph = M .config .indent_markers .icons .corner
34
- elseif markers [i ] and i == rdepth then
35
- glyph = M .config .indent_markers .icons .item
37
+ .. string.rep (M .config .indent_markers .icons .bottom , bottom_width )
38
+ .. (M .config .indent_width > 1 and " " or " " )
39
+ elseif markers [i ] and i == depth then
40
+ glyph = M .config .indent_markers .icons .item .. indent
36
41
elseif markers [i ] then
37
- glyph = M .config .indent_markers .icons .edge
42
+ glyph = M .config .indent_markers .icons .edge .. indent
38
43
else
39
- glyph = M .config .indent_markers .icons .none
44
+ glyph = M .config .indent_markers .icons .none .. indent
40
45
end
41
46
42
- if not with_arrows or (inline_arrows and (rdepth ~= i or not node .nodes )) then
43
- padding = padding .. glyph .. " "
47
+ if not with_arrows or (inline_arrows and (depth ~= i or not node .nodes )) then
48
+ padding = padding .. glyph
44
49
elseif inline_arrows then
45
50
padding = padding
46
- elseif idx == nodes_number and i == rdepth and has_folder_sibling then
47
- padding = padding .. base_padding .. glyph .. " ── "
48
- elseif rdepth == i and not node .nodes and has_folder_sibling then
49
- padding = padding .. base_padding .. glyph .. " " .. base_padding
51
+ elseif idx ~= nodes_number and depth == i and not node .nodes and has_folder_sibling then
52
+ padding = padding .. base_padding .. glyph .. base_padding
50
53
else
51
- padding = padding .. base_padding .. glyph .. " "
54
+ padding = padding .. base_padding .. glyph
52
55
end
53
56
end
54
57
end
@@ -71,11 +74,12 @@ function M.get_padding(depth, idx, nodes_number, node, markers)
71
74
local show_arrows = M .config .icons .show .folder_arrow
72
75
local show_markers = M .config .indent_markers .enable
73
76
local inline_arrows = M .config .indent_markers .inline_arrows
77
+ local indent_width = M .config .indent_width
74
78
75
79
if show_markers then
76
80
padding = padding .. get_padding_indent_markers (depth , idx , nodes_number , markers , show_arrows , inline_arrows , node )
77
81
else
78
- padding = padding .. string.rep (" " , depth )
82
+ padding = padding .. string.rep (" " , depth * indent_width )
79
83
end
80
84
81
85
if show_arrows then
87
91
88
92
function M .setup (opts )
89
93
M .config = opts .renderer
94
+
95
+ if M .config .indent_width < 1 then
96
+ M .config .indent_width = 1
97
+ end
98
+
99
+ local function check_marker (symbol )
100
+ if # symbol == 0 then
101
+ return " "
102
+ end
103
+ -- return the first character from the UTF-8 encoded string; we may use utf8.codes from Lua 5.3 when available
104
+ return symbol :match " [%z\1 -\127\194 -\244 ][\128 -\191 ]*"
105
+ end
106
+
107
+ for k , v in pairs (M .config .indent_markers .icons ) do
108
+ M .config .indent_markers .icons [k ] = check_marker (v )
109
+ end
90
110
end
91
111
92
112
return M
0 commit comments