Skip to content

Commit 3c093d4

Browse files
committed
doc format and example clarification
1 parent b67209a commit 3c093d4

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

doc/nvim-tree-lua.txt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,20 +1817,25 @@ tree.expand_all({opts}) *nvim-tree-api.tree.expand_all()*
18171817

18181818
Options: ~
18191819
• {expand_until} (fun(expansion_count: integer, node: Node): boolean)
1820-
A function returning boolean that
1821-
specifies terminating condition for node/tree expansion. If not
1822-
provided the function that expands recursively entire node/tree will be
1823-
used.
1824-
Example: >
18251820

1826-
-- expand only 5 levels deep
1827-
local function my_expand(expansion_count, node)
1828-
local should_halt = expansion_count >= 5
1829-
return not should_halt
1830-
end
1821+
A function returning boolean that specifies terminating condition
1822+
for node/tree expansion. If not provided the function that expands
1823+
recursively entire node/tree will be used.
18311824

1832-
-- on_attach
1833-
vim.keymap.set('n', 'Z', api.tree.expand_all(node, { expand_until = my_expand }))
1825+
Example: >
1826+
-- expand only 5 levels deep
1827+
local function my_expand_until(expansion_count, node)
1828+
print("my_expand_until " .. expansion_count .. " " .. tostring(node and node.absolute_path))
1829+
local should_halt = expansion_count >= 5
1830+
return not should_halt
1831+
end
1832+
1833+
local function my_expand_all()
1834+
api.tree.expand_all(nil, { expand_until = my_expand_until })
1835+
end
1836+
1837+
-- on_attach
1838+
vim.keymap.set("n", "Z", my_expand_all, opts("My Expand All"))
18341839
<
18351840
*nvim-tree-api.tree.toggle_enable_filters()*
18361841
tree.toggle_enable_filters()

0 commit comments

Comments
 (0)