Skip to content

Commit 1be4d91

Browse files
committed
feat: implement example for custom file stats
1 parent e2ffa39 commit 1be4d91

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lua/example/init.lua

+34
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local vim = vim
55
local renderer = require("neo-tree.ui.renderer")
66
local manager = require("neo-tree.sources.manager")
77
local events = require("neo-tree.events")
8+
local utils = require("neo-tree.utils")
89

910
local M = {
1011
-- This is the name our source will be referred to as
@@ -14,6 +15,39 @@ local M = {
1415
display_name = "留Example"
1516
}
1617

18+
19+
---Returns the stats for the given node in the same format as `vim.loop.fs_stat`
20+
---@param node table NuiNode to get the stats for.
21+
--- Example return value:
22+
---
23+
--- {
24+
--- birthtime {
25+
--- sec = 1692617750 -- seconds since epoch
26+
--- },
27+
--- mtime = {
28+
--- sec = 1692617750 -- seconds since epoch
29+
--- },
30+
--- size = 11453, -- size in bytes
31+
--- }
32+
--
33+
---@class StatTime
34+
--- @field sec number
35+
---
36+
---@class StatTable
37+
--- @field birthtime StatTime
38+
--- @field mtime StatTime
39+
--- @field size number
40+
---
41+
--- @return StatTable Stats for the given node.
42+
M.get_node_stat = function(node)
43+
-- This is just fake data, you'll want to replace this with something real
44+
return {
45+
birthtime = { sec = 1692617750 },
46+
mtime = { sec = 1692617750 },
47+
size = 11453,
48+
}
49+
end
50+
1751
---Navigate to the given path.
1852
---@param path string Path to navigate to. If empty, will navigate to the cwd.
1953
M.navigate = function(state, path)

0 commit comments

Comments
 (0)