A file explorer tree for neovim written in lua
Go to file
darcy 4a87b8b46b
feat(#2654): filters.custom may be a function (#2655)
* feat(#2654): add `binaries` field to `filters`

* feat(#2648): allow functions in `filters.custom`

* ci: fix: stylua check

* ci: fix: add new keybind and config to docs

* fix: replace os-specific binary filter with `vim.fn.executable`

* fix: remove function and mapping for `binaries` filter

* fix: add `node` parameter to custom filter function

* fix: update doc for custom filter function signature

* fix: add custom filter to `ACCEPTED_TYPES`

* fix: accept single function for custom filter

* fix: change custom filter on `ACCEPTED_TYPES`

* fix: revert to using `path` for custom filter function

* fix: use `function` type for custom filter

* fix: type for custom filter in help

* fix: custom filter single function no longer mutates `M.config.filter_custom`

* fix: remove dead `if` statement in custom filter

* fix: separate custom filter function from `M.ignore_list`

* doc nit

---------

Co-authored-by: darcy <44690813+darccyy@users.noreply.github.com>
Co-authored-by: Alexander Courtis <alex@courtis.org>
2024-02-11 17:18:40 +11:00
.github chore(deps): bump actions/checkout from 3 to 4 (#2623) 2024-01-08 10:09:04 +01:00
.hooks ci: lua language server and Makefile (#2546) 2024-01-06 13:18:52 +11:00
doc feat(#2654): filters.custom may be a function (#2655) 2024-02-11 17:18:40 +11:00
lua feat(#2654): filters.custom may be a function (#2655) 2024-02-11 17:18:40 +11:00
scripts ci: lua language server and Makefile (#2546) 2024-01-06 13:18:52 +11:00
.editorconfig feat(#2092): add api.node.navigate.open.next, prev (#2093) 2023-04-03 14:23:03 +10:00
.gitignore ci: lua language server and Makefile (#2546) 2024-01-06 13:18:52 +11:00
.luacheckrc refacto: set tree explorer in the global state 2022-02-07 22:07:08 +01:00
.luarc.json ci: lua language server and Makefile (#2546) 2024-01-06 13:18:52 +11:00
.release-please-manifest.json chore(master): release nvim-tree 0.100.0 (#2635) 2024-02-11 15:49:27 +11:00
.stylua.toml chore: stylua column width 120 -> 140 (#2448) 2023-10-08 11:40:58 +11:00
CHANGELOG.md chore(master): release nvim-tree 0.100.0 (#2635) 2024-02-11 15:49:27 +11:00
CONTRIBUTING.md ci: lua language server and Makefile (#2546) 2024-01-06 13:18:52 +11:00
LICENSE renaming: lua-tree -> nvim-tree 2020-12-27 19:14:34 +01:00
Makefile ci: lua language server and Makefile (#2546) 2024-01-06 13:18:52 +11:00
README.md feat(#2415): colour and highlight overhaul, see :help nvim-tree-highlight-overhaul (#2455) 2024-01-20 16:12:13 +11:00
release-please-config.json chore: first release (#2588) 2023-12-11 01:36:12 +01:00

A File Explorer For Neovim Written In Lua

CI

Automatic updates

File type icons

Git integration

Diagnostics integration: LSP and COC

(Live) filtering

Cut, copy, paste, rename, delete, create

Highly customisable



Take a look at the wiki for Showcases, Tips, Recipes and more.

Community support: matrix

Requirements

neovim >=0.8.0

nvim-web-devicons is optional and used to display file icons. It requires a patched font. Your terminal emulator must be configured to use that font, usually "Hack Nerd Font"

Install

Please install via your preferred package manager. See Installation for specific package manager instructions.

nvim-tree/nvim-tree.lua

nvim-tree/nvim-web-devicons optional, for file icons

Disabling netrw is strongly advised, see :help nvim-tree-netrw

Quick Start

Setup

Setup the plugin in your init.lua

-- disable netrw at the very start of your init.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

-- 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,
  },
  renderer = {
    group_empty = true,
  },
  filters = {
    dotfiles = true,
  },
})

Help

Open the tree: :NvimTreeOpen

Show the mappings: g?

Custom Mappings

:help nvim-tree-mappings-default are applied by default however you may customise via |nvim-tree.on_attach| e.g.

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,
  ---
}

Commands

See :help nvim-tree-commands

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.

:NvimTreeCollapse Collapses the nvim-tree recursively.

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.

Development is focused on:

  • Bug fixes
  • Performance
  • Quality of Life improvements
  • API / Events
  • Enhancements to existing features

API

nvim-tree exposes a public API. This is non breaking, with additions made as necessary. See :help nvim-tree-api

See wiki Recipes and Tips for ideas and inspiration.

Please raise a feature request if the API is insufficient for your needs. Contributions are always welcome.

You may also subscribe to events that nvim-tree will dispatch in a variety of situations, see :help nvim-tree-events

Contributing

PRs are always welcome. See wiki to get started.

See bug and PR Please issues if you are looking for some work to get you started.

Screenshots

See Showcases wiki page for examples of user's configurations with sources.

Please add your own!

Team