*nvim-tree.lua* A file explorer written in lua Minimum version of neovim: 0.5.0 Author: Yazdani Kiyan ============================================================================== INTRODUCTION *nvim-tree-introduction* This file explorer requires `neovim >= 0.5.0` ============================================================================== QUICK START *nvim-tree-quickstart* open the tree with :NvimTreeToggle > nnoremap :NvimTreeToggle 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 |:NvimTreeFocus| *:NvimTreeFocus* open the tree if it is closed, and then focus on 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`) |:NvimTreeFindFileToggle| *:NvimTreeFindFileToggle* close the tree or change the cursor in the tree for the current bufname, similar to combination of |:NvimTreeToggle| and |:NvimTreeFindFile| |:NvimTreeClipboard| *:NvimTreeClipboard* Print clipboard content for both cut and copy |:NvimTreeResize| *:NvimTreeResize* Resize the NvimTree window to the given size. Example: `:NvimTreeresize 50` resizes the window to the width of 50. ============================================================================== SETUP *nvim-tree.setup* To configure the tree (and make it runnable), you should call the setup function. > require'nvim-tree'.setup { disable_netrw = true, hijack_netrw = true, open_on_setup = false, ignore_ft_on_setup = {}, update_to_buf_dir = { enable = true, auto_open = true, }, auto_close = false, open_on_tab = false, hijack_cursor = false, update_cwd = false, diagnostics = { enable = false, show_on_dirs = false, icons = { hint = "", info = "", warning = "", error = "", } }, update_focused_file = { enable = false, update_cwd = false, ignore_list = {} }, system_open = { cmd = nil, args = {} }, git = { enable = true, ignore = true, }, view = { width = 30, height = 30, side = 'left', auto_resize = false, number = false, relativenumber = false, signcolumn = "yes" mappings = { custom_only = false, list = {} } }, filters = { dotfiles = false, custom = {} }, trash = { cmd = "trash", require_confirm = true, } } < As options are currently being migrated, configuration of global options in |nvim-tree-options| should be done BEFORE the setup call. Here is a list of the options available in the setup call: *nvim-tree.disable_netrw* - |disable_netrw|: completely disable netrw type: `boolean` default: `true` *nvim-tree.hijack_netrw* - |hijack_netrw|: hijack netrw windows (overriden if |disable_netrw| is `true`) type: `boolean` default: `true` *nvim-tree.open_on_setup* - |open_on_setup|: will automatically open the tree when running setup if current buffer is a directory, is empty or is unnamed. type: `boolean` default: `false` *nvim-tree.ignore_ft_on_setup* - |ignore_ft_on_setup|: list of filetypes that will make |open_on_setup| not open. You can use this option if you don't want the tree to open in some scenarios (eg using vim startify). type: `{string}` default: `{}` *nvim-tree.auto_close* - |auto_close|: force closing neovim when the tree is the last window in the view. type: `boolean` default: `false` *nvim-tree.open_on_tab* - |open_on_tab|: opens the tree automatically when switching tabpage or opening a new tabpage if the tree was previously open. type: `boolean` default: `false` *nvim-tree.update_to_buf_dir* - |update_to_buf_dir|: hijacks new directory buffers when they are opened (`:e dir`). - |update_to_buf_dir.enable|: enable the feature. Disable this option if you use vim-dirvish. type: `boolean` default: `true` - |update_to_buf_dir.auto_open|: opens the tree if the tree was previously closed. type: `boolean` default: `true` *nvim-tree.hijack_cursor* - |hijack_cursor|: keeps the cursor on the first letter of the filename when moving in the tree. type: `boolean` default: `false` *nvim-tree.update_cwd* - |update_cwd|: changes the tree root directory on `DirChanged` and refreshes the tree. type: `boolean` default: `false` *nvim-tree.update_focused_file* - |update_focused_file|: update the focused file on `BufEnter`, un-collapses the folders recursively until it finds the file - |update_focused_file.enable|: enable this feature. type: `boolean` default: `false` - |update_focused_file.update_cwd|: update the root directory of the tree to the one of the folder containing the file if the file is not under the current root directory. Only relevant when |update_focused_file.enable| is `true` type: `boolean` default: `false` - |update_focused_file.ignore_list|: list of buffer names and filetypes that will not update the root dir of the tree if the file isn't found under the current root directory. Only relevant when |update_focused_file.update_cwd| is `true` and |update_focused_file.enable| is `true`. type: `{string}` default: `{}` *nvim-tree.system_open* - |system_open|: configuration options for the system open command - |system_open.cmd|: the command to run, leaving nil should work but useful if you want to override the default command with another one. type: `string` default: `nil` - |system_open.args|: the command arguments as a list type: `{string}` default: `{}` *nvim-tree.diagnostics* - |diagnostics|: show lsp diagnostics in the signcolumn - |diagnostics.enable|: enable/disable the feature type: `boolean` default: `false` - diagnostics.show_on_dirs: if the node with diagnostic is not visible, then show diagnostic in the parent directory type: `boolean` default: `false` - |diagnostics.icons|: icons for diagnostic severity type: `table` default: `{ hint = "", info = "", warning = "", error = "" }` `NOTE`: it will use the default diagnostic color groups to highlight the signs. If you wish to customize, you can override these groups: - `NvimTreeLspDiagnosticsError` - `NvimTreeLspDiagnosticsWarning` - `NvimTreeLspDiagnosticsInformation` - `NvimTreeLspDiagnosticsHint` *nvim-tree.git* - |git|: git integration with icons and colors - |git.enable|: enable / disable the feature type: `boolean` default: `true` - |git.ignore|: ignore files based on `.gitignore`. will add `ignored=matching` to the integration when `true`. Otherwise will add `ignored=no` to the integration which can lead to better performance. - |git.timeout|: kills the git process after some time if it takes too long type: `number` default: `400` (ms) You will still need to configure `g:nvim_tree_show_icons.git` or `g:nvim_tree_git_hl` to be able to see things in the tree. This will be changed in the future versions. The configurable timeout will kill the current process and so disable the git integration for the project that takes too long. The git integration is blocking, so if your timeout is too long (like not in milliseconds but a few seconds), it will not render anything until the git process returned the data. *nvim-tree.view* - |view|: window / buffer setup - |view.hide_root_folder|: hide the path of the current working directory on top of the tree type: `boolean` default: `false` - |view.width|: width of the window, can be either a `%` string or a number representing columns. Only works with |view.side| `left` or `right` type: `string | number` default: `30` - |view.height|: height of the window, can be either a `%` string or a number representing rows. Only works with |view.side| `top` or `bottom` type: `string | number` default: `30` - |view.side|: side of the tree, can be one of 'left' | 'right' | 'bottom' | 'top' Note that bottom/top are not working correctly yet. type: `string` default: 'left' - |view.auto_resize|: auto resize the tree after opening a file type: `boolean` default: false - |view.number|: print the line number in front of each line. type: `boolean` default: false - |view.relativenumber|: show the line number relative to the line with the cursor in front of each line. If the option `view.number` is also `true`, the number on the cursor line will be the line number instead of `0`. type: `boolean` default: false - |view.signcolumn|: show diagnostic sign column. Value can be `"yes"`, `"auto"`, `"no"` type: `string` default: `"yes"` - |view.mappings|: configuration options for keymaps - |view.mappings.custom_only|: will use only the provided user mappings and not the default otherwise, extends the default mappings with the provided user mappings type: `boolean` default: false - |view.mappings.list|: a list of keymaps that will extend or override the default keymaps type: list of `{ key: table of strings or string, mode: string (vim-mode), cb: callback function as a string }` default: {} *nvim-tree.filters* |filters|: filtering options - |filters.dotfiles|: do not show `dotfiles` (files starting with a `.`) type: `boolean` default: `false` - |filters.custom|: custom list of string that will not be shown. type: `{string}` default: `{}` *nvim-tree.trash* |trash|: configuration options for trashing - |trash.cmd|: the command used to trash items (must be installed on your system) type: `string` default: `"trash"` - |trash.require_confirm|: show a prompt before trashing takes place. type: `boolean` default: `true` ============================================================================== OPTIONS *nvim-tree-options* |g:nvim_tree_width| *g:nvim_tree_width* width of the window, can be *width_in_columns* or *'width_in_percent%'* > let g:nvim_tree_width = 30 " indicates width of 30 columns let g:nvim_tree_width = '30%' " indicates width of 30% of '&columns' |g:nvim_tree_side| *g:nvim_tree_side* where the window will open (default to 'left') - 'left' or 'right' |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_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_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_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_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_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_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_symlink_arrow| *g:nvim_tree_symlink_arrow* Defaults to ' ➛ '. Used as a separator between symlinks' source and target. |g:nvim_tree_respect_buf_cwd| *g:nvim_tree_respect_buf_cwd* Can be 0 or 1. 0 by default. Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree. |g:nvim_tree_create_in_closed_folder| *g:nvim_tree_create_in_closed_folder* Can be 0 or 1. 1 by default. Creating a file when the cursor is on a closed folder will set the path to be inside the closed folder when 1, and on the parent folder when 0. ============================================================================== INFORMATIONS *nvim-tree-info* |Mappings| *nvim-tree-mappings* - type `g?` to see the help UI with keybindings - move around like in any vim buffer - '' on '..' will cd in the above directory - typing '' will cd in the directory under the cursor - typing '' 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 `` 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 's' to open a file with default system application or a folder with default file manager - 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, '' will open the directory - otherwise it will open the file in the buffer near the tree - if the file is a symlink, '' will follow the symlink - '' will open the file in a vertical split - '' will open the file in a horizontal split - '' will open the file in a new 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 '' - Double right click acts like '' Defaults to: > lua <", "o", "<2-LeftMouse>"}, cb = tree_cb("edit") }, { key = {"<2-RightMouse>", ""}, cb = tree_cb("cd") }, { key = "", cb = tree_cb("vsplit") }, { key = "", cb = tree_cb("split") }, { key = "", cb = tree_cb("tabnew") }, { key = "<", cb = tree_cb("prev_sibling") }, { key = ">", cb = tree_cb("next_sibling") }, { key = "P", cb = tree_cb("parent_node") }, { key = "", cb = tree_cb("close_node") }, { key = "", cb = tree_cb("close_node") }, { key = "", cb = tree_cb("preview") }, { key = "K", cb = tree_cb("first_sibling") }, { key = "J", cb = tree_cb("last_sibling") }, { key = "I", cb = tree_cb("toggle_ignored") }, { key = "H", cb = tree_cb("toggle_dotfiles") }, { key = "R", cb = tree_cb("refresh") }, { key = "a", cb = tree_cb("create") }, { key = "d", cb = tree_cb("remove") }, { key = "D", cb = tree_cb("trash") }, { key = "r", cb = tree_cb("rename") }, { key = "", cb = tree_cb("full_rename") }, { key = "x", cb = tree_cb("cut") }, { key = "c", cb = tree_cb("copy") }, { key = "p", cb = tree_cb("paste") }, { key = "y", cb = tree_cb("copy_name") }, { key = "Y", cb = tree_cb("copy_path") }, { key = "gy", cb = tree_cb("copy_absolute_path") }, { key = "[c", cb = tree_cb("prev_git_item") }, { key = "]c", cb = tree_cb("next_git_item") }, { key = "-", cb = tree_cb("dir_up") }, { key = "s", cb = tree_cb("system_open") }, { key = "q", cb = tree_cb("close") }, { key = "g?", cb = tree_cb("toggle_help") }, } < |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. Aside from `NvimTreeWindowPicker`, 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 NvimTreeWindowPicker 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 ============================================================================== 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)`. vim:tw=78:ts=8:noet:ft=help:norl: