|
1 | 1 | local config = require'nvim-tree.config'
|
2 | 2 | local utils = require'nvim-tree.utils'
|
3 | 3 | local view = require'nvim-tree.view'
|
| 4 | +local _padding = require'nvim-tree.renderer.padding' |
4 | 5 |
|
5 | 6 | local api = vim.api
|
6 | 7 |
|
@@ -241,40 +242,6 @@ if icon_state.show_git_icon then
|
241 | 242 | end
|
242 | 243 | end
|
243 | 244 |
|
244 |
| -local get_padding = function(depth) |
245 |
| - return string.rep(' ', depth) |
246 |
| -end |
247 |
| - |
248 |
| -if icon_state.show_folder_icon and icon_state.show_folder_arrows then |
249 |
| - get_padding = function(depth, _, _, node) |
250 |
| - if node.entries then |
251 |
| - local icon = icon_state.icons.folder_icons[node.open and 'arrow_open' or 'arrow_closed'] |
252 |
| - return string.rep(' ', depth - 2)..icon..' ' |
253 |
| - end |
254 |
| - return string.rep(' ', depth) |
255 |
| - end |
256 |
| -end |
257 |
| - |
258 |
| -if vim.g.nvim_tree_indent_markers == 1 then |
259 |
| - get_padding = function(depth, idx, tree, _, markers) |
260 |
| - local padding = "" |
261 |
| - if depth ~= 0 then |
262 |
| - local rdepth = depth/2 |
263 |
| - markers[rdepth] = idx ~= #tree.entries |
264 |
| - for i=1,rdepth do |
265 |
| - if idx == #tree.entries and i == rdepth then |
266 |
| - padding = padding..'└ ' |
267 |
| - elseif markers[i] then |
268 |
| - padding = padding..'│ ' |
269 |
| - else |
270 |
| - padding = padding..' ' |
271 |
| - end |
272 |
| - end |
273 |
| - end |
274 |
| - return padding |
275 |
| - end |
276 |
| -end |
277 |
| - |
278 | 245 | local picture = {
|
279 | 246 | jpg = true,
|
280 | 247 | jpeg = true,
|
@@ -303,7 +270,7 @@ local function update_draw_data(tree, depth, markers)
|
303 | 270 | end
|
304 | 271 |
|
305 | 272 | for idx, node in ipairs(tree.entries) do
|
306 |
| - local padding = get_padding(depth, idx, tree, node, markers) |
| 273 | + local padding = _padding.get_padding(depth, idx, tree, node, markers) |
307 | 274 | local offset = string.len(padding)
|
308 | 275 | if depth > 0 then
|
309 | 276 | table.insert(hl, { 'NvimTreeIndentMarker', index, 0, offset })
|
@@ -443,6 +410,8 @@ function M.draw(tree, reload)
|
443 | 410 | hl = {}
|
444 | 411 |
|
445 | 412 | local show_arrows = icon_state.show_folder_icon and icon_state.show_folder_arrows
|
| 413 | + _padding.reload_padding_function() |
| 414 | + icon_state = config.get_icon_state() |
446 | 415 | update_draw_data(tree, show_arrows and 2 or 0, {})
|
447 | 416 | end
|
448 | 417 |
|
|
0 commit comments