forked from nvim-tree/nvim-tree.lua
/
nvim-tree-lua.txt
694 lines (536 loc) · 23 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
*nvim-tree.lua* A file explorer written in lua
Minimum version of neovim: 0.5.0
Author: Yazdani Kiyan <yazdani.kiyan@protonmail.com>
==============================================================================
INTRODUCTION *nvim-tree-introduction*
This file explorer requires `neovim >= 0.5.0`
==============================================================================
QUICK START *nvim-tree-quickstart*
open the tree with :NvimTreeToggle
>
nnoremap <C-n> :NvimTreeToggle<CR>
lua require 'nvim-tree'.toggle()
<
==============================================================================
COMMANDS *nvim-tree-commands*
|:NvimTreeOpen| *:NvimTreeOpen*
opens the tree
|:NvimTreeClose| *:NvimTreeClose*
closes the tree
|:NvimTreeToggle| *:NvimTreeToggle*
open or close the tree
|:NvimTreeFocus| *:NvimTreeFocus*
open the tree if it is closed, and then focus on the tree
|:NvimTreeRefresh| *:NvimTreeRefresh*
refresh the tree
|:NvimTreeFindFile| *: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`)
|:NvimTreeClipboard| *:NvimTreeClipboard*
Print clipboard content for both cut and copy
|:NvimTreeResize| *:NvimTreeResize*
Resize the NvimTree window to the given size. Example: `:NvimTreeresize 50`
resizes the window to the width of 50.
==============================================================================
SETUP *nvim-tree.setup*
To configure the tree (and make it runnable), you should call the setup
function.
>
require'nvim-tree'.setup {
disable_netrw = true,
hijack_netrw = true,
open_on_setup = false,
ignore_ft_on_setup = {},
update_to_buf_dir = {
enable = true,
auto_open = true,
},
auto_close = false,
open_on_tab = false,
hijack_cursor = false,
update_cwd = false,
lsp_diagnostics = false,
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {}
},
system_open = {
cmd = nil,
args = {}
},
view = {
width = 30,
height = 30,
side = 'left',
auto_resize = false,
mappings = {
custom_only = false,
list = {}
}
}
}
<
As options are currently being migrated, configuration of global options in
|nvim-tree-options| should be done BEFORE the setup call.
Here is a list of the options available in the setup call:
*nvim-tree.disable_netrw*
- |disable_netrw|: completely disable netrw
type: `boolean`
default: `true`
*nvim-tree.hijack_netrw*
- |hijack_netrw|: hijack netrw windows (overriden if |disable_netrw| is `true`)
type: `boolean`
default: `true`
*nvim-tree.open_on_setup*
- |open_on_setup|: will automatically open the tree when running setup if current
buffer is a directory, is empty or is unnamed.
type: `boolean`
default: `false`
*nvim-tree.ignore_ft_on_setup*
- |ignore_ft_on_setup|: list of filetypes that will make |open_on_setup| not
open. You can use this option if you don't want the tree to open in some
scenarios (eg using vim startify).
type: `{string}`
default: `{}`
*nvim-tree.auto_close*
- |auto_close|: force closing neovim when the tree is the last window in the view.
type: `boolean`
default: `false`
*nvim-tree.open_on_tab*
- |open_on_tab|: opens the tree automatically when switching tabpage or opening a new
tabpage if the tree was previously open.
type: `boolean`
default: `false`
*nvim-tree.update_to_buf_dir*
- |update_to_buf_dir|: hijacks new directory buffers when they are opened (`:e dir`).
- |update_to_buf_dir.enable|: enable the feature. Disable this option if you use vim-dirvish.
type: `boolean`
default: `true`
- |update_to_buf_dir.auto_open|: opens the tree if the tree was previously closed.
type: `boolean`
default: `true`
*nvim-tree.hijack_cursor*
- |hijack_cursor|: keeps the cursor on the first letter of the filename when
moving in the tree.
type: `boolean`
default: `false`
*nvim-tree.update_cwd*
- |update_cwd|: changes the tree root directory on `DirChanged` and refreshes
the tree.
type: `boolean`
default: `false`
*nvim-tree.update_focused_file*
- |update_focused_file|: update the focused file on `BufEnter`, un-collapses
the folders recursively until it finds the file
- |update_focused_file.enable|: enable this feature.
type: `boolean`
default: `false`
- |update_focused_file.update_cwd|: update the root directory of the tree to the one
of the folder containing the file if the file is not under the current root
directory. Only relevant when |update_focused_file.enable| is `true`
type: `boolean`
default: `false`
- |update_focused_file.ignore_list|: list of buffer names and filetypes that will not
update the root dir of the tree if the file isn't found under the current root
directory. Only relevant when |update_focused_file.update_cwd| is `true` and
|update_focused_file.enable| is `true`.
type: `{string}`
default: `{}`
*nvim-tree.system_open*
- |system_open|: configuration options for the system open command
- |system_open.cmd|: the command to run, leaving nil should work but
useful if you want to override the default command with another one.
type: `string`
default: `nil`
- |system_open.args|: the command arguments as a list
type: `{string}`
default: `{}`
*nvim-tree.lsp_diagnostics*
- |lsp_diagnostics|: show lsp diagnostics in the signcolumn
type: `boolean`
default: false
*nvim-tree.view*
- |view|: window / buffer setup
- |view.width|: width of the window, can be either a `%` string or
a number representing columns. Only works with |view.side| `left` or `right`
type: `string | number`
default: `30`
- |view.height|: height of the window, can be either a `%` string or
a number representing rows. Only works with |view.side| `top` or `bottom`
type: `string | number`
default: `30`
- |view.side|: side of the tree, can be one of 'left' | 'right' | 'bottom' | 'top'
Note that bottom/top are not working correctly yet.
type: `string`
default: 'left'
- |view.auto_resize|: auto resize the tree after opening a file
type: `boolean`
default: false
- |view.mappings|: configuration options for keymaps
- |view.mappings.custom_only|: will use only the provided user mappings and not the default
otherwise, extends the default mappings with the provided user mappings
type: `boolean`
default: false
- |view,mappings.list|: a list of keymaps that will extend or override the default keymaps
type: list of `{ key: table of strings or string, mode: string (vim-mode), cb: callback function as a string }`
default: {}
==============================================================================
OPTIONS *nvim-tree-options*
|g:nvim_tree_width| *g:nvim_tree_width*
width of the window, can be *width_in_columns* or *'width_in_percent%'*
>
let g:nvim_tree_width = 30 " indicates width of 30 columns
let g:nvim_tree_width = '30%' " indicates width of 30% of '&columns'
|g:nvim_tree_side| *g:nvim_tree_side*
where the window will open (default to 'left')
- 'left' or 'right'
|g:nvim_tree_ignore| *g:nvim_tree_ignore*
An array of strings that the tree won't load and display.
useful to hide large data/cache folders.
>
example: let g:nvim_tree_ignore = [ '.git', 'node_modules' ]
|g:nvim_tree_gitignore| *g:nvim_tree_gitignore*
Determines whether to include in g:nvim_tree_ignore
files ignored by git.
Must be:
0: not ignored
1: ignored files from `git ls-files --others --ignored --exclude-standard --directory`
>
|g:nvim_tree_show_icons| *g:nvim_tree_show_icons*
Dictionary, if your terminal or font doesn't support certain unicode
character, the tree UI might be messed up. The following configuration
can disable icons per type:
>
let g:nvim_tree_show_icons = {
\ 'git': 1,
\ 'folders': 1,
\ 'files': 1,
\ 'folder_arrows': 1,
\}
Can be one of `1` and `0` for each key. By default the tree will try
to render the icons. The `files` key can only work if `nvim-web-devicons`
is installed and in your |runtimepath|
(https://github.com/kyazdani42/nvim-web-devicons)
if folder is 1, you can also set `folder_arrows = 1` to show small arrows
next to the folder icons but this will not work when you set
|g:nvim_tree_indent_markers| (because of UI conflict).
|g:nvim_tree_highlight_opened_files| *g:nvim_tree_highlight_opened_files*
Highlight icons and/or names for opened files and directories
Default is 0
Must be:
0: No highlight
1: Enable highligting for folders and file icons only.
2: Enable highligting for folders and file names only.
3: Enable highligting for folders and both file icons and names.
|g:nvim_tree_icons| *g:nvim_tree_icons*
You can set icons for:
- The git status.
- The default icon that shows when no icon is found for a file
or if you are not using icons.
- Symlinks. If an icon is not provided, the `default` icon is used.
>
let g:nvim_tree_icons = {
\ 'default': '',
\ 'symlink': '',
\ 'git': {
\ 'unstaged': "✗",
\ 'staged': "✓",
\ 'unmerged': "",
\ 'renamed': "➜",
\ 'untracked': "★",
\ 'deleted': "",
\ },
\ 'folder': {
\ 'arrow_open': "",
\ 'arrow_closed': "",
\ 'default': "",
\ 'open': "",
\ 'empty': "",
\ 'empty_open': "",
\ 'symlink': "",
\ 'symlink_open': "",
\ },
\ 'lsp': {
\ 'hint': "",
\ 'info': "",
\ 'warning': "",
\ 'error': "",
\ }
\ }
|g:nvim_tree_git_hl| *g:nvim_tree_git_hl*
You can enable file highlight for git attributes by setting this property.
This can be used with or without the icons.
|g:nvim_tree_quit_on_open| *g:nvim_tree_quit_on_open*
Can be `0` or `1`. When `1`, will close the tree when a file is opened.
Applies to: `edit`, `vsplit`, `split`, `tabnew`.
Default is 0
|g:nvim_tree_indent_markers| *g:nvim_tree_indent_markers*
Can be `0` or `1`. When `1`, will display indent markers when folders are open
Default is 0
|g:nvim_tree_hide_dotfiles| *g:nvim_tree_hide_dotfiles*
Can be `0` or `1`. When `1`, will hide dotfiles, files or folders which start
with the `.` character.
Default is 0
|g:nvim_tree_root_folder_modifier| *g:nvim_tree_root_folder_modifier*
In what format to show root folder. See `:help filename-modifiers` for
available options.
Default is `:~`
|g:nvim_tree_add_trailing| *g:nvim_tree_add_trailing*
Can be 0 or 1. When 1, appends a trailing slash to folder names.
0 by default.
|g:nvim_tree_group_empty| *g:nvim_tree_group_empty*
Can be 0 or 1. When 1, folders that contain only one folder are grouped
together. 0 by default.
|g:nvim_tree_special_files| *g:nvim_tree_special_files*
A list of filenames that gets highlighted with `NvimTreeSpecialFile`.
default table is
>
{
["Cargo.toml"] = true,
Makefile = true,
["README.md"] = true,
["readme.md"] = true,
}
|g:nvim_tree_disable_window_picker| *g:nvim_tree_disable_window_picker*
Can be 0 or 1. When 1, will disable the window picker. Files will open in the
window from which you last opened NvimTree.
|g:nvim_tree_window_picker_chars| *g:nvim_tree_window_picker_chars*
A string of chars used as identifiers by the window picker.
`"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"` by default.
|g:nvim_tree_window_picker_exclude| *g:nvim_tree_window_picker_exclude*
Dictionary of buffer option names mapped to a list of option values that
indicates to the window picker that the buffer's window should not be
selectable. The default table is
>
{
filetype = {
"packer",
"qf"
}
}
<
|g:nvim_tree_icon_padding| *g:nvim_tree_icon_padding*
One space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
|g:nvim_tree_symlink_arrow| *g:nvim_tree_symlink_arrow*
Defaults to ' ➛ '. Used as a separator between symlinks' source and target.
|g:nvim_tree_respect_buf_cwd| *g:nvim_tree_respect_buf_cwd*
Can be 0 or 1. 0 by default.
Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
|g:nvim_tree_create_in_closed_folder| *g:nvim_tree_create_in_closed_folder*
Can be 0 or 1. 1 by default.
Creating a file when the cursor is on a closed folder will set the
path to be inside the closed folder when 1, and on the parent folder when 0.
==============================================================================
INFORMATIONS *nvim-tree-info*
|Mappings| *nvim-tree-mappings*
- type `g?` to see the help UI with keybindings
- move around like in any vim buffer
- '<CR>' on '..' will cd in the above directory
- typing '<C-]>' will cd in the directory under the cursor
- typing '<BS>' will close current opened directory or parent
- typing 'P' will move cursor to the parent directory
- type 'a' to add a file
- type 'r' to rename a file
- type `<C-r>` to rename a file and omit the filename on input
- type 'x' to add/remove file/directory to cut clipboard
- type 'c' to add/remove file/directory to copy clipboard
- type 'p' to paste from clipboard. Cut clipboard has precedence over copy
(will prompt for confirmation)
- type 'd' to delete a file (will prompt for confirmation)
- type ']c' to go to next git item
- type '[c' to go to prev git item
- type '-' to navigate up one directory
- type 's' to open a file with default system application or a folder with default file manager
- type '<' to navigate to the previous sibling of current file/directory
- type '>' to navigate to the next sibling of current file/directory
- type 'J' to navigate to the first sibling of current file/directory
- type 'K' to navigate to the last sibling of current file/directory
- if the file is a directory, '<CR>' will open the directory
- otherwise it will open the file in the buffer near the tree
- if the file is a symlink, '<CR>' will follow the symlink
- '<C-v>' will open the file in a vertical split
- '<C-x>' will open the file in a horizontal split
- '<C-t>' will open the file in a new tab
- '<Tab>' will open the file as a preview (keeps the cursor in the tree)
- 'I' will toggle visibility of folders hidden via |g:nvim_tree_ignore|
- 'R' will refresh the tree
- Double left click acts like '<CR>'
- Double right click acts like '<C-]>'
Defaults to:
>
lua <<EOF
local tree_cb = require'nvim-tree.config'.nvim_tree_callback
local list = {
{ key = {"<CR>", "o", "<2-LeftMouse>"}, cb = tree_cb("edit") },
{ key = {"<2-RightMouse>", "<C-]>"}, cb = tree_cb("cd") },
{ key = "<C-v>", cb = tree_cb("vsplit") },
{ key = "<C-x>", cb = tree_cb("split") },
{ key = "<C-t>", cb = tree_cb("tabnew") },
{ key = "<", cb = tree_cb("prev_sibling") },
{ key = ">", cb = tree_cb("next_sibling") },
{ key = "P", cb = tree_cb("parent_node") },
{ key = "<BS>", cb = tree_cb("close_node") },
{ key = "<S-CR>", cb = tree_cb("close_node") },
{ key = "<Tab>", cb = tree_cb("preview") },
{ key = "K", cb = tree_cb("first_sibling") },
{ key = "J", cb = tree_cb("last_sibling") },
{ key = "I", cb = tree_cb("toggle_ignored") },
{ key = "H", cb = tree_cb("toggle_dotfiles") },
{ key = "R", cb = tree_cb("refresh") },
{ key = "a", cb = tree_cb("create") },
{ key = "d", cb = tree_cb("remove") },
{ key = "r", cb = tree_cb("rename") },
{ key = "<C-r>", cb = tree_cb("full_rename") },
{ key = "x", cb = tree_cb("cut") },
{ key = "c", cb = tree_cb("copy") },
{ key = "p", cb = tree_cb("paste") },
{ key = "y", cb = tree_cb("copy_name") },
{ key = "Y", cb = tree_cb("copy_path") },
{ key = "gy", cb = tree_cb("copy_absolute_path") },
{ key = "[c", cb = tree_cb("prev_git_item") },
{ key = "]c", cb = tree_cb("next_git_item") },
{ key = "-", cb = tree_cb("dir_up") },
{ key = "s", cb = tree_cb("system_open") },
{ key = "q", cb = tree_cb("close") },
{ key = "g?", cb = tree_cb("toggle_help") },
}
<
|Features| *nvim-tree-features*
File icons with vim-devicons.
Uses other type of icons so a good font support is recommended.
If the tree renders weird glyphs, install the correct fonts.
Syntax highlighting uses g:terminal_color_ from colorschemes, fallbacks to
ugly colors otherwise.
Git integration tells when a file is:
- ✗ unstaged or folder is dirty
- ✓ staged
- ★ new file
- ✓ ✗ partially staged
- ✓ ★ new file staged
- ✓ ★ ✗ new file staged and has unstaged modifications
- ═ merging
- ➜ renamed
Mouse support defined in |KeyBindings|
==============================================================================
HIGHLIGHT GROUPS *nvim-tree-highlight*
|nvim_tree_highlight| *nvim_tree_highlight*
All the following highlight groups can be configured by hand. It is not
advised to colorize the background of these groups.
Example (in your `init.vim`):
>
highlight NvimTreeSymlink guifg=blue gui=bold,underline
<
You should have 'termguicolors' enabled, otherwise, colors will not be
applied.
NvimTreeSymlink
NvimTreeFolderName
NvimTreeRootFolder
NvimTreeFolderIcon
NvimTreeEmptyFolderName
NvimTreeOpenedFolderName
NvimTreeExecFile
NvimTreeOpenedFile
NvimTreeSpecialFile
NvimTreeImageFile
NvimTreeMarkdownFile
NvimTreeIndentMarker
LspDiagnosticsError
LspDiagnosticsWarning
LspDiagnosticsInformation
LspDiagnosticsHint
NvimTreeLicenseIcon
NvimTreeYamlIcon
NvimTreeTomlIcon
NvimTreeGitignoreIcon
NvimTreeJsonIcon
NvimTreeLuaIcon
NvimTreePythonIcon
NvimTreeShellIcon
NvimTreeJavascriptIcon
NvimTreeCIcon
NvimTreeReactIcon
NvimTreeHtmlIcon
NvimTreeRustIcon
NvimTreeVimIcon
NvimTreeTypescriptIcon
NvimTreeGitDirty
NvimTreeGitStaged
NvimTreeGitMerge
NvimTreeGitRenamed
NvimTreeGitNew
NvimTreeGitDeleted
There are also links to normal bindings to style the tree itself.
Normal
EndOfBuffer
CursorLine
VertSplit
CursorColumn
There are also links for file highlight with git properties
These all link to there Git equivalent
NvimTreeFileDirty
NvimTreeFileStaged
NvimTreeFileMerge
NvimTreeFileRenamed
NvimTreeFileNew
NvimTreeFileDeleted
vim:tw=78:ts=8:noet:ft=help:norl:
==============================================================================
EVENTS *nvim-tree-events*
|nvim_tree_events| *nvim_tree_events*
nvim-tree will dispatch events whenever an action is made. These events can be
subscribed to through handler functions. This allows for even further
customization of nvim-tree.
A handler for an event is just a function which receives one argument -
the payload of the event. The payload is different for each event type. Refer
to |nvim_tree_registering_handlers| for more information.
<
|nvim_tree_registering_handlers| *nvim_tree_registering_handlers*
Handlers are registered by calling the `on_*` functions available in the
`require('nvim-tree.events')` module. See |nvim-tree.events|.
For example, registering a handler for when a node is renamed is done like this: >
local events = require('nvim-tree.events')
events.on_node_renamed(function(data)
print("Node renamed from " .. data.old_name .. " to " .. data.new_name)
end)
==============================================================================
Lua module: nvim-tree.events *nvim-tree.events*
*nvim-tree.events.on_nvim_tree_ready()*
on_nvim_tree_ready({handler})
Registers a handler for when NvimTree has been initialized.
Parameters: ~
{handler} (function) Handler function, with the
signature `function()`.
*nvim-tree.events.on_node_renamed()*
on_node_renamed({handler})
Registers a handler for when a node is renamed.
• Note: A node can either be a file or a directory.
Parameters: ~
{handler} (function) Handler function, with the
signature `function(payload)`.
*nvim-tree.events.on_file_created()*
on_file_created({handler})
Registers a handler for when a file is created.
Parameters: ~
{handler} (function) Handler function, with the
signature `function(payload)`.
*nvim-tree.events.on_file_removed()*
on_file_removed({handler})
Registers a handler for when a file is removed.
Parameters: ~
{handler} (function) Handler function, with the
signature `function(payload)`.
*nvim-tree.events.on_folder_created()*
on_folder_created({handler})
Registers a handler for when a folder is created.
Parameters: ~
{handler} (function) Handler function, with the
signature `function(payload)`.
*nvim-tree.events.on_folder_removed()*
on_folder_removed({handler})
Registers a handler for when a folder is removed.
Parameters: ~
{handler} (function) Handler function, with the
signature `function(payload)`.