Skip to content

Commit 75c482b

Browse files
committed
feat: update custom stat_provider example
1 parent 1be4d91 commit 75c482b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lua/example/commands.lua

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
--This file should contain all commands meant to be used by mappings.
22
local cc = require("neo-tree.sources.common.commands")
3+
local manager = require("neo-tree.sources.manager")
34

45
local vim = vim
56

@@ -13,6 +14,10 @@ M.example_command = function(state)
1314
print(string.format("example_command: id=%s, name=%s", id, name))
1415
end
1516

17+
M.refresh = function(state)
18+
manager.refresh("example", state)
19+
end
20+
1621
M.show_debug_info = function(state)
1722
print(vim.inspect(state))
1823
end

lua/example/init.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,26 @@ M.navigate = function(state, path)
6262
id = "1",
6363
name = "root",
6464
type = "directory",
65+
stat_provider = "example-custom",
6566
children = {
6667
{
6768
id = "1.1",
6869
name = "child1",
6970
type = "directory",
71+
stat_provider = "example-custom",
7072
children = {
7173
{
7274
id = "1.1.1",
7375
name = "child1.1 (you'll need a custom renderer to display this properly)",
7476
type = "custom",
77+
stat_provider = "example-custom",
7578
extra = { custom_text = "HI!" },
7679
},
7780
{
7881
id = "1.1.2",
7982
name = "child1.2",
80-
type = "file"
83+
type = "file",
84+
stat_provider = "example-custom",
8185
},
8286
},
8387
},
@@ -91,6 +95,8 @@ end
9195
---@param config table Configuration table containing any keys that the user
9296
--wants to change from the defaults. May be empty to accept default values.
9397
M.setup = function(config, global_config)
98+
-- redister or custom stat provider to override the default libuv one
99+
require("neo-tree.utils").register_stat_provider("example-custom", M.get_node_stat)
94100
-- You most likely want to use this function to subscribe to events
95101
if config.use_libuv_file_watcher then
96102
manager.subscribe(M.name, {

0 commit comments

Comments
 (0)