Skip to content

Commit 7634f72

Browse files
committed
doc(#2934): add nvim_tree.api classes to help
1 parent fbfb09f commit 7634f72

2 files changed

Lines changed: 141 additions & 26 deletions

File tree

doc/nvim-tree-lua.txt

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
*nvim-tree.lua* A File Explorer For Neovim Written In Lua
1+
*nvim-tree* A File Explorer For Neovim Written In Lua
22

33
Author: Yazdani Kiyan
44

55
==============================================================================
6-
CONTENTS *nvim-tree*
6+
CONTENTS
77

88
1. Introduction |nvim-tree-introduction|
99
2. Quickstart |nvim-tree-quickstart|
@@ -3445,7 +3445,7 @@ highlight group is not, hard linking as follows: >
34453445
|nvim-tree-api.tree.winid()|
34463446

34473447
==============================================================================
3448-
Lua module: nvim_tree.Config *nvim-tree-config*
3448+
Lua module: nvim_tree *nvim-tree-module*
34493449

34503450
*nvim_tree.Config*
34513451

@@ -4262,6 +4262,96 @@ Lua module: nvim_tree.Config *nvim-tree-config*
42624262

42634263

42644264

4265+
==============================================================================
4266+
Lua module: nvim_tree.api *nvim-tree-api*
4267+
4268+
*nvim_tree.api.CollapseOpts*
4269+
4270+
Fields: ~
4271+
• {keep_buffers}? (`boolean`) do not collapse nodes with open buffers
4272+
4273+
*nvim_tree.api.NodeBufferOpts*
4274+
4275+
Fields: ~
4276+
{force}? (`boolean`) delete/wipe even if buffer is modified, default
4277+
false
4278+
4279+
*nvim_tree.api.NodeEditOpts*
4280+
4281+
Fields: ~
4282+
• {quit_on_open}? (`boolean`) quits the tree when opening the file
4283+
{focus}? (`boolean`) keep focus in the tree when opening the
4284+
file
4285+
4286+
*nvim_tree.api.TreeExpandOpts*
4287+
4288+
Fields: ~
4289+
• {expand_until}? (`fun(expansion_count: integer, node: Node): boolean`)
4290+
Return true if node should be expanded.
4291+
expansion_count is the total number of folders
4292+
expanded.
4293+
4294+
*nvim_tree.api.TreeFindFileOpts*
4295+
4296+
Fields: ~
4297+
{buf}? (`string|number`) absolute/relative path OR bufnr
4298+
to find
4299+
{open}? (`boolean`) open the tree if necessary
4300+
• {current_window}? (`boolean`) requires open, open in the current
4301+
window
4302+
{winid}? (`number`) open the tree in the specified |winid|,
4303+
overrides current_window
4304+
• {update_root}? (`boolean`) see
4305+
|nvim-tree.update_focused_file.update_root|
4306+
{focus}? (`boolean`) focus the tree
4307+
4308+
*nvim_tree.api.TreeIsVisibleOpts*
4309+
4310+
Fields: ~
4311+
{tabpage}? (`number`) as per |nvim_get_current_tabpage()|
4312+
• {any_tabpage}? (`boolean`) visible on any tab, default false
4313+
4314+
*nvim_tree.api.TreeOpenOpts*
4315+
4316+
Fields: ~
4317+
{path}? (`string`) root directory for the tree
4318+
• {current_window}? (`boolean`) open the tree in the current window
4319+
{winid}? (`number`) open the tree in the specified winid,
4320+
overrides current_window
4321+
• {find_file}? (`boolean`) find the current buffer
4322+
• {update_root}? (`boolean`) requires find_file, see
4323+
|nvim-tree.update_focused_file.update_root|
4324+
{focus}? (`boolean`) focus the tree when opening, default
4325+
true
4326+
4327+
*nvim_tree.api.TreeResizeOpts*
4328+
4329+
Fields: ~
4330+
{width}? (`string|function|number|table`) new
4331+
|nvim-tree.view.width| value
4332+
{absolute}? (`number`) set the width
4333+
{relative}? (`number`) relative width adjustment
4334+
4335+
*nvim_tree.api.TreeToggleOpts*
4336+
4337+
Fields: ~
4338+
{path}? (`string`) root directory for the tree
4339+
• {current_window}? (`boolean`) open the tree in the current window
4340+
{winid}? (`number`) open the tree in the specified |winid|,
4341+
overrides current_window
4342+
• {find_file}? (`boolean`) find the current buffer
4343+
• {update_root}? (`boolean`) requires find_file, see
4344+
|nvim-tree.update_focused_file.update_root|
4345+
{focus}? (`boolean`) focus the tree when opening, default
4346+
true
4347+
4348+
*nvim_tree.api.TreeWinIdOpts*
4349+
4350+
Fields: ~
4351+
{tabpage}? (`number`) tabpage, 0 or nil for current, default nil
4352+
4353+
4354+
42654355
==============================================================================
42664356
Lua module: nvim_tree.api.decorator *nvim-tree-api-decorator*
42674357

scripts/gen_vimdoc_config.lua

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,61 @@
11
---@diagnostic disable: undefined-doc-name
22

3+
-- module name is derived as the file name with the first letter capitalised
4+
local modules = {
5+
Api = {
6+
order = 2,
7+
helptag = "nvim-tree-api",
8+
title = "Lua module: nvim_tree.api",
9+
path = "lua/nvim-tree/_meta/api.lua",
10+
},
11+
Config = {
12+
order = 1,
13+
helptag = "nvim-tree-module",
14+
title = "Lua module: nvim_tree",
15+
path = "lua/nvim-tree/_meta/config.lua",
16+
},
17+
Api_decorator = {
18+
order = 3,
19+
helptag = "nvim-tree-api-decorator",
20+
title = "Lua module: nvim_tree.api.decorator",
21+
path = "lua/nvim-tree/_meta/api_decorator.lua",
22+
},
23+
}
24+
325
--- @type table<string,nvim.gen_vimdoc.Config>
426
local config = {
527
decorator = {
628
filename = "nvim-tree-lua.txt",
7-
-- filename = "decorator.txt",
8-
section_order = {
9-
"config.lua",
10-
"api_decorator.lua",
11-
},
12-
files = {
13-
-- module is derived soley from the file name, first letter capitalised
14-
"lua/nvim-tree/_meta/api_decorator.lua",
15-
"lua/nvim-tree/_meta/config.lua",
16-
},
17-
section_fmt = function(name)
18-
if name == "Config" then
19-
return "Lua module: nvim_tree.Config"
20-
elseif name == "Api_decorator" then
21-
return "Lua module: nvim_tree.api.decorator"
29+
30+
-- file name sets order
31+
section_order = (function()
32+
local ret = {}
33+
for _, c in pairs(modules) do
34+
ret[c.order] = vim.fn.fnamemodify(c.path, ":t")
35+
end
36+
return ret
37+
end)(),
38+
39+
-- full path, will be ordered by section_order
40+
files = (function()
41+
local ret = {}
42+
for _, c in pairs(modules) do
43+
table.insert(ret, c.path)
2244
end
23-
error(string.format("unknown module %s passed to section_fmt", name))
45+
return ret
46+
end)(),
47+
48+
-- section title
49+
section_fmt = function(name)
50+
return modules[name] and modules[name].title or error(string.format("unknown module %s passed to section", name))
2451
end,
52+
53+
-- section's help tag
2554
helptag_fmt = function(name)
26-
-- used to locate the first section only, others will be rendered after
27-
if name == "Config" then
28-
return "nvim-tree-config"
29-
elseif name == "Api_decorator" then
30-
return "nvim-tree-api-decorator"
31-
end
32-
error(string.format("unknown module %s passed to helptag_fmt", name))
55+
return modules[name] and modules[name].helptag or error(string.format("unknown module %s passed to helptag_fmt", name))
3356
end,
57+
58+
-- class/function's help tag
3459
fn_helptag_fmt = function(fun)
3560
-- Modified copy of fn_helptag_fmt_common
3661
-- Uses fully qualified class name in the tag for methods.

0 commit comments

Comments
 (0)