@@ -87,6 +87,26 @@ if icon_state.show_git_icon then
87
87
end
88
88
end
89
89
90
+ local get_padding = function (depth )
91
+ return string.rep (' ' , depth )
92
+ end
93
+
94
+ if vim .g .lua_tree_indent_markers == 1 then
95
+ get_padding = function (depth , idx , tree , node )
96
+ local padding = " "
97
+ if depth ~= 0 then
98
+ for i = 1 ,depth / 2 do
99
+ if idx == # tree .entries and i == depth / 2 then
100
+ padding = padding .. ' └ '
101
+ else
102
+ padding = padding .. ' │ '
103
+ end
104
+ end
105
+ end
106
+ return padding
107
+ end
108
+ end
109
+
90
110
local picture = {
91
111
jpg = true ,
92
112
jpeg = true ,
@@ -108,12 +128,16 @@ local function update_draw_data(tree, depth)
108
128
index = 1
109
129
end
110
130
111
- for _ , node in ipairs (tree .entries ) do
112
- local padding = string.rep (" " , depth )
131
+ for idx , node in ipairs (tree .entries ) do
132
+ local padding = get_padding (depth , idx , tree , node )
133
+ local offset = string.len (padding )
134
+ if depth > 0 then
135
+ table.insert (hl , { ' LuaTreeIndentMarker' , index , 0 , offset })
136
+ end
113
137
if node .entries then
114
138
local icon = get_folder_icon (node .open )
115
- local git_icon = get_git_icons (node , index , depth +# node .name , # icon + 1 )
116
- set_folder_hl (index , depth , # icon , # node .name )
139
+ local git_icon = get_git_icons (node , index , offset +# node .name , # icon + 1 )
140
+ set_folder_hl (index , offset , # icon , # node .name )
117
141
index = index + 1
118
142
if node .open then
119
143
table.insert (lines , padding .. icon .. node .name .. " " .. git_icon )
@@ -122,7 +146,7 @@ local function update_draw_data(tree, depth)
122
146
table.insert (lines , padding .. icon .. node .name .. " " .. git_icon )
123
147
end
124
148
elseif node .link_to then
125
- table.insert (hl , { ' LuaTreeSymlink' , index , depth , - 1 })
149
+ table.insert (hl , { ' LuaTreeSymlink' , index , offset , - 1 })
126
150
table.insert (lines , padding .. node .name .. " ➛ " .. node .link_to )
127
151
index = index + 1
128
152
@@ -131,17 +155,17 @@ local function update_draw_data(tree, depth)
131
155
local git_icons
132
156
if special [node .name ] then
133
157
icon = " "
134
- git_icons = get_git_icons (node , index , depth , 0 )
135
- table.insert (hl , {' LuaTreeSpecialFile' , index , depth +# git_icons , - 1 })
158
+ git_icons = get_git_icons (node , index , offset , 0 )
159
+ table.insert (hl , {' LuaTreeSpecialFile' , index , offset +# git_icons , - 1 })
136
160
else
137
- icon = get_file_icon (node .name , node .extension , index , depth )
138
- git_icons = get_git_icons (node , index , depth , # icon )
161
+ icon = get_file_icon (node .name , node .extension , index , offset )
162
+ git_icons = get_git_icons (node , index , offset , # icon )
139
163
end
140
164
table.insert (lines , padding .. icon .. git_icons .. node .name )
141
165
if node .executable then
142
- table.insert (hl , {' LuaTreeExecFile' , index , depth +# icon +# git_icons , - 1 })
166
+ table.insert (hl , {' LuaTreeExecFile' , index , offset +# icon +# git_icons , - 1 })
143
167
elseif picture [node .extension ] then
144
- table.insert (hl , {' LuaTreeImageFile' , index , depth +# icon +# git_icons , - 1 })
168
+ table.insert (hl , {' LuaTreeImageFile' , index , offset +# icon +# git_icons , - 1 })
145
169
end
146
170
index = index + 1
147
171
end
0 commit comments