forked from nvim-tree/nvim-tree.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnvim-tree-lua.txt
More file actions
3084 lines (2455 loc) · 125 KB
/
nvim-tree-lua.txt
File metadata and controls
3084 lines (2455 loc) · 125 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*nvim-tree-lua.txt* A File Explorer For Nvim *nvim_tree* *nvim-tree*
Author: Yazdani Kiyan
Type |gO| to see the table of contents.
Help tag prefixes:
• `nvim-tree-` Help Sections e.g.
• |nvim-tree-mappings|
• |nvim-tree-config|
• `nvim_tree.` API and classes e.g.
• |nvim_tree.config.filesystem_watchers|
==============================================================================
Introduction *nvim-tree-introduction*
Features
- Automatic updates
- File type icons
- Git integration
- Diagnostics integration: LSP and COC
- (Live) filtering
- Cut, copy, paste, rename, delete, create
- Highly customisable
File Icons
https://github.com/nvim-tree/nvim-web-devicons is optional and used to display file icons.
It requires a patched font: https://www.nerdfonts.com
Your terminal emulator must be configured to use that font, usually "Hack Nerd Font"
should look like an open folder.
Disable the display of icons with |nvim_tree.config.renderer.icons.show|
Colours
Syntax highlighting uses g:terminal_color_ from colorschemes, falls back to
ugly colors otherwise.
Git Integration
One or two icons for git status. When two are shown, the left is staged.
✗ unstaged
✓ staged
unmerged
➜ renamed
★ untracked
deleted
◌ ignored
Requirements
Nvim >= 0.9
==============================================================================
Quickstart *nvim-tree-quickstart*
Install the plugins via your package manager:
`"nvim-tree/nvim-tree.lua"`
`"nvim-tree/nvim-web-devicons"`
Disabling |netrw| is strongly advised, see |nvim-tree-netrw|
==============================================================================
Quickstart: Setup *nvim-tree-quickstart-setup*
Setup the plugin in your `init.lua`.
See |nvim-tree-setup| and |nvim-tree-default-config >lua
-- disable netrw at the very start of your init.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- optionally enable 24-bit colour
vim.opt.termguicolors = true
-- empty setup using defaults
require("nvim-tree").setup()
-- OR setup with a config
---@type nvim_tree.config
local config = {
sort = {
sorter = "case_sensitive",
},
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
}
require("nvim-tree").setup(config)
<
==============================================================================
Quickstart: Help *nvim-tree-quickstart-help*
Open the tree: `:NvimTreeOpen`
Show the mappings: `g?`
`<C-]>` CD |nvim-tree-api.tree.change_root_to_node()|
`<C-e>` Open: In Place |nvim-tree-api.node.open.replace_tree_buffer()|
`<C-k>` Info |nvim-tree-api.node.show_info_popup()|
`<C-r>` Rename: Omit Filename |nvim-tree-api.fs.rename_sub()|
`<C-t>` Open: New Tab |nvim-tree-api.node.open.tab()|
`<C-v>` Open: Vertical Split |nvim-tree-api.node.open.vertical()|
`<C-x>` Open: Horizontal Split |nvim-tree-api.node.open.horizontal()|
`<BS>` Close Directory |nvim-tree-api.node.navigate.parent_close()|
`<CR>` Open |nvim-tree-api.node.open.edit()|
`<Del>` Delete |nvim-tree-api.fs.remove()|
`<Tab>` Open Preview |nvim-tree-api.node.open.preview()|
`>` Next Sibling |nvim-tree-api.node.navigate.sibling.next()|
`<` Previous Sibling |nvim-tree-api.node.navigate.sibling.prev()|
`.` Run Command |nvim-tree-api.node.run.cmd()|
`-` Up |nvim-tree-api.tree.change_root_to_parent()|
`a` Create File Or Directory |nvim-tree-api.fs.create()|
`bd` Delete Bookmarked |nvim-tree-api.marks.bulk.delete()|
`bt` Trash Bookmarked |nvim-tree-api.marks.bulk.trash()|
`bmv` Move Bookmarked |nvim-tree-api.marks.bulk.move()|
`B` Toggle Filter: No Buffer |nvim-tree-api.tree.toggle_no_buffer_filter()|
`c` Copy |nvim-tree-api.fs.copy.node()|
`C` Toggle Filter: Git Clean |nvim-tree-api.tree.toggle_git_clean_filter()|
`[c` Prev Git |nvim-tree-api.node.navigate.git.prev()|
`]c` Next Git |nvim-tree-api.node.navigate.git.next()|
`d` Delete |nvim-tree-api.fs.remove()|
`D` Trash |nvim-tree-api.fs.trash()|
`E` Expand All |nvim-tree-api.tree.expand_all()|
`e` Rename: Basename |nvim-tree-api.fs.rename_basename()|
`]e` Next Diagnostic |nvim-tree-api.node.navigate.diagnostics.next()|
`[e` Prev Diagnostic |nvim-tree-api.node.navigate.diagnostics.prev()|
`F` Live Filter: Clear |nvim-tree-api.live_filter.clear()|
`f` Live Filter: Start |nvim-tree-api.live_filter.start()|
`g?` Help |nvim-tree-api.tree.toggle_help()|
`gy` Copy Absolute Path |nvim-tree-api.fs.copy.absolute_path()|
`ge` Copy Basename |nvim-tree-api.fs.copy.basename()|
`H` Toggle Filter: Dotfiles |nvim-tree-api.tree.toggle_hidden_filter()|
`I` Toggle Filter: Git Ignore |nvim-tree-api.tree.toggle_gitignore_filter()|
`J` Last Sibling |nvim-tree-api.node.navigate.sibling.last()|
`K` First Sibling |nvim-tree-api.node.navigate.sibling.first()|
`L` Toggle Group Empty |nvim-tree-api.node.open.toggle_group_empty()|
`M` Toggle Filter: No Bookmark |nvim-tree-api.tree.toggle_no_bookmark_filter()|
`m` Toggle Bookmark |nvim-tree-api.marks.toggle()|
`o` Open |nvim-tree-api.node.open.edit()|
`O` Open: No Window Picker |nvim-tree-api.node.open.no_window_picker()|
`p` Paste |nvim-tree-api.fs.paste()|
`P` Parent Directory |nvim-tree-api.node.navigate.parent()|
`q` Close |nvim-tree-api.tree.close()|
`r` Rename |nvim-tree-api.fs.rename()|
`R` Refresh |nvim-tree-api.tree.reload()|
`s` Run System |nvim-tree-api.node.run.system()|
`S` Search |nvim-tree-api.tree.search_node()|
`u` Rename: Full Path |nvim-tree-api.fs.rename_full()|
`U` Toggle Filter: Hidden |nvim-tree-api.tree.toggle_custom_filter()|
`W` Collapse All |nvim-tree-api.tree.collapse_all()|
`x` Cut |nvim-tree-api.fs.cut()|
`y` Copy Name |nvim-tree-api.fs.copy.filename()|
`Y` Copy Relative Path |nvim-tree-api.fs.copy.relative_path()|
`<2-LeftMouse>` Open |nvim-tree-api.node.open.edit()|
`<2-RightMouse>` CD |nvim-tree-api.tree.change_root_to_node()|
==============================================================================
Quickstart: Custom Mappings *nvim-tree-quickstart-custom-mappings*
|nvim-tree-mappings-default| are applied by default however you may customise
via |nvim_tree.config| {on_attach} e.g. >lua
local function my_on_attach(bufnr)
local api = require "nvim-tree.api"
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- default mappings
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
vim.keymap.set("n", "<C-t>", api.tree.change_root_to_parent, opts("Up"))
vim.keymap.set("n", "?", api.tree.toggle_help, opts("Help"))
end
-- pass to setup along with your other options
require("nvim-tree").setup({
---
on_attach = my_on_attach,
---
})
<
==============================================================================
Quickstart: Highlight Groups *nvim-tree-quickstart-highlight*
Run |:NvimTreeHiTest| to show all the highlights that nvim-tree uses.
They can be customised before or after setup is called and will be immediately
applied at runtime. e.g. >lua
vim.cmd([[
:hi NvimTreeExecFile guifg=#ffa0a0
:hi NvimTreeSpecialFile guifg=#ff80ff gui=underline
:hi NvimTreeSymlink guifg=Yellow gui=italic
:hi link NvimTreeImageFile Title
]])
<
See |nvim-tree-highlight-groups| for details.
==============================================================================
Commands *nvim-tree-commands*
*:NvimTreeOpen*
Opens the tree. See |nvim-tree-api.tree.open()|
Calls: `api.tree.open({ path = "<args>" })`
*:NvimTreeClose*
Closes the tree. See |nvim-tree-api.tree.close()|
Calls: `api.tree.close()`
*:NvimTreeToggle*
Open or close the tree. See |nvim-tree-api.tree.toggle()|
Calls: `api.tree.toggle({ path = "<args>", find_file = false, update_root = false, focus = true, })`
*:NvimTreeFocus*
Open the tree if it is closed, and then focus on the tree.
See |nvim-tree-api.tree.open()|
Calls: `api.tree.open()`
*:NvimTreeRefresh*
Refresh the tree. See |nvim-tree-api.tree.reload()|
Calls: `api.tree.reload()`
*:NvimTreeFindFile*
The command will change the cursor in the tree for the current bufname.
It will also open the leafs of the tree leading to the file in the buffer
(if you opened a file with something else than the NvimTree, like `fzf` or
`:split`)
Invoke with a bang `:NvimTreeFindFile!` to update the root.
See |nvim-tree-api.tree.find_file()|
Calls: `api.tree.find_file({ update_root = <bang>, open = true, focus = true, })`
*:NvimTreeFindFileToggle*
close the tree or change the cursor in the tree for the current bufname,
similar to combination of |:NvimTreeToggle| and |:NvimTreeFindFile|. Takes an
optional path argument.
Invoke with a bang `:NvimTreeFindFileToggle!` to update the root.
See |nvim-tree-api.tree.toggle()|
Calls: `api.tree.toggle({ path = "<args>", update_root = <bang>, find_file = true, focus = true, })`
*:NvimTreeClipboard*
Print clipboard content for both cut and copy
See |nvim-tree-api.fs.print_clipboard()|
Calls: `api.fs.print_clipboard()`
*:NvimTreeResize*
Resize the NvimTree window to the given size. Example: `:NvimTreeResize 50`
resizes the window to the width of 50. If the size starts with "+" or "-" it
adds or removes the given value to the current window width.
Example `:NvimTreeResize -20` removes the value 20 from the current width. And
`:NvimTreeResize +20` adds the value 20 to the current width.
*:NvimTreeCollapse*
Collapses the nvim-tree recursively.
See |nvim-tree-api.tree.collapse_all()|
Calls: `api.tree.collapse_all({ keep_buffers = false })`
*:NvimTreeCollapseKeepBuffers*
Collapses the nvim-tree recursively, but keep the directories open, which are
used in an open buffer.
See |nvim-tree-api.tree.collapse_all()|
Calls: `api.tree.collapse_all({ keep_buffers = true })`
*:NvimTreeHiTest*
Show nvim-tree highlight groups similar to `:so $VIMRUNTIME/syntax/hitest.vim`
See |nvim-tree-api.diagnostics.hi_test()|
Calls: `api.diagnostics.hi_test()`
==============================================================================
Setup *nvim-tree-setup*
You must run the `setup()` function once to initialise nvim-tree. It may be
called again to apply a change in configuration without restarting Nvim.
The `setup()` function takes one optional argument: |nvim_tree.config|. If
omitted nvim-tree will be initialised with default configuration:
|nvim-tree-default-config|.
Config can be validated with |lsp| when passed directly e.g. >lua
require("nvim-tree").setup({
hijack_cursor = true,
})
<
or as a typed variable e.g. >lua
---@type nvim_tree.config
local config = {
hijack_cursor = true,
}
require("nvim-tree").setup(config)
<
The first `setup()` call is cheap: it does nothing more than validate / apply
the configuration. Nothing happens until the tree is first opened.
Subsequent `setup()` calls are expensive as they tear down the world before
applying configuration.
==============================================================================
API *nvim-tree-api*
Nvim-tree's public API can be used to access features. e.g. >lua
local api = require("nvim-tree.api")
api.tree.toggle()
<
This module exposes stable functionalities, it is advised to use this in order
to avoid breaking configurations due to internal breaking changes.
The api is separated in multiple modules, which can be accessed with
`api.<module>.<function>`
Functions accepting {node} as their first argument will use the node under the
cursor when that argument is not present or nil.
==============================================================================
API: Tree *nvim-tree-api.tree*
tree.open({opts}) *nvim-tree-api.tree.open()*
Open the tree, focusing it if already open.
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {path} (string) root directory for the tree
• {current_window} (boolean) open the tree in the current window
• {winid} (number) open the tree in the specified |winid|,
overrides {current_window}
• {find_file} (boolean) find the current buffer
• {update_root} (boolean) requires {find_file}, see
|nvim_tree.config.update_focused_file| {update_root}
tree.toggle({opts}) *nvim-tree-api.tree.toggle()*
Open or close the tree.
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {path} (string) root directory for the tree
• {current_window} (boolean) open the tree in the current window
• {winid} (number) open the tree in the specified |winid|,
overrides {current_window}
• {find_file} (boolean) find the current buffer
• {update_root} (boolean) requires {find_file}, see
|nvim_tree.config.update_focused_file| {update_root}
• {focus} (boolean) focus the tree when opening, default true
tree.close() *nvim-tree-api.tree.close()*
Close the tree, affecting all tabs as per |nvim_tree.config.tab.sync| {close}
tree.close_in_this_tab() *nvim-tree-api.tree.close_in_this_tab()*
Close the tree in this tab only.
tree.close_in_all_tabs() *nvim-tree-api.tree.close_in_all_tabs()*
Close the tree in all tabs.
tree.focus() *nvim-tree-api.tree.focus()*
Focus the tree, opening it if necessary.
Retained for compatibility, use |nvim-tree-api.tree.open()| with no arguments instead.
tree.reload() *nvim-tree-api.tree.reload()*
Refresh the tree. Does nothing if closed.
tree.resize({opts}) *nvim-tree-api.tree.resize()*
Resize the tree, persisting the new size.
Resets to |nvim_tree.config.view| {width} when no {opts} provided.
See |:NvimTreeResize|
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {width} (table) new |nvim_tree.config.view| {width} value
• {absolute} (number) set the width
• {relative} (number) increase or decrease the width
Only one option is supported, in the priority order above.
{absolute} and {relative} do nothing when {width} is a function.
tree.change_root({path}) *nvim-tree-api.tree.change_root()*
Change the tree's root to a path.
Parameters: ~
• {path} (string) absolute or relative path
*nvim-tree-api.tree.change_root_to_node()*
tree.change_root_to_node({node})
Change the tree's root to a folder node or the parent of a file node.
Parameters: ~
• {node} (Node) folder or file
*nvim-tree-api.tree.change_root_to_parent()*
tree.change_root_to_parent({node})
Change the tree's root to the parent of a node.
Parameters: ~
• {node} (Node) folder or file
tree.get_node_under_cursor() *nvim-tree-api.tree.get_node_under_cursor()*
Retrieve the currently focused node.
Return: ~
node or nil if tree is not visible
tree.get_nodes() *nvim-tree-api.tree.get_nodes()*
Retrieve a hierarchical list of all the nodes. This is a cloned list for
reference purposes only and should not be passed into other API functions.
Return: ~
table of nodes
tree.find_file({opts}) *nvim-tree-api.tree.find_file()*
Find and focus a file or folder in the tree. Finds current buffer unless
otherwise specified.
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {buf} (string|number) absolute/relative path OR bufnr to find
• {open} (boolean) open the tree if necessary
• {current_window} (boolean) requires {open}, open in the current window
• {winid} (number) open the tree in the specified |winid|,
overrides {current_window}
• {update_root} (boolean) see |nvim_tree.config.update_focused_file| {update_root}
• {focus} (boolean) focus the tree
tree.search_node() *nvim-tree-api.tree.search_node()*
Open the search dialogue as per the search_node action.
tree.collapse_all({opts}) *nvim-tree-api.tree.collapse_all()*
Collapse the tree.
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {keep_buffers} (boolean) do not collapse nodes with open buffers.
tree.expand_all({node}, {opts}) *nvim-tree-api.tree.expand_all()*
Recursively expand all nodes under the tree root or specified folder.
Parameters: ~
• {node} (Node|nil) folder
• {opts} (ApiTreeExpandOpts) optional parameters
Options: ~
• {expand_until} ((fun(expansion_count: integer, node: Node?): boolean)?)
Return true if {node} should be expanded.
{expansion_count} is the total number of folders expanded.
*nvim-tree-api.tree.toggle_enable_filters()*
tree.toggle_enable_filters()
Toggle |nvim_tree.config.filters| {enable} all filters.
*nvim-tree-api.tree.toggle_gitignore_filter()*
tree.toggle_gitignore_filter()
Toggle |nvim_tree.config.filters| {git_ignored} filter.
*nvim-tree-api.tree.toggle_git_clean_filter()*
tree.toggle_git_clean_filter()
Toggle |nvim_tree.config.filters| {git_clean} filter.
*nvim-tree-api.tree.toggle_no_buffer_filter()*
tree.toggle_no_buffer_filter()
Toggle |nvim_tree.config.filters| {no_buffer} filter.
*nvim-tree-api.tree.toggle_no_bookmark_filter()*
tree.toggle_no_bookmark_filter()
Toggle |nvim_tree.config.filters| {no_bookmark} filter.
*nvim-tree-api.tree.toggle_custom_filter()*
tree.toggle_custom_filter()
Toggle |nvim_tree.config.filters| {custom} filter.
*nvim-tree-api.tree.toggle_hidden_filter()*
tree.toggle_hidden_filter()
Toggle |nvim_tree.config.filters| {dotfiles} filter.
tree.toggle_help() *nvim-tree-api.tree.toggle_help()*
Toggle help view.
tree.is_tree_buf({bufnr}) *nvim-tree-api.tree.is_tree_buf()*
Checks if a buffer is an nvim-tree.
Parameters: ~
• {bufnr} (number|nil) buffer handle, 0 or nil for current buffer
Return: ~
(boolean) buffer is an nvim-tree buffer
tree.is_visible({opts}) *nvim-tree-api.tree.is_visible()*
Checks if nvim-tree is visible on the current, specified or any tab.
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {tabpage} (number) as per |nvim_get_current_tabpage()|
• {any_tabpage} (boolean) visible on any tab, default false
Return: ~
(boolean) nvim-tree is visible
tree.winid({opts}) *nvim-tree-api.tree.winid()*
Retrieve the winid of the open tree.
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {tabpage} (number|nil) tabpage, 0 or nil for current, default nil
Return: ~
(number) winid or nil if tree is not visible
==============================================================================
API: File System *nvim-tree-api.fs*
fs.create({node}) *nvim-tree-api.fs.create()*
Prompt to create a file or directory. Use a trailing `/` for a directory.
Multiple directories/files may be created e.g. `foo/bar/baz`
Parameters: ~
• {node} (Node|nil) parent, uses the parent of a file.
fs.remove({node}) *nvim-tree-api.fs.remove()*
Delete a file or folder from the file system.
Parameters: ~
• {node} (Node|nil) file or folder
fs.trash({node}) *nvim-tree-api.fs.trash()*
Trash a file or folder as per |nvim_tree.config.trash|
Parameters: ~
• {node} (Node|nil) file or folder
fs.rename_node({node}) *nvim-tree-api.fs.rename_node()*
Prompt to rename a file or folder.
Parameters: ~
• {node} (Node|nil) file or folder
fs.rename({node}) *nvim-tree-api.fs.rename()*
Prompt to rename a file or folder by name.
Parameters: ~
• {node} (Node|nil) file or folder
fs.rename_basename({node}) *nvim-tree-api.fs.rename_basename()*
Prompt to rename a file or folder by name with extension omitted.
Parameters: ~
• {node} (Node|nil) file or folder
fs.rename_sub({node}) *nvim-tree-api.fs.rename_sub()*
Prompt to rename a file or folder by absolute path with name omitted.
Parameters: ~
• {node} (Node|nil) file or folder
fs.rename_full({node}) *nvim-tree-api.fs.rename_full()*
Prompt to rename a file or folder by absolute path.
Parameters: ~
• {node} (Node|nil) file or folder
fs.cut({node}) *nvim-tree-api.fs.cut()*
Cut a file or folder to the nvim-tree clipboard.
Parameters: ~
• {node} (Node|nil) file or folder
fs.paste({node}) *nvim-tree-api.fs.paste()*
Paste a file or folder from the nvim-tree clipboard.
Parameters: ~
• {node} (Node|nil) destination folder, uses the parent of a file.
fs.copy.node({node}) *nvim-tree-api.fs.copy.node()*
Copy a file or folder from the nvim-tree clipboard.
Parameters: ~
• {node} (Node|nil) file or folder
fs.copy.absolute_path({node}) *nvim-tree-api.fs.copy.absolute_path()*
Copy the absolute path of a file or folder to the system clipboard.
Parameters: ~
• {node} (Node|nil) file or folder
fs.copy.basename({node}) *nvim-tree-api.fs.copy.basename()*
Copy the name of a file or folder with extension omitted to the system
clipboard.
Parameters: ~
• {node} (Node|nil) file or folder
fs.copy.filename({node}) *nvim-tree-api.fs.copy.filename()*
Copy the name of a file or folder to the system clipboard.
Parameters: ~
• {node} (Node|nil) file or folder
fs.copy.relative_path({node}) *nvim-tree-api.fs.copy.relative_path()*
Copy the path of a file or folder relative to the tree root to the system
clipboard.
Parameters: ~
• {node} (Node|nil) file or folder
fs.clear_clipboard() *nvim-tree-api.fs.clear_clipboard()*
Clear the nvim-tree clipboard.
fs.print_clipboard() *nvim-tree-api.fs.print_clipboard()*
Print the contents of the nvim-tree clipboard.
==============================================================================
API: Node *nvim-tree-api.node*
node.open.edit({node}, {opts}) *nvim-tree-api.node.open.edit()*
File: open as per |nvim_tree.config.actions.open_file|
Folder: expand or collapse
Root: change directory up
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
*nvim-tree-api.node.open.replace_tree_buffer()*
node.open.replace_tree_buffer({node})
|nvim-tree-api.node.open.edit()|, file will be opened in place: in the
nvim-tree window.
*nvim-tree-api.node.open.no_window_picker()*
node.open.no_window_picker({node}, {opts})
|nvim-tree-api.node.open.edit()|, window picker will be bypassed.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
node.open.vertical({node}, {opts}) *nvim-tree-api.node.open.vertical()*
|nvim-tree-api.node.open.edit()|, file will be opened in a new vertical split.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
*nvim-tree-api.node.open.vertical_no_picker()*
node.open.vertical_no_picker({node}, {opts})
|nvim-tree-api.node.open.vertical()|, window picker will be bypassed.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
node.open.horizontal({node}, {opts}) *nvim-tree-api.node.open.horizontal()*
|nvim-tree-api.node.open.edit()|, file will be opened in a new horizontal split.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
*nvim-tree-api.node.open.horizontal_no_picker()*
node.open.horizontal_no_picker({node}, {opts})
|nvim-tree-api.node.open.horizontal()|, window picker will be bypassed.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
*nvim-tree-api.node.open.toggle_group_empty()*
node.open.toggle_group_empty({node}, {opts})
Toggle |nvim_tree.config.renderer| {group_empty} for a specific folder.
Does nothing on files.
Needs |nvim_tree.config.renderer| {group_empty} set.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
node.open.drop({node}) *nvim-tree-api.node.open.drop()*
Switch to window with selected file if it exists.
Open file otherwise.
See: `:h :drop`.
File: open file using `:drop`
Folder: expand or collapse
Root: change directory up
node.open.tab({node}, {opts}) *nvim-tree-api.node.open.tab()*
|nvim-tree-api.node.open.edit()|, file will be opened in a new tab.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
*nvim-tree-api.node.open.tab_drop()*
node.open.tab_drop({node})
Switch to tab containing window with selected file if it exists.
Open file in new tab otherwise.
File: open file using `tab :drop`
Folder: expand or collapse
Root: change directory up
node.open.preview({node}, {opts}) *nvim-tree-api.node.open.preview()*
|nvim-tree-api.node.open.edit()|, file buffer will have |'bufhidden'| set to `delete`.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
*nvim-tree-api.node.open.preview_no_picker()*
node.open.preview_no_picker({node}, {opts})
|nvim-tree-api.node.open.edit()|, file buffer will have |'bufhidden'| set to `delete`.
window picker will be bypassed.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {quit_on_open} (boolean) quits the tree when opening the file
• {focus} (boolean) keep focus in the tree when opening the file
node.navigate.git.next({node}) *nvim-tree-api.node.navigate.git.next()*
Navigate to the next item showing git status.
*nvim-tree-api.node.navigate.git.next_recursive()*
node.navigate.git.next_recursive({node})
Alternative to |nvim-tree-api.node.navigate.git.next()| that navigates to
the next file showing git status, recursively.
Needs |nvim_tree.config.git| {show_on_dirs} set.
*nvim-tree-api.node.navigate.git.next_skip_gitignored()*
node.navigate.git.next_skip_gitignored({node})
Same as |nvim-tree-api.node.navigate.git.next()|, but skips gitignored files.
node.navigate.git.prev({node}) *nvim-tree-api.node.navigate.git.prev()*
Navigate to the previous item showing git status.
*nvim-tree-api.node.navigate.git.prev_recursive()*
node.navigate.git.prev_recursive({node})
Alternative to |nvim-tree-api.node.navigate.git.prev()| that navigates to
the previous file showing git status, recursively.
Needs |nvim_tree.config.git| {show_on_dirs} set.
*nvim-tree-api.node.navigate.git.prev_skip_gitignored()*
node.navigate.git.prev_skip_gitignored({node})
same as |nvim-tree-api.node.navigate.git.prev()|, but skips gitignored files.
*nvim-tree-api.node.navigate.diagnostics.next()*
node.navigate.diagnostics.next({node})
Navigate to the next item showing diagnostic status.
*nvim-tree-api.node.navigate.diagnostics.next_recursive()*
node.navigate.diagnostics.next_recursive({node})
Alternative to |nvim-tree-api.node.navigate.diagnostics.next()| that
navigates to the next file showing diagnostic status, recursively.
Needs |nvim_tree.config.diagnostics| {show_on_dirs} set.
*nvim-tree-api.node.navigate.diagnostics.prev()*
node.navigate.diagnostics.prev({node})
Navigate to the next item showing diagnostic status.
*nvim-tree-api.node.navigate.diagnostics.prev_recursive()*
node.navigate.diagnostics.prev_recursive({node})
Alternative to |nvim-tree-api.node.navigate.diagnostics.prev()| that
navigates to the previous file showing diagnostic status, recursively.
Needs |nvim_tree.config.diagnostics| {show_on_dirs} set.
*nvim-tree-api.node.navigate.opened.next()*
node.navigate.opened.next({node})
Navigate to the next |bufloaded()| item.
See |nvim_tree.config.renderer| {highlight_opened_files}
*nvim-tree-api.node.navigate.opened.prev()*
node.navigate.opened.prev({node})
Navigate to the previous |bufloaded()| item.
See |nvim_tree.config.renderer| {highlight_opened_files}
*nvim-tree-api.node.navigate.sibling.next()*
node.navigate.sibling.next({node})
Navigate to the next node in the current node's folder, wraps.
*nvim-tree-api.node.navigate.sibling.prev()*
node.navigate.sibling.prev({node})
Navigate to the previous node in the current node's folder, wraps.
*nvim-tree-api.node.navigate.sibling.first()*
node.navigate.sibling.first({node})
Navigate to the first node in the current node's folder.
*nvim-tree-api.node.navigate.sibling.last()*
node.navigate.sibling.last({node})
Navigate to the last node in the current node's folder.
*nvim-tree-api.node.navigate.parent()*
node.navigate.parent({node})
Navigate to the parent folder of the current node.
*nvim-tree-api.node.navigate.parent_close()*
node.navigate.parent_close({node})
|nvim-tree-api.node.navigate.parent()|, closing that folder.
node.show_info_popup({node}) *nvim-tree-api.node.show_info_popup()*
Open a popup window showing: fullpath, size, accessed, modified, created.
node.run.cmd({node}) *nvim-tree-api.node.run.cmd()*
Enter |cmdline| with the full path of the node and the cursor at the start
of the line.
node.run.system({node}) *nvim-tree-api.node.run.system()*
Execute |nvim_tree.config.system_open|
node.buffer.delete({node}, {opts}) *nvim-tree-api.node.buffer.delete()*
Deletes node's related buffer, if one exists.
Executes |:bdelete| or |:bdelete|!
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {force} (boolean) delete even if buffer is modified, default false
node.buffer.wipe({node}, {opts}) *nvim-tree-api.node.buffer.wipe()*
Wipes node's related buffer, if one exists.
Executes |:bwipe| or |:bwipe|!
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {force} (boolean) wipe even if buffer is modified, default false
node.expand({node}, {opts}) *nvim-tree-api.node.expand()*
Recursively expand all nodes under a directory or a file's parent
directory.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (ApiTreeExpandOpts) optional parameters
Options: ~
• {expand_until} ((fun(expansion_count: integer, node: Node?): boolean)?)
Return true if {node} should be expanded.
{expansion_count} is the total number of folders expanded.
node.collapse({node}, {opts}) *nvim-tree-api.node.collapse()*
Collapse the tree under a directory or a file's parent directory.
Parameters: ~
• {node} (Node|nil) file or folder
• {opts} (table) optional parameters
Options: ~
• {keep_buffers} (boolean) do not collapse nodes with open buffers.
==============================================================================
API: Git *nvim-tree-api.git*
git.reload() *nvim-tree-api.git.reload()*
Update the git status of the entire tree.
==============================================================================
API: Events *nvim-tree-api.events*
*nvim-tree-api.events.subscribe()*
events.subscribe({event_type}, {callback})
Register a handler for an event, see |nvim-tree-events|
Parameters: ~
• {event_type} (string) |nvim-tree-api.events.Event|
• {callback} (function) see |nvim_tree_events_kind| for parameters
events.Event *nvim-tree-api.events.Event*
String enum: |nvim_tree_events_kind|
==============================================================================
API: Live Filter *nvim-tree-api.live_filter*
live_filter.start() *nvim-tree-api.live_filter.start()*
Enter |nvim-tree-api.live_filter| mode.
Opens an input window with |filetype| `"NvimTreeFilter"`
live_filter.clear() *nvim-tree-api.live_filter.clear()*
Exit |nvim-tree-api.live_filter| mode.
==============================================================================
API: Marks *nvim-tree-api.marks*
marks.get({node}) *nvim-tree-api.marks.get()*
Return the node if it is marked.
Parameters: ~
• {node} (Node) folder or file
marks.list() *nvim-tree-api.marks.list()*
Retrieve all marked nodes.
Return: ~
(table) marked nodes
marks.toggle({node}) *nvim-tree-api.marks.toggle()*
Toggle node mark.
Parameters: ~
• {node} (Node) folder or file