A directory buffer for Neovim that lets you edit your filesystem like you edit text. Inspired by vim-dirvish and vidir.
Ctrl-^
(Ctrl-6
).Requires Neovim 0.6 or higher.
Plug "elihunter173/dirbuf.nvim"
use "elihunter173/dirbuf.nvim"
If you use nvim-tree.lua
, you
must disable the :help nvim-tree.update_to_buf_dir
option. Otherwise, Dirbuf
will fail to open directory buffers.
require("nvim-tree").setup {
update_to_buf_dir = { enable = false }
}
If you notice nvim /some/directory
opening Netrw instead of Dirbuf, you can
disable Netrw by adding the following to your init.vim
or init.lua
. This
issue only appears with certain package managers and affects other file manager
plugins as well. I am searching for a more elegant solution.
" init.vim
let g:loaded_netrwPlugin = 1
let g:loaded_netrw = 1
-- init.lua
vim.g.loaded_netrwPlugin = 1
vim.g.loaded_netrw = 1
Run the command :Dirbuf
to open a directory buffer for your current
directory. Press -
in any buffer to open a directory buffer for its parent.
Editing a directory will also open up a directory buffer, overriding Netrw.
Inside a directory buffer, there are the following keybindings:
<CR>
: Open the file or directory at the cursor.gh
: Toggle showing hidden files (i.e. dot files).-
: Open parent directory.See :help dirbuf.txt
for more info.
Configuration is not necessary for Dirbuf to work. But for those that want to override the default config, the following options are available with their default values listed.
require("dirbuf").setup {
hash_padding = 2,
show_hidden = true,
sort_order = "default",
write_cmd = "DirbufSync",
}
Read the documentation for more information (:help dirbuf-options
).
A Justfile is provided to test and lint the project.
# Run unit tests
$ just test
# Run luacheck
$ just lint
just test
will automatically download plenary.nvim's test harness and run
the *_spec.lua
tests in tests/
.