-
-
Notifications
You must be signed in to change notification settings - Fork 609
/
nvim-tree-lua.txt
3137 lines (2566 loc) · 118 KB
/
nvim-tree-lua.txt
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* A File Explorer For Neovim Written In Lua
Author: Yazdani Kiyan
==============================================================================
CONTENTS *nvim-tree*
1. Introduction |nvim-tree-introduction|
2. Quickstart |nvim-tree-quickstart|
2.1 Quickstart: Setup |nvim-tree-quickstart-setup|
2.2 Quickstart: Help |nvim-tree-quickstart-help|
2.3 Quickstart: Custom Mappings |nvim-tree-quickstart-custom-mappings|
2.4 Quickstart: Highlight |nvim-tree-quickstart-highlight|
3. Commands |nvim-tree-commands|
4. Setup |nvim-tree-setup|
5. Opts |nvim-tree-opts|
5.1 Opts: Sort |nvim-tree-opts-sort|
5.2 Opts: View |nvim-tree-opts-view|
5.3 Opts: Renderer |nvim-tree-opts-renderer|
5.4 Opts: Hijack Directories |nvim-tree-opts-hijack-directories|
5.5 Opts: Update Focused File |nvim-tree-opts-update-focused-file|
5.6 Opts: System Open |nvim-tree-opts-system-open|
5.7 Opts: Git |nvim-tree-opts-git|
5.8 Opts: Diagnostics |nvim-tree-opts-diagnostics|
5.9 Opts: Modified |nvim-tree-opts-modified|
5.10 Opts: Filters |nvim-tree-opts-filters|
5.11 Opts: Live Filter |nvim-tree-opts-live-filter|
5.12 Opts: Filesystem Watchers |nvim-tree-opts-filesystem-watchers|
5.13 Opts: Actions |nvim-tree-opts-actions|
5.14 Opts: Trash |nvim-tree-opts-trash|
5.15 Opts: Tab |nvim-tree-opts-tab|
5.16 Opts: Notify |nvim-tree-opts-notify|
5.17 Opts: Help |nvim-tree-opts-help|
5.18 Opts: UI |nvim-tree-opts-ui|
5.19 Opts: Experimental |nvim-tree-opts-experimental|
5.20 Opts: Log |nvim-tree-opts-log|
6. API |nvim-tree-api|
6.1 API Tree |nvim-tree-api.tree|
6.2 API File System |nvim-tree-api.fs|
6.3 API Node |nvim-tree-api.node|
6.4 API Git |nvim-tree-api.git|
6.5 API Events |nvim-tree-api.events|
6.6 API Live Filter |nvim-tree-api.live_filter|
6.7 API Marks |nvim-tree-api.marks|
6.8 API Config |nvim-tree-api.config|
6.9 API Commands |nvim-tree-api.commands|
6.10 API Diagnostics |nvim-tree-api.diagnostics|
7. Mappings |nvim-tree-mappings|
7.1 Mappings: Default |nvim-tree-mappings-default|
8. Highlight |nvim-tree-highlight|
8.1 Highlight: Default |nvim-tree-highlight-default|
8.2 Highlight: Overhaul |nvim-tree-highlight-overhaul|
9. Events |nvim-tree-events|
10. Prompts |nvim-tree-prompts|
11. OS Specific Restrictions |nvim-tree-os-specific|
12. Netrw |nvim-tree-netrw|
13. Legacy |nvim-tree-legacy|
13.1 Legacy: Opts |nvim-tree-legacy-opts|
13.2 Legacy: Highlight |nvim-tree-legacy-highlight|
14. Index |nvim-tree-index|
14.1 Index: Opts |nvim-tree-index-opts|
14.2 Index: API |nvim-tree-index-api|
==============================================================================
1. 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.
To disable the display of icons see |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
This file explorer requires `neovim >= 0.9.0`
==============================================================================
2. 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|
==============================================================================
2.1 QUICKSTART: SETUP *nvim-tree-quickstart-setup*
Setup the plugin in your `init.lua` e.g. >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 some options
require("nvim-tree").setup({
sort = {
sorter = "case_sensitive",
},
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
})
<
==============================================================================
2.2 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()|
`<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 |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()|
==============================================================================
2.3 QUICKSTART: CUSTOM MAPPINGS *nvim-tree-quickstart-custom-mappings*
|nvim-tree-mappings-default| are applied by default however you may customise
via |nvim-tree.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,
---
}
<
==============================================================================
2.4 QUICKSTART: HIGHLIGHT *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| for details.
==============================================================================
3. 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(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(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()`
==============================================================================
4. SETUP *nvim-tree-setup*
You must run setup() function once to initialise nvim-tree. It may be called
again to apply a change in configuration without restarting nvim.
setup() function takes one optional argument: configuration table. If omitted
nvim-tree will be initialised with default configuration.
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.
Following is the default configuration. See |nvim-tree-opts| for details. >lua
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
on_attach = "default",
hijack_cursor = false,
auto_reload_on_write = true,
disable_netrw = false,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
root_dirs = {},
prefer_startup_root = false,
sync_root_with_cwd = false,
reload_on_bufenter = false,
respect_buf_cwd = false,
select_prompts = false,
sort = {
sorter = "name",
folders_first = true,
files_first = false,
},
view = {
centralize_selection = false,
cursorline = true,
debounce_delay = 15,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
width = 30,
float = {
enable = false,
quit_on_focus_loss = true,
open_win_config = {
relative = "editor",
border = "rounded",
width = 30,
height = 30,
row = 1,
col = 1,
},
},
},
renderer = {
add_trailing = false,
group_empty = false,
full_name = false,
root_folder_label = ":~:s?$?/..?",
indent_width = 2,
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
hidden_display = "none",
symlink_destination = true,
highlight_git = "none",
highlight_diagnostics = "none",
highlight_opened_files = "none",
highlight_modified = "none",
highlight_hidden = "none",
highlight_bookmarks = "none",
highlight_clipboard = "name",
indent_markers = {
enable = false,
inline_arrows = true,
icons = {
corner = "└",
edge = "│",
item = "│",
bottom = "─",
none = " ",
},
},
icons = {
web_devicons = {
file = {
enable = true,
color = true,
},
folder = {
enable = false,
color = true,
},
},
git_placement = "before",
modified_placement = "after",
hidden_placement = "after",
diagnostics_placement = "signcolumn",
bookmarks_placement = "signcolumn",
padding = " ",
symlink_arrow = " ➛ ",
show = {
file = true,
folder = true,
folder_arrow = true,
git = true,
modified = true,
hidden = false,
diagnostics = true,
bookmarks = true,
},
glyphs = {
default = "",
symlink = "",
bookmark = "",
modified = "●",
hidden = "",
folder = {
arrow_closed = "",
arrow_open = "",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
},
git = {
unstaged = "✗",
staged = "✓",
unmerged = "",
renamed = "➜",
untracked = "★",
deleted = "",
ignored = "◌",
},
},
},
},
hijack_directories = {
enable = true,
auto_open = true,
},
update_focused_file = {
enable = false,
update_root = {
enable = false,
ignore_list = {},
},
exclude = false,
},
system_open = {
cmd = "",
args = {},
},
git = {
enable = true,
show_on_dirs = true,
show_on_open_dirs = true,
disable_for_dirs = {},
timeout = 400,
cygwin_support = false,
},
diagnostics = {
enable = false,
show_on_dirs = false,
show_on_open_dirs = true,
debounce_delay = 500,
severity = {
min = vim.diagnostic.severity.HINT,
max = vim.diagnostic.severity.ERROR,
},
icons = {
hint = "",
info = "",
warning = "",
error = "",
},
},
modified = {
enable = false,
show_on_dirs = true,
show_on_open_dirs = true,
},
filters = {
enable = true,
git_ignored = true,
dotfiles = false,
git_clean = false,
no_buffer = false,
no_bookmark = false,
custom = {},
exclude = {},
},
live_filter = {
prefix = "[FILTER]: ",
always_show_folders = true,
},
filesystem_watchers = {
enable = true,
debounce_delay = 50,
ignore_dirs = {
"/.ccls-cache",
"/build",
"/node_modules",
"/target",
},
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
global = false,
restrict_above_cwd = false,
},
expand_all = {
max_folder_discovery = 300,
exclude = {},
},
file_popup = {
open_win_config = {
col = 1,
row = 1,
relative = "cursor",
border = "shadow",
style = "minimal",
},
},
open_file = {
quit_on_open = false,
eject = true,
resize_window = true,
relative_path = true,
window_picker = {
enable = true,
picker = "default",
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
},
},
remove_file = {
close_window = true,
},
},
trash = {
cmd = "gio trash",
},
tab = {
sync = {
open = false,
close = false,
ignore = {},
},
},
notify = {
threshold = vim.log.levels.INFO,
absolute_path = true,
},
help = {
sort_by = "key",
},
ui = {
confirm = {
remove = true,
trash = true,
default_yes = false,
},
},
experimental = {
},
log = {
enable = false,
truncate = false,
types = {
all = false,
config = false,
copy_paste = false,
dev = false,
diagnostics = false,
git = false,
profile = false,
watcher = false,
},
},
} -- END_DEFAULT_OPTS
<
==============================================================================
5. OPTS *nvim-tree-opts*
*nvim-tree.on_attach*
Runs when creating the nvim-tree buffer. Use this to set your nvim-tree
specific mappings. See |nvim-tree-mappings|.
When on_attach is not a function, |nvim-tree-mappings-default| will be called.
Type: `function(bufnr) | string`, Default: `"default"`
*nvim-tree.hijack_cursor*
Keeps the cursor on the first letter of the filename when moving in the tree.
Type: `boolean`, Default: `false`
*nvim-tree.auto_reload_on_write*
Reloads the explorer every time a buffer is written to.
Type: `boolean`, Default: `true`
*nvim-tree.disable_netrw*
Completely disable netrw
Type: `boolean`, Default: `false`
It is strongly advised to eagerly disable netrw, due to race conditions at vim
startup.
Set the following at the very beginning of your `init.lua` / `init.vim`: >lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
<
*nvim-tree.hijack_netrw*
Hijack netrw windows (overridden if |disable_netrw| is `true`)
Type: `boolean`, Default: `true`
*nvim-tree.hijack_unnamed_buffer_when_opening*
Opens in place of the unnamed buffer if it's empty.
Type: `boolean`, Default: `false`
*nvim-tree.root_dirs*
Preferred root directories.
Only relevant when `update_focused_file.update_root` is `true`
Type: `{string}`, Default: `{}`
*nvim-tree.prefer_startup_root*
Prefer startup root directory when updating root directory of the tree.
Only relevant when `update_focused_file.update_root` is `true`
Type: `boolean`, Default: `false`
*nvim-tree.sync_root_with_cwd*
Changes the tree root directory on `DirChanged` and refreshes the tree.
Type: `boolean`, Default: `false`
*nvim-tree.reload_on_bufenter*
Automatically reloads the tree on `BufEnter` nvim-tree.
Type: `boolean`, Default: `false`
*nvim-tree.respect_buf_cwd*
Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
Type: `boolean`, Default: `false`
*nvim-tree.select_prompts*
Use |vim.ui.select| style prompts. Necessary when using a UI prompt decorator
such as dressing.nvim or telescope-ui-select.nvim
Type: `boolean`, Default: `false`
==============================================================================
5.1 OPTS: SORT *nvim-tree-opts-sort*
File and folder sorting options.
*nvim-tree.sort.sorter*
Changes how files within the same directory are sorted.
Can be one of `"name"`, `"case_sensitive"`, `"modification_time"`, `"extension"`,
`"suffix"`, `"filetype"` or a function.
`"extension"` uses all suffixes e.g. `foo.tar.gz` -> `.tar.gz`
`"suffix"` uses the last e.g. `.gz`
Type: `string` | `function(nodes)`, Default: `"name"`
Function may perform a sort or return a string with one of the above
methods. It is passed a table of nodes to be sorted, each node containing:
- `absolute_path`: `string`
- `executable`: `boolean`
- `extension`: `string`
- `filetype`: `string`
- `link_to`: `string`
- `name`: `string`
- `type`: `"directory"` | `"file"` | `"link"`
Example: sort by name length: >lua
local sorter = function(nodes)
table.sort(nodes, function(a, b)
return #a.name < #b.name
end)
end
<
*nvim-tree.sort.folders_first*
Sort folders before files. Has no effect when |nvim-tree.sort.sorter| is a
function.
Type: `boolean`, Default: `true`
*nvim-tree.sort.files_first*
Sort files before folders. Has no effect when |nvim-tree.sort.sorter| is a
function. If set to `true` it overrides |nvim-tree.sort.folders_first|.
Type: `boolean`, Default: `false`
==============================================================================
5.2 OPTS: VIEW *nvim-tree-opts-view*
*nvim-tree.view.centralize_selection*
When entering nvim-tree, reposition the view so that the current node is
initially centralized, see |zz|.
Type: `boolean`, Default: `false`
*nvim-tree.view.cursorline*
Enable |cursorline| in the tree window.
Type: `boolean`, Default: `true`
*nvim-tree.view.debounce_delay*
Idle milliseconds before some reload / refresh operations.
Increase if you experience performance issues around screen refresh.
Type: `number`, Default: `15` (ms)
*nvim-tree.view.side*
Side of the tree, can be `"left"`, `"right"`.
Type: `string`, Default: `"left"`
*nvim-tree.view.preserve_window_proportions*
Preserves window proportions when opening a file.
If `false`, the height and width of windows other than nvim-tree will be equalized.
Type: `boolean`, Default: `false`
*nvim-tree.view.number*
Print the line number in front of each line.
Type: `boolean`, Default: `false`
*nvim-tree.view.relativenumber*
Show the line number relative to the line with the cursor in front of each line.
If the option `view.number` is also `true`, the number on the cursor line
will be the line number instead of `0`.
Type: `boolean`, Default: `false`
*nvim-tree.view.signcolumn*
Show |signcolumn|. Value can be `"yes"`, `"auto"`, `"no"`.
Type: `string`, Default: `"yes"`
*nvim-tree.view.width*
Width of the window: can be a `%` string, a number representing columns, a
function or a table.
A table indicates that the view should be dynamically sized based on the
longest line.
Type: `string | number | table | function()` returning a number
Default: `30`
*nvim-tree.view.width.min*
Minimum dynamic width.
Type: `string | number | function()` returning a number
Default: `30`
*nvim-tree.view.width.max*
Maximum dynamic width, -1 for unbounded.
Type: `string | number | function()` returning a number
Default: `-1`
*nvim-tree.view.width.padding*
Extra padding to the right.
Type: `number | function()` returning a number
Default: `1`
*nvim-tree.view.float*
Use nvim-tree in a floating window.
*nvim-tree.view.float.enable*
Tree window will be floating.
Type: `boolean`, Default: `false`
*nvim-tree.view.float.quit_on_focus_loss*
Close the floating tree window when it loses focus.
Type: `boolean`, Default: `true`
*nvim-tree.view.float.open_win_config*
Floating window config. See |nvim_open_win| for more details.
Type: `table | function` returning a table
Default:
`{`
`relative = "editor",`
`border = "rounded",`
`width = 30,`
`height = 30,`
`row = 1,`
`col = 1,`
`}`
==============================================================================
5.3 OPTS: RENDERER *nvim-tree-opts-renderer*
Highlight precedence, additive:
git < opened < modified < bookmarked < diagnostics < copied < cut
*nvim-tree.renderer.add_trailing*
Appends a trailing slash to folder names.
Type: `boolean`, Default: `false`
*nvim-tree.renderer.group_empty*
Compact folders that only contain a single folder into one node.
Boolean or function that takes one argument (the relative path
of grouped folders) and returns a string to be displayed.
Type: `boolean | function(relative_path):string`, Default: `false`
*nvim-tree.renderer.full_name*
Display node whose name length is wider than the width of nvim-tree window in
floating window.
Type: `boolean`, Default: `false`
*nvim-tree.renderer.root_folder_label*
In what format to show root folder. See `:help filename-modifiers` for
available `string` options.
Set to `false` to hide the root folder.
Type: `string` or `boolean` or `function(root_cwd)`, Default: `":~:s?$?/..?"`
Function is passed the absolute path of the root folder and should
return a string. e.g. >lua
my_root_folder_label = function(path)
return ".../" .. vim.fn.fnamemodify(path, ":t")
end
<
*nvim-tree.renderer.indent_width*
Number of spaces for an each tree nesting level. Minimum 1.
Type: `number`, Default: `2`
*nvim-tree.renderer.special_files*
A list of filenames that gets highlighted with `NvimTreeSpecialFile`.
Type: `table`, Default: `{ "Cargo.toml", "Makefile", "README.md", "readme.md", }`
*nvim-tree.renderer.hidden_display*
Show a summary of hidden files below the tree using `NvimTreeHiddenDisplay
Type: `function | string`, Default: `"none"`
Possible string values are:
- `"none"`: Doesn't inform anything about hidden files.
- `"simple"`: Shows how many hidden files are in a folder.
- `"all"`: Shows how many files are hidden and the number of hidden
files per reason why they're hidden.
Example `"all"`:
If a folder has 14 hidden items for various reasons, the display might
show: >
(14 total git: 5, dotfile: 9)
<
If a function is provided, it receives a table `hidden_stats` where keys are
reasons and values are the count of hidden files for that reason.
The `hidden_stats` argument is structured as follows, where <num> is the
number of hidden files related to the field: >lua
hidden_stats = {
bookmark = <num>,
buf = <num>,
custom = <num>,
dotfile = <num>,
git = <num>,
live_filter = <num>,
}
<
Example of function that can be passed: >lua
function(hidden_stats)
local total_count = 0
for reason, count in pairs(hidden_stats) do
total_count = total_count + count
end
if total_count > 0 then
return "(" .. tostring(total_count) .. " hidden)"
end
return nil
end
<
*nvim-tree.renderer.symlink_destination*
Whether to show the destination of the symlink.
Type: `boolean`, Default: `true`
*nvim-tree.renderer.highlight_git*
Enable highlight for git attributes using `NvimTreeGit*HL` highlight groups.
Requires |nvim-tree.git.enable|
Value can be `"none"`, `"icon"`, `"name"` or `"all"`.
Type: `string`, Default: `"none"`
*nvim-tree.renderer.highlight_diagnostics*
Enable highlight for diagnostics using `NvimTreeDiagnostic*HL` highlight groups.
Requires |nvim-tree.diagnostics.enable|
Value can be `"none"`, `"icon"`, `"name"` or `"all"`.
Type: `string`, Default: `"none"`
*nvim-tree.renderer.highlight_opened_files*
Highlight icons and/or names for |bufloaded()| files using the
`NvimTreeOpenedHL` highlight group.
See |nvim-tree-api.navigate.opened.next()| and |nvim-tree-api.navigate.opened.prev()|
Value can be `"none"`, `"icon"`, `"name"` or `"all"`.
Type: `string`, Default: `"none"`
*nvim-tree.renderer.highlight_modified*
Highlight icons and/or names for modified files using the
`NvimTreeModifiedFile` highlight group.
Requires |nvim-tree.modified.enable|
Value can be `"none"`, `"icon"`, `"name"` or `"all"`
Type: `string`, Default `"none"`
*nvim-tree.renderer.highlight_hidden*
Highlight icons and/or names for hidden files (dotfiles) using the
`NvimTreeHiddenFileHL` highlight group.
Value can be `"none"`, `"icon"`, `"name"` or `"all"`
Type: `string`, Default `"none"`
*nvim-tree.renderer.highlight_bookmarks*
Highlight bookmarked using the `NvimTreeBookmarkHL` group.
Value can be `"none"`, `"icon"`, `"name"` or `"all"`
Type: `string`, Default `"none"`
*nvim-tree.renderer.highlight_clipboard*
Enable highlight for clipboard items using the `NvimTreeCutHL` and
`NvimTreeCopiedHL` groups.
Value can be `"none"`, `"icon"`, `"name"` or `"all"`.
Type: `string`, Default: `"name"`
*nvim-tree.renderer.indent_markers*
Configuration options for tree indent markers.
*nvim-tree.renderer.indent_markers.enable*
Display indent markers when folders are open
Type: `boolean`, Default: `false`
*nvim-tree.renderer.indent_markers.inline_arrows*
Display folder arrows in the same column as indent marker
when using |renderer.icons.show.folder_arrow|
Type: `boolean`, Default: `true`
*nvim-tree.renderer.indent_markers.icons*
Icons shown before the file/directory. Length 1.
Type: `table`, Default: >lua
{
corner = "└",
edge = "│",
item = "│",
bottom = "─",
none = " ",
}
<
*nvim-tree.renderer.icons*
Configuration options for icons.
Icon order and sign column precedence:
git < hidden < modified < bookmarked < diagnostics