Skip to content

Commit 6939619

Browse files
committed
docs(#3088): extract fs.copy, fix api node param optionality, move legacy api to legacy.lua
1 parent 9d4a117 commit 6939619

10 files changed

Lines changed: 142 additions & 123 deletions

File tree

doc/nvim-tree-lua.txt

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,36 +2457,6 @@ API: fs *nvim-tree-api-fs*
24572457
clear_clipboard() *nvim_tree.api.fs.clear_clipboard()*
24582458
Clear the nvim-tree clipboard.
24592459

2460-
copy.absolute_path({node}) *nvim_tree.api.fs.copy.absolute_path()*
2461-
Copy the absolute path to the system clipboard.
2462-
2463-
Parameters: ~
2464-
{node} (`nvim_tree.api.Node`)
2465-
2466-
copy.basename({node}) *nvim_tree.api.fs.copy.basename()*
2467-
Copy the name with extension omitted to the system clipboard.
2468-
2469-
Parameters: ~
2470-
{node} (`nvim_tree.api.Node`)
2471-
2472-
copy.filename({node}) *nvim_tree.api.fs.copy.filename()*
2473-
Copy the name to the system clipboard.
2474-
2475-
Parameters: ~
2476-
{node} (`nvim_tree.api.Node`)
2477-
2478-
copy.node({node}) *nvim_tree.api.fs.copy.node()*
2479-
Copy to the nvim-tree clipboard.
2480-
2481-
Parameters: ~
2482-
{node} (`nvim_tree.api.Node`)
2483-
2484-
copy.relative_path({node}) *nvim_tree.api.fs.copy.relative_path()*
2485-
Copy the path relative to the tree root to the system clipboard.
2486-
2487-
Parameters: ~
2488-
{node} (`nvim_tree.api.Node`)
2489-
24902460
create({node}) *nvim_tree.api.fs.create()*
24912461
Prompt to create a file or directory.
24922462

@@ -2497,21 +2467,21 @@ create({node}) *nvim_tree.api.fs.create()*
24972467
Multiple directories/files may be created e.g. `"foo/bar/baz"`
24982468

24992469
Parameters: ~
2500-
{node} (`nvim_tree.api.Node`)
2470+
{node} (`nvim_tree.api.Node?`)
25012471

25022472
cut({node}) *nvim_tree.api.fs.cut()*
25032473
Cut to the nvim-tree clipboard.
25042474

25052475
Parameters: ~
2506-
{node} (`nvim_tree.api.Node`)
2476+
{node} (`nvim_tree.api.Node?`)
25072477

25082478
paste({node}) *nvim_tree.api.fs.paste()*
25092479
Paste from the nvim-tree clipboard.
25102480

25112481
If {node} is a file it will pasted in the parent directory.
25122482

25132483
Parameters: ~
2514-
{node} (`nvim_tree.api.Node`)
2484+
{node} (`nvim_tree.api.Node?`)
25152485

25162486
print_clipboard() *nvim_tree.api.fs.print_clipboard()*
25172487
Print the contents of the nvim-tree clipboard.
@@ -2520,43 +2490,77 @@ remove({node}) *nvim_tree.api.fs.remove()*
25202490
Delete from the file system.
25212491

25222492
Parameters: ~
2523-
{node} (`nvim_tree.api.Node`)
2493+
{node} (`nvim_tree.api.Node?`)
25242494

25252495
rename({node}) *nvim_tree.api.fs.rename()*
25262496
Prompt to rename by name.
25272497

25282498
Parameters: ~
2529-
{node} (`nvim_tree.api.Node`)
2499+
{node} (`nvim_tree.api.Node?`)
25302500

25312501
rename_basename({node}) *nvim_tree.api.fs.rename_basename()*
25322502
Prompt to rename by name with extension omitted.
25332503

25342504
Parameters: ~
2535-
{node} (`nvim_tree.api.Node`)
2505+
{node} (`nvim_tree.api.Node?`)
25362506

25372507
rename_full({node}) *nvim_tree.api.fs.rename_full()*
25382508
Prompt to rename by absolute path.
25392509

25402510
Parameters: ~
2541-
{node} (`nvim_tree.api.Node`)
2511+
{node} (`nvim_tree.api.Node?`)
25422512

25432513
rename_node({node}) *nvim_tree.api.fs.rename_node()*
25442514
Prompt to rename.
25452515

25462516
Parameters: ~
2547-
{node} (`nvim_tree.api.Node`)
2517+
{node} (`nvim_tree.api.Node?`)
25482518

25492519
rename_sub({node}) *nvim_tree.api.fs.rename_sub()*
25502520
Prompt to rename by absolute path with name omitted.
25512521

25522522
Parameters: ~
2553-
{node} (`nvim_tree.api.Node`)
2523+
{node} (`nvim_tree.api.Node?`)
25542524

25552525
trash({node}) *nvim_tree.api.fs.trash()*
25562526
Trash as per |nvim_tree.config.trash|
25572527

25582528
Parameters: ~
2559-
{node} (`nvim_tree.api.Node`)
2529+
{node} (`nvim_tree.api.Node?`)
2530+
2531+
2532+
==============================================================================
2533+
API: fs.copy *nvim-tree-api-fs-copy*
2534+
2535+
absolute_path({node}) *nvim_tree.api.fs.copy.absolute_path()*
2536+
Copy the absolute path to the system clipboard.
2537+
2538+
Parameters: ~
2539+
{node} (`nvim_tree.api.Node?`)
2540+
2541+
basename({node}) *nvim_tree.api.fs.copy.basename()*
2542+
Copy the name with extension omitted to the system clipboard.
2543+
2544+
Parameters: ~
2545+
{node} (`nvim_tree.api.Node?`)
2546+
2547+
filename({node}) *nvim_tree.api.fs.copy.filename()*
2548+
Copy the name to the system clipboard.
2549+
2550+
Parameters: ~
2551+
{node} (`nvim_tree.api.Node?`)
2552+
2553+
node({node}) *nvim_tree.api.fs.copy.node()*
2554+
Copy to the nvim-tree clipboard.
2555+
2556+
Parameters: ~
2557+
{node} (`nvim_tree.api.Node?`)
2558+
2559+
relative_path({node}) *nvim_tree.api.fs.copy.relative_path()*
2560+
Copy the path relative to the tree root to the system clipboard.
2561+
2562+
Parameters: ~
2563+
{node} (`nvim_tree.api.Node?`)
25602564

25612565

25622566
==============================================================================
@@ -2636,7 +2640,7 @@ toggle({node}) *nvim_tree.api.marks.toggle()*
26362640
Toggle mark.
26372641

26382642
Parameters: ~
2639-
{node} (`nvim_tree.api.Node`) file or directory
2643+
{node} (`nvim_tree.api.Node?`) file or directory
26402644

26412645

26422646
==============================================================================
@@ -2647,7 +2651,7 @@ buffer.delete({node}, {opts}) *nvim_tree.api.node.buffer.delete()*
26472651
|:bdelete|!
26482652

26492653
Parameters: ~
2650-
{node} (`nvim_tree.api.Node`) file
2654+
{node} (`nvim_tree.api.Node?`) file
26512655
{opts} (`table?`)
26522656
{force}? (`boolean`, default: false) Proceed even if the
26532657
buffer is modified.
@@ -2976,14 +2980,14 @@ change_root_to_node({node}) *nvim_tree.api.tree.change_root_to_node()*
29762980
Change the tree's root to a folder node or the parent of a file node.
29772981

29782982
Parameters: ~
2979-
{node} (`nvim_tree.api.Node`) directory or file
2983+
{node} (`nvim_tree.api.Node?`) directory or file
29802984

29812985
*nvim_tree.api.tree.change_root_to_parent()*
29822986
change_root_to_parent({node})
29832987
Change the tree's root to the parent of a node.
29842988

29852989
Parameters: ~
2986-
{node} (`nvim_tree.api.Node`) directory or file
2990+
{node} (`nvim_tree.api.Node?`) directory or file
29872991

29882992
close() *nvim_tree.api.tree.close()*
29892993
Close the tree, affecting all tabs as per |nvim_tree.config.tab.sync|

lua/nvim-tree/_meta/api/fs.lua

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,13 @@
11
---@meta
22
local nvim_tree = { api = { fs = {} } }
33

4+
nvim_tree.api.fs.copy = require("nvim-tree._meta.api.fs.copy");
5+
46
---
57
---Clear the nvim-tree clipboard.
68
---
79
function nvim_tree.api.fs.clear_clipboard() end
810

9-
nvim_tree.api.fs.copy = {}
10-
11-
---
12-
---Copy the absolute path to the system clipboard.
13-
---
14-
---@param node nvim_tree.api.Node
15-
function nvim_tree.api.fs.copy.absolute_path(node) end
16-
17-
---
18-
---Copy the name with extension omitted to the system clipboard.
19-
---
20-
---@param node nvim_tree.api.Node
21-
function nvim_tree.api.fs.copy.basename(node) end
22-
23-
---
24-
---Copy the name to the system clipboard.
25-
---
26-
---@param node nvim_tree.api.Node
27-
function nvim_tree.api.fs.copy.filename(node) end
28-
29-
---
30-
---Copy to the nvim-tree clipboard.
31-
---
32-
---@param node nvim_tree.api.Node
33-
function nvim_tree.api.fs.copy.node(node) end
34-
35-
---
36-
---Copy the path relative to the tree root to the system clipboard.
37-
---
38-
---@param node nvim_tree.api.Node
39-
function nvim_tree.api.fs.copy.relative_path(node) end
40-
4111
---
4212
---Prompt to create a file or directory.
4313
---
@@ -47,21 +17,21 @@ function nvim_tree.api.fs.copy.relative_path(node) end
4717
---
4818
---Multiple directories/files may be created e.g. `"foo/bar/baz"`
4919
---
50-
---@param node nvim_tree.api.Node
20+
---@param node? nvim_tree.api.Node
5121
function nvim_tree.api.fs.create(node) end
5222

5323
---
5424
---Cut to the nvim-tree clipboard.
5525
---
56-
---@param node nvim_tree.api.Node
26+
---@param node? nvim_tree.api.Node
5727
function nvim_tree.api.fs.cut(node) end
5828

5929
---
6030
---Paste from the nvim-tree clipboard.
6131
---
6232
---If {node} is a file it will pasted in the parent directory.
6333
---
64-
---@param node nvim_tree.api.Node
34+
---@param node? nvim_tree.api.Node
6535
function nvim_tree.api.fs.paste(node) end
6636

6737
---
@@ -72,43 +42,43 @@ function nvim_tree.api.fs.print_clipboard() end
7242
---
7343
---Delete from the file system.
7444
---
75-
---@param node nvim_tree.api.Node
45+
---@param node? nvim_tree.api.Node
7646
function nvim_tree.api.fs.remove(node) end
7747

7848
---
7949
---Prompt to rename by name.
8050
---
81-
---@param node nvim_tree.api.Node
51+
---@param node? nvim_tree.api.Node
8252
function nvim_tree.api.fs.rename(node) end
8353

8454
---
8555
---Prompt to rename by name with extension omitted.
8656
---
87-
---@param node nvim_tree.api.Node
57+
---@param node? nvim_tree.api.Node
8858
function nvim_tree.api.fs.rename_basename(node) end
8959

9060
---
9161
---Prompt to rename by absolute path.
9262
---
93-
---@param node nvim_tree.api.Node
63+
---@param node? nvim_tree.api.Node
9464
function nvim_tree.api.fs.rename_full(node) end
9565

9666
---
9767
---Prompt to rename.
9868
---
99-
---@param node nvim_tree.api.Node
69+
---@param node? nvim_tree.api.Node
10070
function nvim_tree.api.fs.rename_node(node) end
10171

10272
---
10373
---Prompt to rename by absolute path with name omitted.
10474
---
105-
---@param node nvim_tree.api.Node
75+
---@param node? nvim_tree.api.Node
10676
function nvim_tree.api.fs.rename_sub(node) end
10777

10878
---
10979
---Trash as per |nvim_tree.config.trash|
11080
---
111-
---@param node nvim_tree.api.Node
81+
---@param node? nvim_tree.api.Node
11282
function nvim_tree.api.fs.trash(node) end
11383

11484
return nvim_tree.api.fs
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---@meta
2+
local nvim_tree = { api = { fs = { copy = {} } } }
3+
4+
---
5+
---Copy the absolute path to the system clipboard.
6+
---
7+
---@param node? nvim_tree.api.Node
8+
function nvim_tree.api.fs.copy.absolute_path(node) end
9+
10+
---
11+
---Copy the name with extension omitted to the system clipboard.
12+
---
13+
---@param node? nvim_tree.api.Node
14+
function nvim_tree.api.fs.copy.basename(node) end
15+
16+
---
17+
---Copy the name to the system clipboard.
18+
---
19+
---@param node? nvim_tree.api.Node
20+
function nvim_tree.api.fs.copy.filename(node) end
21+
22+
---
23+
---Copy to the nvim-tree clipboard.
24+
---
25+
---@param node? nvim_tree.api.Node
26+
function nvim_tree.api.fs.copy.node(node) end
27+
28+
---
29+
---Copy the path relative to the tree root to the system clipboard.
30+
---
31+
---@param node? nvim_tree.api.Node
32+
function nvim_tree.api.fs.copy.relative_path(node) end
33+
34+
return nvim_tree.api.fs.copy

lua/nvim-tree/_meta/api/marks.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function nvim_tree.api.marks.list() end
1616
---
1717
---Toggle mark.
1818
---
19-
---@param node nvim_tree.api.Node file or directory
19+
---@param node? nvim_tree.api.Node file or directory
2020
function nvim_tree.api.marks.toggle(node) end
2121

2222
---

lua/nvim-tree/_meta/api/node.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nvim_tree.api.node.buffer = {}
1818
---
1919
---Deletes node's related buffer, if one exists. Executes [:bdelete] or [:bdelete]!
2020
---
21-
---@param node nvim_tree.api.Node file
21+
---@param node? nvim_tree.api.Node file
2222
---@param opts? nvim_tree.api.node.buffer.RemoveOpts
2323
function nvim_tree.api.node.buffer.delete(node, opts) end
2424

lua/nvim-tree/_meta/api/tree.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ function nvim_tree.api.tree.change_root(path) end
115115
---
116116
---Change the tree's root to a folder node or the parent of a file node.
117117
---
118-
---@param node nvim_tree.api.Node directory or file
118+
---@param node? nvim_tree.api.Node directory or file
119119
function nvim_tree.api.tree.change_root_to_node(node) end
120120

121121
---
122122
---Change the tree's root to the parent of a node.
123123
---
124-
---@param node nvim_tree.api.Node directory or file
124+
---@param node? nvim_tree.api.Node directory or file
125125
function nvim_tree.api.tree.change_root_to_parent(node) end
126126

127127
---

0 commit comments

Comments
 (0)