577 lines
18 KiB
Plaintext
577 lines
18 KiB
Plaintext
*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 `nightly (>= 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
|
|
|
|
|: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
|
|
|
|
==============================================================================
|
|
OPTIONS *nvim-tree-options*
|
|
|
|
|g:nvim_tree_width| *g:nvim_tree_width*
|
|
|
|
width of the window (default to 30)
|
|
|
|
|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_follow| *g:nvim_tree_follow*
|
|
|
|
Can be `0` or `1`. When `1`, will update the cursor to update to the correct
|
|
location in the tree on |BufEnter|.
|
|
Default is 0
|
|
|
|
|g:nvim_tree_auto_open| *g:nvim_tree_auto_open*
|
|
|
|
Can be `0` or `1`. When `1`, will open the tree when the package is loaded.
|
|
It's not relying on VimEnter anymore.
|
|
Default is 0
|
|
|
|
|g:nvim_tree_auto_close| *g:nvim_tree_auto_close*
|
|
|
|
Can be `0` or `1`. When `1`, will bind |BufEnter| to automatically
|
|
close the tree if it's the last window.
|
|
Default is 0
|
|
|
|
|g:nvim_tree_auto_ignore_ft| *g:nvim_tree_auto_ignore_ft*
|
|
|
|
Don't auto open the tree on specific filetypes.
|
|
Useful when you don't want to open tree on plugins like 'Startify'
|
|
Default is {}
|
|
>
|
|
example: let g.nvim_tree_auto_ignore_ft = {'startify', 'dashboard'}
|
|
|
|
|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_disable_keybindings| *g:nvim_tree_disable_keybindings*
|
|
|
|
Can be `0` or `1`. When `1`, will disable all keybindings by the plugin.
|
|
|g:nvim_tree_bindings| as well as default bindings will not take effect.
|
|
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_tab_open| *g:nvim_tree_tab_open*
|
|
|
|
Can be 0 or 1. When 1, will open the tree when entering a new tab if the
|
|
tree was previously open.
|
|
Default is 0
|
|
|
|
|g:nvim_tree_width_allow_resize| *g:nvim_tree_width_allow_resize*
|
|
|
|
Can be 0 or 1. When 1, it will not resize the tree to it's original width
|
|
when opening a new file.
|
|
Default is 0
|
|
|
|
|g:nvim_tree_hijack_netrw| *g:nvim_tree_hijack_netrw*
|
|
|
|
Can be 0 or 1. When 1, disable netrw buffers when nvim-tree start but keeps
|
|
existing netrw functionnalities accross buffers (like `gx`).
|
|
1 by default.
|
|
|
|
|g:nvim_tree_disable_netrw| *g:nvim_tree_disable_netrw*
|
|
|
|
Can be 0 or 1. When 1, completely disable netrw and all related
|
|
functionnalities.
|
|
1 by default.
|
|
|
|
|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_lsp_diagnostics| *g:nvim_tree_lsp_diagnostics*
|
|
|
|
Can be 0 or 1. When 1, will show nvim-lsp diagnostics in the signcolumn
|
|
of the tree highlighted by diagnostic severity.
|
|
Code will be executed on `LspDiagnosticsChanged`. 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_hijack_cursor| *g:nvim_tree_hijack_cursor*
|
|
|
|
Can be 0 or 1. 1 by default.
|
|
When 1, moving cursor in the tree will position the cursor at the start
|
|
of the file on the current line.
|
|
|
|
|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_update_cwd|
|
|
|
|
Can be 0 or 1. 0 by default.
|
|
Will update the tree cwd when changing nvim's directory (DirChanged event).
|
|
WARNING: Behaves strangely with autochdir set.
|
|
|
|
==============================================================================
|
|
INFORMATIONS *nvim-tree-info*
|
|
|
|
|KeyBindings| *nvim-tree-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 '<' 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-]>'
|
|
|
|
|g:nvim_tree_bindings| *g:nvim_tree_bindings*
|
|
|
|
You can disable default mappings with
|
|
>
|
|
let nvim_tree_disable_keybindings=1
|
|
<
|
|
But you won't be able to map any keys from the setup with nvim_tree_bindings. Use with caution.
|
|
|
|
Default keybindings can be overriden. You can also define your own keymappings for the tree view:
|
|
>
|
|
lua <<EOF
|
|
local tree_cb = require'nvim-tree.config'.nvim_tree_callback
|
|
vim.g.nvim_tree_bindings = {
|
|
["<CR>"] = ":YourVimFunction()<cr>",
|
|
["u"] = ":lua require'some_module'.some_function()<cr>",
|
|
|
|
-- default mappings
|
|
["<CR>"] = tree_cb("edit"),
|
|
["o"] = tree_cb("edit"),
|
|
["<2-LeftMouse>"] = tree_cb("edit"),
|
|
["<2-RightMouse>"] = tree_cb("cd"),
|
|
["<C-]>"] = tree_cb("cd"),
|
|
["<C-v>"] = tree_cb("vsplit"),
|
|
["<C-x>"] = tree_cb("split"),
|
|
["<C-t>"] = tree_cb("tabnew"),
|
|
["<"] = tree_cb("prev_sibling"),
|
|
[">"] = tree_cb("next_sibling"),
|
|
["P"] = tree_cb("parent_node"),
|
|
["<BS>"] = tree_cb("close_node"),
|
|
["<S-CR>"] = tree_cb("close_node"),
|
|
["<Tab>"] = tree_cb("preview"),
|
|
["K"] = tree_cb("first_sibling"),
|
|
["J"] = tree_cb("last_sibling"),
|
|
["I"] = tree_cb("toggle_ignored"),
|
|
["H"] = tree_cb("toggle_dotfiles"),
|
|
["R"] = tree_cb("refresh"),
|
|
["a"] = tree_cb("create"),
|
|
["d"] = tree_cb("remove"),
|
|
["r"] = tree_cb("rename"),
|
|
["<C-r>"] = tree_cb("full_rename"),
|
|
["x"] = tree_cb("cut"),
|
|
["c"] = tree_cb("copy"),
|
|
["p"] = tree_cb("paste"),
|
|
["[c"] = tree_cb("prev_git_item"),
|
|
["]c"] = tree_cb("next_git_item"),
|
|
["-"] = tree_cb("dir_up"),
|
|
["q"] = tree_cb("close"),
|
|
}
|
|
EOF
|
|
<
|
|
|
|
All mappings are set in `normal mode`.
|
|
|
|
|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)`.
|