nvim-tree.lua/README.md

187 lines
5.8 KiB
Markdown
Raw Permalink Normal View History

2020-02-18 18:32:03 +01:00
# A File Explorer For Neovim Written In Lua
[![CI](https://github.com/nvim-tree/nvim-tree.lua/actions/workflows/ci.yml/badge.svg)](https://github.com/nvim-tree/nvim-tree.lua/actions/workflows/ci.yml)
2021-07-10 11:25:25 +02:00
2023-04-18 05:24:22 +02:00
<img align="left" width="199" height="598" src="https://user-images.githubusercontent.com/1505378/232662694-8dc494e0-24da-497a-8541-29344293378c.png">
<img align="left" width="199" height="598" src="https://user-images.githubusercontent.com/1505378/232662698-2f321315-c67a-486b-85d8-8c391de52392.png">
2020-02-04 19:59:14 +01:00
Automatic updates
File type icons
Git integration
Diagnostics integration: LSP and COC
2020-02-04 19:59:14 +01:00
(Live) filtering
Cut, copy, paste, rename, delete, create
Highly customisable
<br clear="left"/>
2022-06-19 10:49:53 +02:00
<br />
2022-11-13 04:33:31 +01:00
Take a look at the [wiki](https://github.com/nvim-tree/nvim-tree.lua/wiki) for Showcases, Tips, Recipes and more.
2024-03-30 04:09:08 +01:00
Questions and general support: [Discussions](https://github.com/nvim-tree/nvim-tree.lua/discussions)
2022-06-19 10:49:53 +02:00
## Requirements
2021-10-02 13:16:59 +02:00
[neovim >=0.9.0](https://github.com/neovim/neovim/wiki/Installing-Neovim)
[nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) is optional and used to display file icons. It requires a [patched font](https://www.nerdfonts.com/). Your terminal emulator must be configured to use that font, usually "Hack Nerd Font"
## Install
Please install via your preferred package manager. See [Installation](https://github.com/nvim-tree/nvim-tree.lua/wiki/Installation) for specific package manager instructions.
2020-10-20 13:51:04 +02:00
`nvim-tree/nvim-tree.lua`
Major or minor versions may be specified via tags: `v<MAJOR>` e.g. `v1` or `v<MAJOR>.<MINOR>` e.g. `v1.23`
`nvim-tree/nvim-web-devicons` optional, for file icons
Disabling [netrw](https://neovim.io/doc/user/pi_netrw.html) is strongly advised, see [:help nvim-tree-netrw](doc/nvim-tree-lua.txt)
## Quick Start
### Setup
Setup the plugin in your `init.lua`
2022-06-04 04:37:02 +02:00
2022-02-09 22:35:06 +01:00
```lua
-- disable netrw at the very start of your init.lua
vim.g.loaded_netrw = 1
2022-09-11 03:41:12 +02:00
vim.g.loaded_netrwPlugin = 1
feat(#2415): colour and highlight overhaul, see :help nvim-tree-highlight-overhaul (#2455) * feat(#2415): granular highlight_diagnostics, normalise groups (#2454) * chore: normalise colours and enable cterm (#2471) * feat(#2415): granular highlight_git, normalise git groups (#2487) * docs: update CONTRIBUTING.md (#2485) * feat(#2415): granular highlight_git, normalise git groups * feat(#2415): normalise and add modified groups * feat(#2415): create Decorator class for modified and bookmarks * feat(#2415): create DecoratorDiagnostics * feat(#2415): create DecoratorGit * feat(#2415): create DecoratorGit * add DecoratorCopied DecoratorCut * add DecoratorOpened * remove unloaded_bufnr checks as the view debouncer takes care of it * Add `renderer.highlight_git` to accepted strings * fix(#2415): builder refactor (#2538) * simplify builder signs * decorators take care of themselves and are priority ordered * simplify builder hl groups * refactor builder for icon arrays * builder use decorators generically * fix(#2415): harden sign creation (#2539) * fix(#2415): harden unicode signs * Decorator tidy * normalise git sign creation and tidy * tidy builder * NvimTreeBookmarkIcon * tidy HL doc * tidy HL doc * tidy HL doc * tidy builder doc * standardise on '---@param' * DiagnosticWarning -> DiagnosticWarn * annotate decorators * limit to two highlight groups for line rendering * style * apply #2519 * feat(#2415): combined hl groups (#2601) * feat(#2415): create combined highlight groups * feat(#2415): create combined highlight groups * feat(#2415): create combined highlight groups * ci: allow workflow_dispatch (#2620) * one and only one hl namespace, required winhl removal * small tidies * colors.lua -> appearance.lua * full-name uses one and only namespace * don't highlight fast, just apply to namespace, safer win_set_hl * gut builder (#2622) collapse Builder * fix group_empty function check * feat(#2415): highlight-overhaul release date --------- Co-authored-by: Akmadan23 <azadahmadi@mailo.com>
2024-01-20 06:12:13 +01:00
-- optionally enable 24-bit colour
vim.opt.termguicolors = true
-- empty setup using defaults
require("nvim-tree").setup()
-- OR setup with some options
require("nvim-tree").setup({
sort = {
sorter = "case_sensitive",
},
view = {
width = 30,
},
2022-04-10 15:40:29 +02:00
renderer = {
group_empty = true,
2022-02-09 22:35:06 +01:00
},
filters = {
dotfiles = true,
},
})
2022-02-09 22:35:06 +01:00
```
### Help
Open the tree: `:NvimTreeOpen`
Show the mappings: `g?`
### Custom Mappings
[:help nvim-tree-mappings-default](doc/nvim-tree-lua.txt) are applied by default however you may customise via |nvim-tree.on_attach| e.g.
```lua
local function my_on_attach(bufnr)
local api = require "nvim-tree.api"
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- default mappings
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
end
-- pass to setup along with your other options
require("nvim-tree").setup {
---
on_attach = my_on_attach,
---
}
```
### Highlight
Run `:NvimTreeHiTest` to show all the highlights that nvim-tree uses.
They can be customised before or after setup is called and will be immediately
applied at runtime. e.g.
```lua
vim.cmd([[
:hi NvimTreeExecFile guifg=#ffa0a0
:hi NvimTreeSpecialFile guifg=#ff80ff gui=underline
:hi NvimTreeSymlink guifg=Yellow gui=italic
:hi link NvimTreeImageFile Title
]])
```
See [:help nvim-tree-highlight](doc/nvim-tree-lua.txt) for details.
## Commands
2022-01-21 11:03:49 +01:00
See [:help nvim-tree-commands](doc/nvim-tree-lua.txt)
2022-01-21 11:03:49 +01:00
Basic commands:
`:NvimTreeToggle` Open or close the tree. Takes an optional path argument.
`:NvimTreeFocus` Open the tree if it is closed, and then focus on the tree.
`:NvimTreeFindFile` Move the cursor in the tree for the current buffer, opening folders if needed.
2021-10-01 16:05:18 +02:00
`:NvimTreeCollapse` Collapses the nvim-tree recursively.
2021-10-01 16:05:18 +02:00
## Roadmap
nvim-tree is stable and new major features will not be added. The focus is on existing user experience.
Users are encouraged to add their own custom features via the public [API](#api).
Development is focused on:
* Bug fixes
* Performance
* Quality of Life improvements
* API / Events
* Enhancements to existing features
## API
feat: automated migration from view.mappings.list to on_attach, see https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach (#1579) * chore(mappings): migrate legacy mappings under the hood * chore(mappings): POC for help and :help on_attach keymaps * chore(mappings): POC for help and :help on_attach keymaps * chore(mappings): add desc to all mappings, show in help, reformat help * chore(mappings): add desc to all mappings * chore(mappings): add desc to all mappings * chore(mappings): escape help keys * chore(mappings): migrate legacy mappings under the hood: map keymap to legacy mappings * chore(mappings): migrate legacy mappings under the hood: remove dispatch * Revert "chore(mappings): migrate legacy mappings under the hood: remove dispatch" This reverts commit f6f439ba59b051e16f17d56bf1271af67fb5b662. * chore(mappings): migrate legacy mappings under the hood: pass node to action_cb * chore(mappings): migrate legacy mappings under the hood: remove dispatch * chore(mappings): migrate legacy mappings under the hood: replace mappigns with keymaps in help * chore(mappings): generate on_attach from user's legacy mappings * chore(mappings): generate on_attach from user's legacy mappings * chore(mappings): merge cleanup * chore(mappings): use default mappings when on_attach not present, log legacy migration * on_attach is default or user only, legacy and generation includes defaults (#1777) * chore(mappings): remove mappings via vim.keymap.del instead of filtering mappings, to allow for multiple ways of specifying a key * doc: specify that the terminal emulator must be configured to use the patched font * feat(renderer): add NvimTreeOpenedFolderIcon NvimTreeClosedFolderIcon (#1768) * feat: Add highlight group for opened folder closes #1674 * docs: Add NvimTreeOpenedFolderIcon default * feat: Add NvimTreeClosedFolderIcon highlight group Defaults to NvimTreeFolderIcon * feat: add diagnostics.show_on_open_dirs git.show_on_open_dirs (#1778) * feat(diagnostics): only show diagnostic on closed folder * feat(git): only show git icon on closed folder * docs: Update feature_request.md (#1788) * Update feature_request.md Closes #1654 * Update feature_request.md Co-authored-by: Alexander Courtis <alex@courtis.org> * 1786 git next prev land on dirs (#1787) * Filtered dir with git status that are open when show_on_open_dir is false * refactored for single source of truth of existence of git status on a node Putting `has_git_status()` in `explorer.common` because that's where node.status is constructed Or at least I think that's where it's constructed * 1786 semantic nit Co-authored-by: Alexander Courtis <alex@courtis.org> * fix(git): git rename not showing up for the renamed file (#1783) * fixed git rename not showing up for the renamed file * considered " -> " being a part of the filename Fixed -> pattern to escape - Fixed "\"" and "\\" in filename * using string.find(, , true) to match plain -> * Using -z and removed unnecessary logic * feat(view): always enable cursorline, users may change this behaviour via Event.TreeOpen (#1814) * Update view.lua * set cursorline to true * feat(event): dispatch Event.NodeRenamed on cut-paste (#1817) * feat(view): add filters.git_clean, filters.no_buffer (#1784) * feat(view): add filters.git_clean * feat(view): add filters.git_clean * feat(view): add filters.no_buffer * feat(view): filters.no_buffer misses unloaded, handles buffer in/out * feat(view): filters.no_buffer matches directories specifically * feat(view): filters.no_buffer clarify targets * feat: add placeholder filters.diagnostics_ok, refactor filters * feat(view): remove placeholder filters.diagnostics_ok * doc: consolidate and clarify :help examples * doc: format help * feat: paste and create always target closed folder, remove create_in_closed_folder (#1802) * Fix default for file creation in closed directories * Make paste in closed directories consistent with create * doc: clarify create_in_closed_folder * Remove create_in_closed_folder option * doc: clarify create_in_closed_folder removal message (whoops) Co-authored-by: Alexander Courtis <alex@courtis.org> * on_attach is user's or default, nothing else; legacy generated on_attach includes defaults Co-authored-by: baahrens <bahrens@compeon.de> Co-authored-by: Richard Li <38484873+chomosuke@users.noreply.github.com> Co-authored-by: gegoune <69750637+gegoune@users.noreply.github.com> Co-authored-by: rishabhjain9191 <rishabh.jain9191@gmail.com> Co-authored-by: Anton <14187674+antosha417@users.noreply.github.com> Co-authored-by: Eric Haynes <ehaynes99@gmail.com> * on_attach_default hardcoded * format default_on_attach * source default on_attach directly * remove human mappings help * simplified on_attach generation * simplified on_attach generation * generate default on_attach * generate default on_attach * split out keymap_legacy * add recently introduced mappings * legacy api.config.mappings.active and default * legacy api.config.mappings.active and default * on_attach help and readme * legacy generate handles action = "" * legacy generate handles action = * legacy generate gives defaults when no user mappings * legacy generate handles action = "" * legacy generate api handles overrides * legacy generate handles subsequent setup, on_attach retains deep copies of legacy config * add wiki link to generated on_attach * add opts helper function for on_attach, prefixing 'nvim-tree: ' --------- Co-authored-by: kiyan <yazdani.kiyan@protonmail.com> Co-authored-by: baahrens <bahrens@compeon.de> Co-authored-by: Richard Li <38484873+chomosuke@users.noreply.github.com> Co-authored-by: gegoune <69750637+gegoune@users.noreply.github.com> Co-authored-by: rishabhjain9191 <rishabh.jain9191@gmail.com> Co-authored-by: Anton <14187674+antosha417@users.noreply.github.com> Co-authored-by: Eric Haynes <ehaynes99@gmail.com>
2023-02-27 04:19:50 +01:00
nvim-tree exposes a public API. This is non breaking, with additions made as necessary. See [:help nvim-tree-api](doc/nvim-tree-lua.txt)
2023-03-21 06:39:45 +01:00
See wiki [Recipes](https://github.com/nvim-tree/nvim-tree.lua/wiki/Recipes) and [Tips](https://github.com/nvim-tree/nvim-tree.lua/wiki/Tips) for ideas and inspiration.
2022-12-31 22:31:47 +01:00
2023-03-21 06:39:45 +01:00
Please raise a [feature request](https://github.com/nvim-tree/nvim-tree.lua/issues/new?assignees=&labels=feature+request&template=feature_request.md&title=) if the API is insufficient for your needs. [Contributions](#Contributing) are always welcome.
feat: automated migration from view.mappings.list to on_attach, see https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach (#1579) * chore(mappings): migrate legacy mappings under the hood * chore(mappings): POC for help and :help on_attach keymaps * chore(mappings): POC for help and :help on_attach keymaps * chore(mappings): add desc to all mappings, show in help, reformat help * chore(mappings): add desc to all mappings * chore(mappings): add desc to all mappings * chore(mappings): escape help keys * chore(mappings): migrate legacy mappings under the hood: map keymap to legacy mappings * chore(mappings): migrate legacy mappings under the hood: remove dispatch * Revert "chore(mappings): migrate legacy mappings under the hood: remove dispatch" This reverts commit f6f439ba59b051e16f17d56bf1271af67fb5b662. * chore(mappings): migrate legacy mappings under the hood: pass node to action_cb * chore(mappings): migrate legacy mappings under the hood: remove dispatch * chore(mappings): migrate legacy mappings under the hood: replace mappigns with keymaps in help * chore(mappings): generate on_attach from user's legacy mappings * chore(mappings): generate on_attach from user's legacy mappings * chore(mappings): merge cleanup * chore(mappings): use default mappings when on_attach not present, log legacy migration * on_attach is default or user only, legacy and generation includes defaults (#1777) * chore(mappings): remove mappings via vim.keymap.del instead of filtering mappings, to allow for multiple ways of specifying a key * doc: specify that the terminal emulator must be configured to use the patched font * feat(renderer): add NvimTreeOpenedFolderIcon NvimTreeClosedFolderIcon (#1768) * feat: Add highlight group for opened folder closes #1674 * docs: Add NvimTreeOpenedFolderIcon default * feat: Add NvimTreeClosedFolderIcon highlight group Defaults to NvimTreeFolderIcon * feat: add diagnostics.show_on_open_dirs git.show_on_open_dirs (#1778) * feat(diagnostics): only show diagnostic on closed folder * feat(git): only show git icon on closed folder * docs: Update feature_request.md (#1788) * Update feature_request.md Closes #1654 * Update feature_request.md Co-authored-by: Alexander Courtis <alex@courtis.org> * 1786 git next prev land on dirs (#1787) * Filtered dir with git status that are open when show_on_open_dir is false * refactored for single source of truth of existence of git status on a node Putting `has_git_status()` in `explorer.common` because that's where node.status is constructed Or at least I think that's where it's constructed * 1786 semantic nit Co-authored-by: Alexander Courtis <alex@courtis.org> * fix(git): git rename not showing up for the renamed file (#1783) * fixed git rename not showing up for the renamed file * considered " -> " being a part of the filename Fixed -> pattern to escape - Fixed "\"" and "\\" in filename * using string.find(, , true) to match plain -> * Using -z and removed unnecessary logic * feat(view): always enable cursorline, users may change this behaviour via Event.TreeOpen (#1814) * Update view.lua * set cursorline to true * feat(event): dispatch Event.NodeRenamed on cut-paste (#1817) * feat(view): add filters.git_clean, filters.no_buffer (#1784) * feat(view): add filters.git_clean * feat(view): add filters.git_clean * feat(view): add filters.no_buffer * feat(view): filters.no_buffer misses unloaded, handles buffer in/out * feat(view): filters.no_buffer matches directories specifically * feat(view): filters.no_buffer clarify targets * feat: add placeholder filters.diagnostics_ok, refactor filters * feat(view): remove placeholder filters.diagnostics_ok * doc: consolidate and clarify :help examples * doc: format help * feat: paste and create always target closed folder, remove create_in_closed_folder (#1802) * Fix default for file creation in closed directories * Make paste in closed directories consistent with create * doc: clarify create_in_closed_folder * Remove create_in_closed_folder option * doc: clarify create_in_closed_folder removal message (whoops) Co-authored-by: Alexander Courtis <alex@courtis.org> * on_attach is user's or default, nothing else; legacy generated on_attach includes defaults Co-authored-by: baahrens <bahrens@compeon.de> Co-authored-by: Richard Li <38484873+chomosuke@users.noreply.github.com> Co-authored-by: gegoune <69750637+gegoune@users.noreply.github.com> Co-authored-by: rishabhjain9191 <rishabh.jain9191@gmail.com> Co-authored-by: Anton <14187674+antosha417@users.noreply.github.com> Co-authored-by: Eric Haynes <ehaynes99@gmail.com> * on_attach_default hardcoded * format default_on_attach * source default on_attach directly * remove human mappings help * simplified on_attach generation * simplified on_attach generation * generate default on_attach * generate default on_attach * split out keymap_legacy * add recently introduced mappings * legacy api.config.mappings.active and default * legacy api.config.mappings.active and default * on_attach help and readme * legacy generate handles action = "" * legacy generate handles action = * legacy generate gives defaults when no user mappings * legacy generate handles action = "" * legacy generate api handles overrides * legacy generate handles subsequent setup, on_attach retains deep copies of legacy config * add wiki link to generated on_attach * add opts helper function for on_attach, prefixing 'nvim-tree: ' --------- Co-authored-by: kiyan <yazdani.kiyan@protonmail.com> Co-authored-by: baahrens <bahrens@compeon.de> Co-authored-by: Richard Li <38484873+chomosuke@users.noreply.github.com> Co-authored-by: gegoune <69750637+gegoune@users.noreply.github.com> Co-authored-by: rishabhjain9191 <rishabh.jain9191@gmail.com> Co-authored-by: Anton <14187674+antosha417@users.noreply.github.com> Co-authored-by: Eric Haynes <ehaynes99@gmail.com>
2023-02-27 04:19:50 +01:00
You may also subscribe to events that nvim-tree will dispatch in a variety of situations, see [:help nvim-tree-events](doc/nvim-tree-lua.txt)
## Contributing
2022-11-13 05:09:20 +01:00
PRs are always welcome. See [wiki](https://github.com/nvim-tree/nvim-tree.lua/wiki/Development) to get started.
2022-11-13 00:37:21 +01:00
See [bug](https://github.com/nvim-tree/nvim-tree.lua/issues?q=is%3Aissue+is%3Aopen+label%3Abug) and [PR Please](https://github.com/nvim-tree/nvim-tree.lua/issues?q=is%3Aopen+is%3Aissue+label%3A%22PR+please%22) issues if you are looking for some work to get you started.
## Screenshots
See [Showcases](https://github.com/nvim-tree/nvim-tree.lua/wiki/Showcases) wiki page for examples of user's configurations with sources.
Please add your own!
## Team
* [@alex-courtis](https://github.com/alex-courtis) Arch Linux
* [@gegoune](https://github.com/gegoune) macOS
* [@Akmadan23](https://github.com/Akmadan23) Linux
* [@dependabot[bot]](https://github.com/apps/dependabot) Ubuntu Linux