@@ -50,47 +50,6 @@ local PICTURE_MAP = {
50
50
--- @field private hidden_display fun (node : Node ): string | nil
51
51
local Builder = {}
52
52
53
- --- @param opts table
54
- --- @return fun ( node : Node ): string | nil
55
- local setup_hidden_display_function = function (opts )
56
- local hidden_display = opts .renderer .hidden_display
57
- -- options are already validated, so ´hidden_display´ can ONLY be `string` or `function` if type(hidden_display) == "string" then
58
- if type (hidden_display ) == " string" then
59
- if hidden_display == " none" then
60
- return function ()
61
- return nil
62
- end
63
- elseif hidden_display == " simple" then
64
- return function (hidden_stats )
65
- return utils .default_format_hidden_count (hidden_stats , true )
66
- end
67
- else -- "all"
68
- return function (hidden_stats )
69
- return utils .default_format_hidden_count (hidden_stats , false )
70
- end
71
- end
72
- else -- "function
73
- return function (hidden_stats )
74
- -- In case of missing field such as live_filter we zero it, otherwise keep field as is
75
- hidden_stats = vim .tbl_deep_extend (" force" , {
76
- live_filter = 0 ,
77
- git = 0 ,
78
- buf = 0 ,
79
- dotfile = 0 ,
80
- custom = 0 ,
81
- bookmark = 0 ,
82
- }, hidden_stats or {})
83
-
84
- local ok , result = pcall (hidden_display , hidden_stats )
85
- if not ok then
86
- notify .warn " Problem occurred in the function ``opts.renderer.hidden_display`` see nvim-tree.renderer.hidden_display on :h nvim-tree"
87
- return nil
88
- end
89
- return result
90
- end
91
- end
92
- end
93
-
94
53
--- @param opts table user options
95
54
--- @param explorer Explorer
96
55
--- @return Builder
@@ -120,7 +79,7 @@ function Builder:new(opts, explorer)
120
79
DecoratorOpened :new (opts , explorer ),
121
80
DecoratorGit :new (opts , explorer ),
122
81
},
123
- hidden_display = setup_hidden_display_function (opts ),
82
+ hidden_display = Builder : setup_hidden_display_function (opts ),
124
83
}
125
84
126
85
setmetatable (o , { __index = self })
@@ -531,4 +490,46 @@ function Builder:build()
531
490
return self
532
491
end
533
492
493
+ --- TODO refactor back to function; this was left here to reduce PR noise
494
+ --- @param opts table
495
+ --- @return fun ( node : Node ): string | nil
496
+ function Builder :setup_hidden_display_function (opts )
497
+ local hidden_display = opts .renderer .hidden_display
498
+ -- options are already validated, so ´hidden_display´ can ONLY be `string` or `function` if type(hidden_display) == "string" then
499
+ if type (hidden_display ) == " string" then
500
+ if hidden_display == " none" then
501
+ return function ()
502
+ return nil
503
+ end
504
+ elseif hidden_display == " simple" then
505
+ return function (hidden_stats )
506
+ return utils .default_format_hidden_count (hidden_stats , true )
507
+ end
508
+ else -- "all"
509
+ return function (hidden_stats )
510
+ return utils .default_format_hidden_count (hidden_stats , false )
511
+ end
512
+ end
513
+ else -- "function
514
+ return function (hidden_stats )
515
+ -- In case of missing field such as live_filter we zero it, otherwise keep field as is
516
+ hidden_stats = vim .tbl_deep_extend (" force" , {
517
+ live_filter = 0 ,
518
+ git = 0 ,
519
+ buf = 0 ,
520
+ dotfile = 0 ,
521
+ custom = 0 ,
522
+ bookmark = 0 ,
523
+ }, hidden_stats or {})
524
+
525
+ local ok , result = pcall (hidden_display , hidden_stats )
526
+ if not ok then
527
+ notify .warn " Problem occurred in the function ``opts.renderer.hidden_display`` see nvim-tree.renderer.hidden_display on :h nvim-tree"
528
+ return nil
529
+ end
530
+ return result
531
+ end
532
+ end
533
+ end
534
+
534
535
return Builder
0 commit comments