-
-
Notifications
You must be signed in to change notification settings - Fork 625
Tips
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.
You can update tree local window options for the tree by setting
require("nvim-tree.view").View.winopts.MY_OPTION = MY_OPTION_VALUE
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)
You can allow nvim-tree to behave like vinegar: :help nvim-tree-vinegar
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.
You can hide the .git
folder via a custom filter, see :help nvim-tree.filters.custom
filters = { custom = { "^.git$" } }
To disable the display of icons see :help nvim-tree.renderer.icons.show
Eagerly disable Netrw: :help nvim-tree.disable_netrw
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
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",
},
nvim-tree can behave like vinegar. To allow this, you will need to configure it in a specific way:
Use require"nvim-tree".open_replacing_current_buffer()
instead of the default open command. You can easily implement a toggle using this too:
local function toggle_replace()
local view = require"nvim-tree.view"
local api = require"nvim-tree.api"
if view.is_visible() then
api.tree.close()
else
require"nvim-tree".open_replacing_current_buffer()
end
end
Use the edit_in_place
action to edit files. It's bound to <C-e>
by default, vinegar uses <CR>
. You can override this with:
require"nvim-tree".setup {
view = {
mappings = {
list = {
{ key = "<CR>", action = "edit_in_place" }
}
}
}
}
Going up a dir is bound to -
by default in nvim-tree which is identical to vinegar, no change is needed here.
You'll also need to set nvim-tree.hijack_netrw
to true
during setup. A good functionality to enable is nvim-tree.hijack_directories
.