@@ -387,9 +387,9 @@ M.indent = function(config, node, state)
387
387
388
388
local strlen = vim .fn .strdisplaywidth
389
389
local skip_marker = state .skip_marker_at_level
390
- local indent_size = config .indent_size or 2
391
- local padding = config .padding or 0
392
- local start_level = config .level or 2
390
+ local indent_size = config .indent_size
391
+ local padding = config .padding
392
+ local marker_start_level = config .marker_start_level
393
393
local level = node .level
394
394
local with_markers = config .with_markers
395
395
local with_expanders = config .with_expanders == nil and file_nesting .is_enabled ()
@@ -404,10 +404,13 @@ M.indent = function(config, node, state)
404
404
end
405
405
end
406
406
407
- if indent_size == 0 or level < start_level or not with_markers then
408
- local len = indent_size * level + padding
407
+ if indent_size == 0 or not with_markers then
408
+ local len = indent_size + padding
409
409
local expander = get_expander ()
410
410
if level == 0 or not expander then
411
+ if marker_start_level == 0 then
412
+ len = len + indent_size
413
+ end
411
414
return {
412
415
text = string.rep (" " , len ),
413
416
}
@@ -420,36 +423,67 @@ M.indent = function(config, node, state)
420
423
421
424
local indent_marker = config .indent_marker or " │"
422
425
local last_indent_marker = config .last_indent_marker or " └"
423
-
424
426
skip_marker [level ] = node .is_last_child
427
+
425
428
local indent = {}
426
429
if padding > 0 then
427
430
table.insert (indent , { text = string.rep (" " , padding ) })
428
431
end
429
432
430
- for i = start_level - 1 , level do
431
- local char = " "
432
- local spaces_count = indent_size
433
+ for i = 0 , level do
433
434
local highlight = nil
435
+ local char = marker_start_level ~= 0 and " " or " "
436
+ local separator = i < marker_start_level and " " or " "
437
+ local additional_spaces = string.rep (" " , math.max (0 , indent_size - 2 ))
438
+
439
+ if marker_start_level ~= 0 then
440
+ if i <= 0 then
441
+ additional_spaces = " "
442
+ end
443
+ if level == 0 then
444
+ char = " "
445
+ separator = " "
446
+ additional_spaces = " "
447
+ end
448
+ end
434
449
435
- if i > start_level - 1 and not skip_marker [i ] or i == level then
436
- spaces_count = spaces_count - 1
437
- char = indent_marker
450
+ if indent_size == 1 then
451
+ separator = " "
452
+ additional_spaces = " "
453
+ end
454
+
455
+ if marker_start_level >= 2 and i > 0 then
456
+ char = " "
457
+ separator = " "
458
+ end
459
+
460
+ if i >= marker_start_level then
438
461
highlight = marker_highlight
439
462
if i == level then
440
- local expander = get_expander ()
441
- if expander then
442
- char = expander
443
- highlight = expander_highlight
444
- elseif node .is_last_child then
463
+ if node .is_last_child then
445
464
char = last_indent_marker
446
- spaces_count = spaces_count - (vim .api .nvim_strwidth (last_indent_marker ) - 1 )
465
+ -- proof of concept for extended markers
466
+ -- if indent_size > 2 then
467
+ -- separator = "─"
468
+ -- end
469
+ else
470
+ char = indent_marker
447
471
end
472
+ elseif not skip_marker [i ] then
473
+ char = indent_marker
474
+ end
475
+ end
476
+
477
+ if i == level and i >= 1 then
478
+ local expander = get_expander ()
479
+ if expander then
480
+ char = expander
481
+ highlight = expander_highlight
448
482
end
449
483
end
450
484
451
485
table.insert (indent , {
452
- text = char .. string.rep ( " " , spaces_count ) ,
486
+ text = char .. separator .. additional_spaces ,
453
487
highlight = highlight ,
454
488
no_next_padding = true ,
455
489
})
@@ -458,7 +492,7 @@ M.indent = function(config, node, state)
458
492
return indent
459
493
end
460
494
461
- local get_header = function (state , label , size )
495
+ local get_header = function (state , label , size )
462
496
if state .sort and state .sort .label == label then
463
497
local icon = state .sort .direction == 1 and " ▲" or " ▼"
464
498
size = size - 2
@@ -467,12 +501,12 @@ local get_header = function (state, label, size)
467
501
return string.format (" %" .. size .. " s " , label )
468
502
end
469
503
470
- M .file_size = function (config , node , state )
504
+ M .file_size = function (config , node , state )
471
505
-- Root node gets column labels
472
506
if node :get_depth () == 1 then
473
507
return {
474
508
text = get_header (state , " Size" , 12 ),
475
- highlight = highlights .FILE_STATS_HEADER
509
+ highlight = highlights .FILE_STATS_HEADER ,
476
510
}
477
511
end
478
512
@@ -490,7 +524,7 @@ M.file_size = function (config, node, state)
490
524
491
525
return {
492
526
text = string.format (" %12s " , text ),
493
- highlight = config .highlight or highlights .FILE_STATS
527
+ highlight = config .highlight or highlights .FILE_STATS ,
494
528
}
495
529
end
496
530
@@ -505,7 +539,7 @@ local file_time = function(config, node, state, stat_field)
505
539
end
506
540
return {
507
541
text = get_header (state , label , 20 ),
508
- highlight = highlights .FILE_STATS_HEADER
542
+ highlight = highlights .FILE_STATS_HEADER ,
509
543
}
510
544
end
511
545
@@ -515,7 +549,7 @@ local file_time = function(config, node, state, stat_field)
515
549
local display = seconds and os.date (" %Y-%m-%d %I:%M %p" , seconds ) or " -"
516
550
return {
517
551
text = string.format (" %20s " , display ),
518
- highlight = config .highlight or highlights .FILE_STATS
552
+ highlight = config .highlight or highlights .FILE_STATS ,
519
553
}
520
554
end
521
555
@@ -538,19 +572,19 @@ M.symlink_target = function(config, node, state)
538
572
end
539
573
end
540
574
541
- M .type = function (config , node , state )
575
+ M .type = function (config , node , state )
542
576
local text = node .ext or node .type
543
577
-- Root node gets column labels
544
578
if node :get_depth () == 1 then
545
579
return {
546
580
text = get_header (state , " Type" , 10 ),
547
- highlight = highlights .FILE_STATS_HEADER
581
+ highlight = highlights .FILE_STATS_HEADER ,
548
582
}
549
583
end
550
584
551
585
return {
552
586
text = string.format (" %10s " , text ),
553
- highlight = highlights .FILE_STATS
587
+ highlight = highlights .FILE_STATS ,
554
588
}
555
589
end
556
590
0 commit comments