@@ -1817,20 +1817,25 @@ tree.expand_all({opts}) *nvim-tree-api.tree.expand_all()*
1817
1817
1818
1818
Options: ~
1819
1819
• {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: >
1825
1820
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.
1831
1824
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"))
1834
1839
<
1835
1840
*nvim-tree-api.tree.toggle_enable_filters()*
1836
1841
tree.toggle_enable_filters()
0 commit comments