Skip to content
Alexander Courtis edited this page Jan 17, 2023 · 15 revisions

Create A Directory

You can add a directory by adding a / at the end of the path.

Entering multiple directories BASE/foo/bar/baz will add directory foo, then bar and add a file baz to it.

Change Window Options

You can update tree local window options for the tree by setting

require("nvim-tree.view").View.winopts.MY_OPTION = MY_OPTION_VALUE

Toggle Tree Without Focusing Explorer

toggle has a second parameter which allows to toggle without focusing the explorer, see :help nvim-tree.api.tree

require("nvim-tree.api").tree.toggle(false, true)

Vinegar

You can allow nvim-tree to behave like vinegar: :help nvim-tree-vinegar

Open On The Left

If you :set nosplitright, the files will open on the left side of the tree, placing the tree window in the right side of the file you opened.

Hide .git Directory

You can hide the .git folder via a custom filter, see :help nvim-tree.filters.custom

filters = { custom = { "^.git$" } }

Disable Icons

To disable the display of icons see :help nvim-tree.renderer.icons.show

Netrw Keeps Popping Up

Eagerly disable Netrw: :help nvim-tree.disable_netrw

Open vim-startify along with nvim-tree.lua on startup/setup

If you are using init.lua:

require("nvim-tree").setup{
  open_on_setup = true,
  ignore_buffer_on_setup = true,
}

If you are using init.vim:

lua << EOF
require("nvim-tree").setup{
  open_on_setup = true,
  ignore_buffer_on_setup = true,
}
EOF

Why this? Because, only open_on_setup = true, opens nvim-tree.lua on startup but doesn't open vim-startify

While open_on_setup = true, & ignore_buffer_on_setup = true, opens vim-startify along with nvim-tree.lua and puts the cursor in the vim-startify window

Don't Open nvim-tree When Creating Git Commit Message

Opening nvim-tree on setup adds little value when executing git commit ... and can be annoying when using update_focused_file. Stop it:

open_on_setup = true,
open_on_setup_file = true,
ignore_ft_on_setup = {
  "gitcommit",
},
Clone this wiki locally