11local utils = require " nvim-tree.utils"
22local core = require " nvim-tree.core"
3+ local notify = require " nvim-tree.notify"
34
45local git = require " nvim-tree.renderer.components.git"
56local pad = require " nvim-tree.renderer.components.padding"
@@ -105,6 +106,13 @@ function Builder:configure_symlink_destination(show)
105106 return self
106107end
107108
109+ function Builder :configure_group_name_modifier (group_name_modifier )
110+ if type (group_name_modifier ) == " function" then
111+ self .group_name_modifier = group_name_modifier
112+ end
113+ return self
114+ end
115+
108116function Builder :_insert_highlight (group , start , end_ )
109117 table.insert (self .highlights , { group , self .index , start , end_ or - 1 })
110118end
@@ -113,14 +121,24 @@ function Builder:_insert_line(line)
113121 table.insert (self .lines , line )
114122end
115123
116- local function get_folder_name (node )
124+ function Builder : _get_folder_name (node )
117125 local name = node .name
118126 local next = node .group_next
119127 while next do
120128 name = name .. " /" .. next .name
121129 next = next .group_next
122130 end
123- return name
131+
132+ if node .group_next and self .group_name_modifier then
133+ local new_name = self .group_name_modifier (name )
134+ if type (new_name ) == " string" then
135+ name = new_name
136+ else
137+ notify .warn (string.format (" Invalid return type for field renderer.group_empty. Expected string, got %s" , type (new_name )))
138+ end
139+ end
140+
141+ return name .. self .trailing_slash
124142end
125143
126144--- @class HighlightedString
152170function Builder :_build_folder (node )
153171 local has_children = # node .nodes ~= 0 or node .has_children
154172 local icon , icon_hl = icons .get_folder_icon (node , has_children )
155- local foldername = get_folder_name (node ) .. self . trailing_slash
173+ local foldername = self : _get_folder_name (node )
156174
157175 if # icon > 0 and icon_hl == nil then
158176 if node .open then
0 commit comments