@@ -324,18 +324,42 @@ M.get_inner_win_width = function(winid)
324324 end
325325end
326326
327+ local stat_providers = {
328+ default = function (node )
329+ return vim .loop .fs_stat (node .path )
330+ end ,
331+ }
332+
327333--- Gets the statics for a node in the file system. The `stat` object will be cached
328334--- for the lifetime of the node.
335+ ---
329336--- @param node table The Nui TreeNode node to get the stats for.
330- --- @return table stat The stat object from libuv.
337+ --- @return StatTable | table
338+ ---
339+ --- @class StatTime
340+ --- @field sec number
341+ ---
342+ --- @class StatTable
343+ --- @field birthtime StatTime
344+ --- @field mtime StatTime
345+ --- @field size number
331346M .get_stat = function (node )
332347 if node .stat == nil then
333- local success , stat = pcall (vim .loop .fs_stat , node .path )
348+ local provider = stat_providers [node .stat_provider or " default" ]
349+ local success , stat = pcall (provider , node )
334350 node .stat = success and stat or {}
335351 end
336352 return node .stat
337353end
338354
355+ --- Register a function to provide stats for a node.
356+ --- @param name string The name of the stat provider.
357+ --- @param func function The function to call to get the stats.
358+ M .register_stat_provider = function (name , func )
359+ stat_providers [name ] = func
360+ log .debug (" Registered stat provider" , name )
361+ end
362+
339363--- Handles null coalescing into a table at any depth.
340364--- @param sourceObject table The table to get a vlue from.
341365--- @param valuePath string The path to the value to get.
0 commit comments