@@ -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
@@ -86,7 +100,6 @@ let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git att
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_hide_root_folder = 1 "0 by default, will hide the current working directory on top of the tree"
88
102
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
89
- let g:nvim_tree_auto_resize = 0 "1 by default, will resize the tree to its saved width when opening a file
90
103
let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names
91
104
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
92
105
let g:nvim_tree_disable_window_picker = 1 "0 by default, will disable the window picker.
@@ -156,7 +169,7 @@ let g:nvim_tree_icons = {
156
169
nnoremap <C-n> :NvimTreeToggle<CR>
157
170
nnoremap <leader>r :NvimTreeRefresh<CR>
158
171
nnoremap <leader>n :NvimTreeFindFile<CR>
159
- " NvimTreeOpen, NvimTreeClose and NvimTreeFocus are also available if you need them
172
+ " NvimTreeOpen, NvimTreeClose, NvimTreeFocus and NvimTreeResize are also available if you need them
160
173
161
174
set termguicolors " this variable must be enabled for colors to be applied properly
162
175
@@ -168,7 +181,6 @@ highlight NvimTreeFolderIcon guibg=blue
168
181
169
182
### Default actions
170
183
171
- - move around like in any vim buffer
172
184
- ` <CR> ` or ` o ` on ` .. ` will cd in the above directory
173
185
- ` <C-]> ` will cd in the directory under the cursor
174
186
- ` <BS> ` will close current opened directory or parent
@@ -199,88 +211,61 @@ highlight NvimTreeFolderIcon guibg=blue
199
211
- Double left click acts like ` <CR> `
200
212
- Double right click acts like ` <C-]> `
201
213
202
- ### Setup
203
-
204
- You can disable default mappings with
205
-
206
- ``` vim
207
- " let g:nvim_tree_disable_keybindings=1
208
- ```
209
-
210
- But you won't be able to map any keys from the setup with nvim_tree_bindings. Use with caution.
214
+ ### Settings
211
215
212
- You can use only your mappings with
213
-
214
- ``` vim
215
- let g:nvim_tree_disable_default_keybindings = 1
216
- ```
217
-
218
- You can define your own keymaps with this syntax:
219
-
220
- ``` vim
221
- lua <<EOF
222
- vim.g.nvim_tree_bindings = {
223
- { key = {"<CR>", "o" }, cb = ":lua some_func()<cr>"}
224
- { key = "<Tab>", mode = "v", cb = ":lua some_func()<cr>"}
225
- }
216
+ The ` list ` option in ` view.mappings.list ` is a table of
217
+ ``` lua
218
+ -- key can be either a string or a table of string (lhs)
219
+ -- cb is the callback that will be called
220
+ -- mode is normal by default
221
+ local list = {
222
+ { key = {" <CR>" , " o" }, cb = " :lua some_func()<cr>" , mode = " n" }
223
+ }
226
224
EOF
227
225
```
228
226
229
- Notes:
230
-
231
- - ` key ` can be either a string or a table of strings
232
- - ` mode ` is ` n ` by default if you don't specify it
233
- - ` cb ` is the command that will be called when the keymap is triggered
234
-
235
- If you don't use one of the options above, your keymaps will be added to the default keymaps.
236
-
237
- ``` vim
238
- lua <<EOF
239
- local tree_cb = require'nvim-tree.config'.nvim_tree_callback
240
- -- default mappings
241
- vim.g.nvim_tree_bindings = {
242
- { key = {"<CR>", "o", "<2-LeftMouse>"}, cb = tree_cb("edit") },
243
- { key = {"<2-RightMouse>", "<C-]>"}, cb = tree_cb("cd") },
244
- { key = "<C-v>", cb = tree_cb("vsplit") },
245
- { key = "<C-x>", cb = tree_cb("split") },
246
- { key = "<C-t>", cb = tree_cb("tabnew") },
247
- { key = "<", cb = tree_cb("prev_sibling") },
248
- { key = ">", cb = tree_cb("next_sibling") },
249
- { key = "P", cb = tree_cb("parent_node") },
250
- { key = "<BS>", cb = tree_cb("close_node") },
251
- { key = "<S-CR>", cb = tree_cb("close_node") },
252
- { key = "<Tab>", cb = tree_cb("preview") },
253
- { key = "K", cb = tree_cb("first_sibling") },
254
- { key = "J", cb = tree_cb("last_sibling") },
255
- { key = "I", cb = tree_cb("toggle_ignored") },
256
- { key = "H", cb = tree_cb("toggle_dotfiles") },
257
- { key = "R", cb = tree_cb("refresh") },
258
- { key = "a", cb = tree_cb("create") },
259
- { key = "d", cb = tree_cb("remove") },
260
- { key = "r", cb = tree_cb("rename") },
261
- { key = "<C-r>", cb = tree_cb("full_rename") },
262
- { key = "x", cb = tree_cb("cut") },
263
- { key = "c", cb = tree_cb("copy") },
264
- { key = "p", cb = tree_cb("paste") },
265
- { key = "y", cb = tree_cb("copy_name") },
266
- { key = "Y", cb = tree_cb("copy_path") },
267
- { key = "gy", cb = tree_cb("copy_absolute_path") },
268
- { key = "[c", cb = tree_cb("prev_git_item") },
269
- { key = "]c", cb = tree_cb("next_git_item") },
270
- { key = "-", cb = tree_cb("dir_up") },
271
- { key = "s", cb = tree_cb("system_open") },
272
- { key = "q", cb = tree_cb("close") },
273
- { key = "g?", cb = tree_cb("toggle_help") },
274
- }
275
- EOF
227
+ These are the default bindings:
228
+ ``` lua
229
+ local tree_cb = require ' nvim-tree.config' .nvim_tree_callback
230
+ -- default mappings
231
+ local list = {
232
+ { key = {" <CR>" , " o" , " <2-LeftMouse>" }, cb = tree_cb (" edit" ) },
233
+ { key = {" <2-RightMouse>" , " <C-]>" }, cb = tree_cb (" cd" ) },
234
+ { key = " <C-v>" , cb = tree_cb (" vsplit" ) },
235
+ { key = " <C-x>" , cb = tree_cb (" split" ) },
236
+ { key = " <C-t>" , cb = tree_cb (" tabnew" ) },
237
+ { key = " <" , cb = tree_cb (" prev_sibling" ) },
238
+ { key = " >" , cb = tree_cb (" next_sibling" ) },
239
+ { key = " P" , cb = tree_cb (" parent_node" ) },
240
+ { key = " <BS>" , cb = tree_cb (" close_node" ) },
241
+ { key = " <S-CR>" , cb = tree_cb (" close_node" ) },
242
+ { key = " <Tab>" , cb = tree_cb (" preview" ) },
243
+ { key = " K" , cb = tree_cb (" first_sibling" ) },
244
+ { key = " J" , cb = tree_cb (" last_sibling" ) },
245
+ { key = " I" , cb = tree_cb (" toggle_ignored" ) },
246
+ { key = " H" , cb = tree_cb (" toggle_dotfiles" ) },
247
+ { key = " R" , cb = tree_cb (" refresh" ) },
248
+ { key = " a" , cb = tree_cb (" create" ) },
249
+ { key = " d" , cb = tree_cb (" remove" ) },
250
+ { key = " r" , cb = tree_cb (" rename" ) },
251
+ { key = " <C-r>" , cb = tree_cb (" full_rename" ) },
252
+ { key = " x" , cb = tree_cb (" cut" ) },
253
+ { key = " c" , cb = tree_cb (" copy" ) },
254
+ { key = " p" , cb = tree_cb (" paste" ) },
255
+ { key = " y" , cb = tree_cb (" copy_name" ) },
256
+ { key = " Y" , cb = tree_cb (" copy_path" ) },
257
+ { key = " gy" , cb = tree_cb (" copy_absolute_path" ) },
258
+ { key = " [c" , cb = tree_cb (" prev_git_item" ) },
259
+ { key = " ]c" , cb = tree_cb (" next_git_item" ) },
260
+ { key = " -" , cb = tree_cb (" dir_up" ) },
261
+ { key = " s" , cb = tree_cb (" system_open" ) },
262
+ { key = " q" , cb = tree_cb (" close" ) },
263
+ { key = " g?" , cb = tree_cb (" toggle_help" ) },
264
+ }
276
265
```
277
266
278
267
You can toggle the help UI by pressing ` g? ` .
279
268
280
- ## Note
281
-
282
- 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.
283
-
284
269
## Features
285
270
286
271
- Open file in current buffer or in split with FzF like bindings (` <CR> ` , ` <C-v> ` , ` <C-x> ` , ` <C-t> ` )
0 commit comments