Skip to content

Commit 3a08fa2

Browse files
committed
docs(#3088): extract api/events.lua
1 parent ac9424a commit 3a08fa2

5 files changed

Lines changed: 39 additions & 1 deletion

File tree

doc/nvim-tree-lua.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,6 +2862,17 @@ Class: Config.Log *nvim-tree-config-log*
28622862

28632863

28642864

2865+
==============================================================================
2866+
Lua module: nvim_tree.api.events *nvim-tree-api-events*
2867+
2868+
subscribe({event_type}, {callback}) *nvim_tree.api.events.subscribe()*
2869+
Register a handler for an event, see |nvim-tree-events|.
2870+
2871+
Parameters: ~
2872+
• {event_type} (`string`) |nvim_tree_events_kind|
2873+
{callback} (`fun(payload: table?)`)
2874+
2875+
28652876
==============================================================================
28662877
Lua module: nvim_tree.api.filter *nvim-tree-api-filter*
28672878

lua/nvim-tree/api.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,14 @@ end)
354354

355355
-- Api.git.reload = wrap_explorer("reload_git")
356356

357+
function Api.hydrate_events(ev)
358+
Api.events = ev
359+
357360
Api.events.subscribe = events.subscribe
358361
Api.events.Event = events.Event
359362

363+
end
364+
360365
function Api.hydrate_filter(filter)
361366
Api.filter = filter
362367

lua/nvim-tree/api/events.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---@meta
2+
3+
local events = require("nvim-tree.events")
4+
5+
local nvim_tree = { api = { events = {} } }
6+
7+
---
8+
---Register a handler for an event, see [nvim-tree-events].
9+
---
10+
---@param event_type string [nvim_tree_events_kind]
11+
---@param callback fun(payload: table?)
12+
function nvim_tree.api.events.subscribe(event_type, callback) end
13+
14+
15+
nvim_tree.api.events.Event = events.Event
16+
17+
18+
require("nvim-tree.api").hydrate_events(nvim_tree.api.events)
19+
20+
return nvim_tree.api.events

lua/nvim-tree/api/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
return {
2+
events = require("nvim-tree.api.events"),
23
filter = require("nvim-tree.api.filter"),
34
health = require("nvim-tree.api.health"),
45
map = require("nvim-tree.api.map"),

scripts/gen_vimdoc_config.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ local modules = {
3131
{ helptag = "nvim-tree-config-experimental", title = "Class: Config.Experimental", path = "./lua/nvim_tree/_meta/config/experimental.lua", },
3232
{ helptag = "nvim-tree-config-log", title = "Class: Config.Log", path = "./lua/nvim_tree/_meta/config/log.lua", },
3333

34+
{ helptag = "nvim-tree-api-events", title = "Lua module: nvim_tree.api.events", path = "./lua/nvim_tree/api/events.lua", },
3435
{ helptag = "nvim-tree-api-filter", title = "Lua module: nvim_tree.api.filter", path = "./lua/nvim_tree/api/filter.lua", },
3536
{ helptag = "nvim-tree-api-health", title = "Lua module: nvim_tree.api.health", path = "./lua/nvim_tree/api/health.lua", },
3637
{ helptag = "nvim-tree-api-map", title = "Lua module: nvim_tree.api.map", path = "./lua/nvim_tree/api/map.lua", },
37-
{ helptag = "nvim-tree-api-marks", title = "Lua module: nvim_tree.api.marks", path = "./lua/nvim_tree/api/marks.lua", },
38+
{ helptag = "nvim-tree-api-marks", title = "Lua module: nvim_tree.api.marks", path = "./lua/nvim_tree/api/marks.lua", },
3839
{ helptag = "nvim-tree-api-tree", title = "Lua module: nvim_tree.api.tree", path = "./lua/nvim_tree/api/tree.lua", },
3940
}
4041

0 commit comments

Comments
 (0)