Skip to content

Commit fe980ba

Browse files
authored
feat(api): api.tree.find_file feature parity with open/toggle, convert all commands to API, document commands (#2039)
* fix(#1212): API find file feature parity * fix(#2011): API find file feature parity * fix(#2011): API find file feature parity * fix(#2011): API find file feature parity * fix(#2011): API find file feature parity * fix(#2011): API find file feature parity * fix(#2011): API find file feature parity * fix(#2011): API find file feature parity
1 parent f0a1c6a commit fe980ba

File tree

9 files changed

+317
-173
lines changed

9 files changed

+317
-173
lines changed

doc/nvim-tree-lua.txt

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,35 @@ Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file.
103103

104104
*:NvimTreeOpen*
105105

106-
opens the tree. Takes an optional path argument.
106+
Opens the tree. See |nvim-tree.api.tree.open()|
107+
108+
Calls: `api.tree.open({ path = "<arg>" })`
107109

108110
*:NvimTreeClose*
109111

110-
closes the tree
112+
Closes the tree. See |nvim-tree.api.tree.close()|
113+
114+
Calls: `api.tree.close()`
111115

112116
*:NvimTreeToggle*
113117

114-
open or close the tree. Takes an optional path argument.
118+
Open or close the tree. See |nvim-tree.api.tree.toggle()|
119+
120+
Calls: `api.tree.toggle({ path = "<arg>" })`
115121

116122
*:NvimTreeFocus*
117123

118-
open the tree if it is closed, and then focus on the tree
124+
Open the tree if it is closed, and then focus on the tree.
125+
126+
See |nvim-tree.api.tree.toggle()|
127+
128+
Calls: `api.tree.focus()`
119129

120130
*:NvimTreeRefresh*
121131

122-
refresh the tree
132+
Refresh the tree. See |nvim-tree.api.tree.reload()|
133+
134+
Calls: `api.tree.reload()`
123135

124136
*:NvimTreeFindFile*
125137

@@ -131,6 +143,10 @@ Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file.
131143

132144
Invoke with a bang `:NvimTreeFindFile!` to update the root.
133145

146+
See |nvim-tree.api.tree.find_file()|
147+
148+
Calls: `api.tree.find_file { open = true, update_root = <bang> }`
149+
134150
*:NvimTreeFindFileToggle*
135151

136152
close the tree or change the cursor in the tree for the current bufname,
@@ -139,10 +155,18 @@ Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file.
139155

140156
Invoke with a bang `:NvimTreeFindFileToggle!` to update the root.
141157

158+
See |nvim-tree.api.tree.toggle()|
159+
160+
Calls: `api.tree.toggle { find_file = true, focus = true, path = "<arg>", update_root = <bang> }`
161+
142162
*:NvimTreeClipboard*
143163

144164
Print clipboard content for both cut and copy
145165

166+
See |nvim-tree.api.fs.print_clipboard()|
167+
168+
Calls: `api.fs.print_clipboard()`
169+
146170
*:NvimTreeResize*
147171

148172
Resize the NvimTree window to the given size. Example: `:NvimTreeResize 50`
@@ -155,11 +179,19 @@ Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file.
155179

156180
Collapses the nvim-tree recursively.
157181

182+
See |nvim-tree.api.tree.collapse_all()|
183+
184+
Calls: `api.tree.collapse_all(false)`
185+
158186
*:NvimTreeCollapseKeepBuffers*
159187

160188
Collapses the nvim-tree recursively, but keep the directories open, which are
161189
used in an open buffer.
162190

191+
See |nvim-tree.api.tree.collapse_all()|
192+
193+
Calls: `api.tree.collapse_all(true)`
194+
163195
*:NvimTreeGenerateOnAttach*
164196

165197
Creates and opens a new file `/tmp/my_on_attach.lua` containing an
@@ -1266,7 +1298,8 @@ api.tree.open({opts}) *nvim-tree.api.tree.open()*
12661298
{path} (string) root directory for the tree
12671299
• {current_window} (boolean, false) open the tree in the current window
12681300
• {find_file} (boolean, false) find the current buffer
1269-
• {update_root} (boolean, false) see |nvim-tree.update_focused_file.update_root|
1301+
• {update_root} (boolean, false) requires {find_file}, see
1302+
|nvim-tree.update_focused_file.update_root|
12701303

12711304
api.tree.toggle({opts}) *nvim-tree.api.tree.toggle()*
12721305
Open or close the tree.
@@ -1278,7 +1311,8 @@ api.tree.toggle({opts}) *nvim-tree.api.tree.toggle()*
12781311
{path} (string) root directory for the tree
12791312
• {current_window} (boolean, false) open the tree in the current window
12801313
• {find_file} (boolean, false) find the current buffer
1281-
• {update_root} (boolean, false) see |nvim-tree.update_focused_file.update_root|
1314+
• {update_root} (boolean, false) requires {find_file}, see
1315+
|nvim-tree.update_focused_file.update_root|
12821316
{focus} (boolean, true) focus the tree when opening
12831317

12841318
api.tree.close() *nvim-tree.api.tree.close()*
@@ -1329,11 +1363,19 @@ api.tree.get_nodes() *nvim-tree.api.tree.get_nodes()*
13291363
Return: ~
13301364
table of nodes
13311365

1332-
api.tree.find_file({path}) *nvim-tree.api.tree.find_file()*
1333-
Find and focus a file or folder in the tree.
1366+
api.tree.find_file({opts}) *nvim-tree.api.tree.find_file()*
1367+
Find and focus a file or folder in the tree. Finds current buffer unless
1368+
otherwise specified.
13341369

13351370
Parameters: ~
1336-
{path} (string) absolute path
1371+
{opts} (table) optional parameters with boolean defaults
1372+
1373+
Options: ~
1374+
{buf} (string|number) absolute/relative path OR bufnr to find
1375+
{open} (boolean, false) open the tree
1376+
• {current_window} (boolean, false) requires {open}, open in the current window
1377+
• {update_root} (boolean, false) see |nvim-tree.update_focused_file.update_root|
1378+
{focus} (boolean, false) focus the tree
13371379

13381380
api.tree.search_node() *nvim-tree.api.tree.search_node()*
13391381
Open the search dialogue as per the search_node action.

0 commit comments

Comments
 (0)