@@ -71,12 +71,26 @@ require'nvim-tree'.setup {
71
71
-- the command arguments as a list
72
72
args = {}
73
73
},
74
+
75
+ view = {
76
+ -- width of the window, can be either a number (columns) or a string in `%`
77
+ width = 30 ,
78
+ -- side of the tree, can be one of 'left' | 'right' | 'top' | 'bottom'
79
+ side = ' left' ,
80
+ -- if true the tree will resize itself after opening a file
81
+ auto_resize = false ,
82
+ mappings = {
83
+ -- custom only false will merge the list with the default mappings
84
+ -- if true, it will only use your list to set the mappings
85
+ custom_only = false ,
86
+ -- list of mappings to set on the tree manually
87
+ list = {}
88
+ }
89
+ }
74
90
}
75
91
```
76
92
77
93
``` vim
78
- let g:nvim_tree_side = 'right' "left by default
79
- let g:nvim_tree_width = 40 "30 by default, can be width_in_columns or 'width_in_percent%'
80
94
let g:nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
81
95
let g:nvim_tree_gitignore = 1 "0 by default
82
96
let g:nvim_tree_quit_on_open = 1 "0 by default, closes the tree when you open a file
@@ -85,7 +99,6 @@ let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and fol
85
99
let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
86
100
let g:nvim_tree_highlight_opened_files = 1 "0 by default, will enable folder and file icon highlight for opened files/directories.
87
101
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
88
- let g:nvim_tree_auto_resize = 0 "1 by default, will resize the tree to its saved width when opening a file
89
102
let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names
90
103
let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree
91
104
let g:nvim_tree_disable_window_picker = 1 "0 by default, will disable the window picker.
@@ -155,7 +168,7 @@ let g:nvim_tree_icons = {
155
168
nnoremap <C-n> :NvimTreeToggle<CR>
156
169
nnoremap <leader>r :NvimTreeRefresh<CR>
157
170
nnoremap <leader>n :NvimTreeFindFile<CR>
158
- " NvimTreeOpen, NvimTreeClose and NvimTreeFocus are also available if you need them
171
+ " NvimTreeOpen, NvimTreeClose, NvimTreeFocus and NvimTreeResize are also available if you need them
159
172
160
173
set termguicolors " this variable must be enabled for colors to be applied properly
161
174
@@ -167,7 +180,6 @@ highlight NvimTreeFolderIcon guibg=blue
167
180
168
181
### Default actions
169
182
170
- - move around like in any vim buffer
171
183
- ` <CR> ` or ` o ` on ` .. ` will cd in the above directory
172
184
- ` <C-]> ` will cd in the directory under the cursor
173
185
- ` <BS> ` will close current opened directory or parent
@@ -198,88 +210,61 @@ highlight NvimTreeFolderIcon guibg=blue
198
210
- Double left click acts like ` <CR> `
199
211
- Double right click acts like ` <C-]> `
200
212
201
- ### Setup
202
-
203
- You can disable default mappings with
204
-
205
- ``` vim
206
- " let g:nvim_tree_disable_keybindings=1
207
- ```
208
-
209
- But you won't be able to map any keys from the setup with nvim_tree_bindings. Use with caution.
213
+ ### Settings
210
214
211
- You can use only your mappings with
212
-
213
- ``` vim
214
- let g:nvim_tree_disable_default_keybindings = 1
215
- ```
216
-
217
- You can define your own keymaps with this syntax:
218
-
219
- ``` vim
220
- lua <<EOF
221
- vim.g.nvim_tree_bindings = {
222
- { key = {"<CR>", "o" }, cb = ":lua some_func()<cr>"}
223
- { key = "<Tab>", mode = "v", cb = ":lua some_func()<cr>"}
224
- }
215
+ The ` list ` option in ` view.mappings.list ` is a table of
216
+ ``` lua
217
+ -- key can be either a string or a table of string (lhs)
218
+ -- cb is the callback that will be called
219
+ -- mode is normal by default
220
+ local list = {
221
+ { key = {" <CR>" , " o" }, cb = " :lua some_func()<cr>" , mode = " n" }
222
+ }
225
223
EOF
226
224
```
227
225
228
- Notes:
229
-
230
- - ` key ` can be either a string or a table of strings
231
- - ` mode ` is ` n ` by default if you don't specify it
232
- - ` cb ` is the command that will be called when the keymap is triggered
233
-
234
- If you don't use one of the options above, your keymaps will be added to the default keymaps.
235
-
236
- ``` vim
237
- lua <<EOF
238
- local tree_cb = require'nvim-tree.config'.nvim_tree_callback
239
- -- default mappings
240
- vim.g.nvim_tree_bindings = {
241
- { key = {"<CR>", "o", "<2-LeftMouse>"}, cb = tree_cb("edit") },
242
- { key = {"<2-RightMouse>", "<C-]>"}, cb = tree_cb("cd") },
243
- { key = "<C-v>", cb = tree_cb("vsplit") },
244
- { key = "<C-x>", cb = tree_cb("split") },
245
- { key = "<C-t>", cb = tree_cb("tabnew") },
246
- { key = "<", cb = tree_cb("prev_sibling") },
247
- { key = ">", cb = tree_cb("next_sibling") },
248
- { key = "P", cb = tree_cb("parent_node") },
249
- { key = "<BS>", cb = tree_cb("close_node") },
250
- { key = "<S-CR>", cb = tree_cb("close_node") },
251
- { key = "<Tab>", cb = tree_cb("preview") },
252
- { key = "K", cb = tree_cb("first_sibling") },
253
- { key = "J", cb = tree_cb("last_sibling") },
254
- { key = "I", cb = tree_cb("toggle_ignored") },
255
- { key = "H", cb = tree_cb("toggle_dotfiles") },
256
- { key = "R", cb = tree_cb("refresh") },
257
- { key = "a", cb = tree_cb("create") },
258
- { key = "d", cb = tree_cb("remove") },
259
- { key = "r", cb = tree_cb("rename") },
260
- { key = "<C-r>", cb = tree_cb("full_rename") },
261
- { key = "x", cb = tree_cb("cut") },
262
- { key = "c", cb = tree_cb("copy") },
263
- { key = "p", cb = tree_cb("paste") },
264
- { key = "y", cb = tree_cb("copy_name") },
265
- { key = "Y", cb = tree_cb("copy_path") },
266
- { key = "gy", cb = tree_cb("copy_absolute_path") },
267
- { key = "[c", cb = tree_cb("prev_git_item") },
268
- { key = "]c", cb = tree_cb("next_git_item") },
269
- { key = "-", cb = tree_cb("dir_up") },
270
- { key = "s", cb = tree_cb("system_open") },
271
- { key = "q", cb = tree_cb("close") },
272
- { key = "g?", cb = tree_cb("toggle_help") },
273
- }
274
- EOF
226
+ These are the default bindings:
227
+ ``` lua
228
+ local tree_cb = require ' nvim-tree.config' .nvim_tree_callback
229
+ -- default mappings
230
+ local list = {
231
+ { key = {" <CR>" , " o" , " <2-LeftMouse>" }, cb = tree_cb (" edit" ) },
232
+ { key = {" <2-RightMouse>" , " <C-]>" }, cb = tree_cb (" cd" ) },
233
+ { key = " <C-v>" , cb = tree_cb (" vsplit" ) },
234
+ { key = " <C-x>" , cb = tree_cb (" split" ) },
235
+ { key = " <C-t>" , cb = tree_cb (" tabnew" ) },
236
+ { key = " <" , cb = tree_cb (" prev_sibling" ) },
237
+ { key = " >" , cb = tree_cb (" next_sibling" ) },
238
+ { key = " P" , cb = tree_cb (" parent_node" ) },
239
+ { key = " <BS>" , cb = tree_cb (" close_node" ) },
240
+ { key = " <S-CR>" , cb = tree_cb (" close_node" ) },
241
+ { key = " <Tab>" , cb = tree_cb (" preview" ) },
242
+ { key = " K" , cb = tree_cb (" first_sibling" ) },
243
+ { key = " J" , cb = tree_cb (" last_sibling" ) },
244
+ { key = " I" , cb = tree_cb (" toggle_ignored" ) },
245
+ { key = " H" , cb = tree_cb (" toggle_dotfiles" ) },
246
+ { key = " R" , cb = tree_cb (" refresh" ) },
247
+ { key = " a" , cb = tree_cb (" create" ) },
248
+ { key = " d" , cb = tree_cb (" remove" ) },
249
+ { key = " r" , cb = tree_cb (" rename" ) },
250
+ { key = " <C-r>" , cb = tree_cb (" full_rename" ) },
251
+ { key = " x" , cb = tree_cb (" cut" ) },
252
+ { key = " c" , cb = tree_cb (" copy" ) },
253
+ { key = " p" , cb = tree_cb (" paste" ) },
254
+ { key = " y" , cb = tree_cb (" copy_name" ) },
255
+ { key = " Y" , cb = tree_cb (" copy_path" ) },
256
+ { key = " gy" , cb = tree_cb (" copy_absolute_path" ) },
257
+ { key = " [c" , cb = tree_cb (" prev_git_item" ) },
258
+ { key = " ]c" , cb = tree_cb (" next_git_item" ) },
259
+ { key = " -" , cb = tree_cb (" dir_up" ) },
260
+ { key = " s" , cb = tree_cb (" system_open" ) },
261
+ { key = " q" , cb = tree_cb (" close" ) },
262
+ { key = " g?" , cb = tree_cb (" toggle_help" ) },
263
+ }
275
264
```
276
265
277
266
You can toggle the help UI by pressing ` g? ` .
278
267
279
- ## Note
280
-
281
- This plugin is very fast because it uses the ` libuv ` ` scandir ` and ` scandir_next ` functions instead of spawning an ` ls ` process which can get slow on large files when combining with ` stat ` to get file informations.
282
-
283
268
## Features
284
269
285
270
- Open file in current buffer or in split with FzF like bindings (` <CR> ` , ` <C-v> ` , ` <C-x> ` , ` <C-t> ` )
0 commit comments