Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theblob42/drex.nvim
Another directory/file explorer for Neovim written in Lua
https://github.com/theblob42/drex.nvim
file-explorer lua neovim
Last synced: 7 days ago
JSON representation
Another directory/file explorer for Neovim written in Lua
- Host: GitHub
- URL: https://github.com/theblob42/drex.nvim
- Owner: TheBlob42
- License: gpl-3.0
- Created: 2021-11-09T21:21:21.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-25T09:08:20.000Z (5 months ago)
- Last Synced: 2024-07-31T20:45:22.011Z (4 months ago)
- Topics: file-explorer, lua, neovim
- Language: Lua
- Homepage:
- Size: 800 KB
- Stars: 96
- Watchers: 5
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DREX
Another **D**i**R**ectory **EX**plorer for Neovim
![drex](./assets/drex.png)
For showcase GIFs see [here](https://github.com/TheBlob42/drex.nvim/wiki/Showcase)- easily navigate through your file system
- split window and project drawer support
- add, copy, move, rename and delete elements
- mark and operate on multiple elements
- automatic file system synchronization
- powered by [libuv](https://github.com/luvit/luv/blob/master/docs.md)## Installation
> DREX requires Neovim version ≥ 0.7
Install DREX with your favorite plugin manager
[packer](https://github.com/wbthomason/packer.nvim)
```lua
use {
'theblob42/drex.nvim',
requires = 'kyazdani42/nvim-web-devicons', -- optional
}
```[vim-plug](https://github.com/junegunn/vim-plug)
```vim
Plug 'theblob42/drex.nvim'
Plug 'kyazdani42/nvim-web-devicons' " optional
```You only need to install [nvim-web-devicons](https://github.com/kyazdani42/nvim-web-devicons) if you like to have nice file type icons. The plugin works fine without it.
## Usage
Open a DREX buffer in the current working directory
```
:Drex
```You can also provide a target path
```
:Drex ~/projects
```To open the parent directory of the current file
```
:Drex %:h
```> Check the manual for `cmdline-special` and `filename-modifiers`
DREX also comes with a simple project drawer functionality
```
:DrexDrawerOpen
```> See `:help drex-commands` for more available commands
### Default Keybindings
> To see the definition of all default keybindings see the [configuration](#configuration) section
- Use `j` and `k` like in any other VIM buffer to navigate up and down
- `v` is mapped to `V` because there is no need for charwise selection**Basic navigation**
- `l` expands the current element
- If it is a directory open its content in a subtree
- If it is a file open the file in the current window
> `` and `<2-LeftMouse>` are alternative keybindings
- `h` collapses the current directories subtree
- If the element under the cursor is an open directory collapse it
- Otherwise collapse the parent directory of the element
> `` and `` are alternative keybindings
- `` opens a file in a vertical split
- `` opens a file in a horizontal split
- `` opens a file in a new tab
- `` reloads the current directory (dependent on the cursor position)
- `` opens a new DREX buffer in the parent directory of the current root
- `` opens the directory under the cursor in a new DREX buffer**Jumping**
- `gj` jumps to the next sibling
- `gk` jumps to the previous sibling
- `gh` jumps to the parent directory of the current element**Clipboard**
- `m` marks or unmarks the current element (add or remove it from the clipboard)
- `M` marks the current element (add it to the clipboard)
- `u` unmarks the current element (remove it from the clipboard)
- `cc` clears the clipboard content
- `cs` to show and edit the content of the clipboard in a floating window**File actions**
- `s` shows the stats for the current element
- `a` creates a new file or directory
- to create a new directory end your input with a `/` (`\` on Windows)
- non-existent parent directories will be created
(e.g. `foo/bar/file` will create `foo` and `bar` if they don't exist yet)
- `d` deletes the element under the cursor (or the visual selection)
- `D` deletes all elements currently contained in the clipboard
- `p` copies all elements from the clipboard to the path under the cursor
- this will NOT clear the clipboard, so you can continue to paste elsewhere
- `P` moves all elements from the clipboard to the path under the cursor
- `r` renames the element under the cursor (or the visual selection)
- this can move the element to another location
- non-existent parent directories will be created
(e.g. `foo/bar/file` will create `foo` and `bar` if they don't exist yet)
- `R` to multi rename all elements from the clipboard**Search**
- `/` search for visible elements (see `:help drex-search`)
**Copy strings**
- `y` copies the name of the element under the cursor
- `Y` copies the relative path of the element under the cursor
- `` copies the absolute path of the element under the cursor> In visual mode these copy all selected elements (separated by "\n")
## Configuration
There is no initial setup needed to use DREX
However you may configure certain settings to your likingCheck out `:help drex-configuration` for more details about the individual options
See also the wiki pages about [configuration](https://github.com/TheBlob42/drex.nvim/wiki/Configuration) and [custom actions](https://github.com/TheBlob42/drex.nvim/wiki/Custom-Actions) for more information about further customizationHave a look at the default configuration
```lua
require('drex.config').configure {
icons = {
file_default = "",
dir_open = "",
dir_closed = "",
link = "",
others = "",
},
colored_icons = true,
hide_cursor = true,
hijack_netrw = false,
keepalt = false,
sorting = function(a, b)
local aname, atype = a[1], a[2]
local bname, btype = b[1], b[2]local aisdir = atype == 'directory'
local bisdir = btype == 'directory'if aisdir ~= bisdir then
return aisdir
endreturn aname < bname
end,
drawer = {
side = 'left',
default_width = 30,
window_picker = {
enabled = true,
labels = 'abcdefghijklmnopqrstuvwxyz',
},
},
actions = {
files = {
delete_cmd = nil,
},
},
disable_default_keybindings = false,
keybindings = {
['n'] = {
['v'] = 'V',
['l'] = { 'lua require("drex.elements").expand_element()', { desc = 'expand element' }},
['h'] = { 'lua require("drex.elements").collapse_directory()', { desc = 'collapse directory' }},
[''] = { 'lua require("drex.elements").expand_element()', { desc = 'expand element' }},
[''] = { 'lua require("drex.elements").collapse_directory()', { desc = 'collapse directory'}},
['<2-LeftMouse>'] = { 'lua require("drex.elements").expand_element()', { desc = 'expand element' }},
[''] = { 'lua require("drex.elements").collapse_directory()', { desc = 'collapse directory' }},
[''] = { 'lua require("drex.elements").open_file("vs")', { desc = 'open file in vsplit' }},
[''] = { 'lua require("drex.elements").open_file("sp")', { desc = 'open file in split' }},
[''] = { 'lua require("drex.elements").open_file("tabnew", true)', { desc = 'open file in new tab' }},
[''] = { 'lua require("drex.elements").open_directory()', { desc = 'open directory in new buffer' }},
[''] = { 'lua require("drex.elements").open_parent_directory()', { desc = 'open parent directory in new buffer' }},
[''] = { 'lua require("drex").reload_directory()', { desc = 'reload' }},
['gj'] = { 'lua require("drex.actions.jump").jump_to_next_sibling()', { desc = 'jump to next sibling' }},
['gk'] = { 'lua require("drex.actions.jump").jump_to_prev_sibling()', { desc = 'jump to prev sibling' }},
['gh'] = { 'lua require("drex.actions.jump").jump_to_parent()', { desc = 'jump to parent element' }},
['s'] = { 'lua require("drex.actions.stats").stats()', { desc = 'show element stats' }},
['a'] = { 'lua require("drex.actions.files").create()', { desc = 'create element' }},
['d'] = { 'lua require("drex.actions.files").delete("line")', { desc = 'delete element' }},
['D'] = { 'lua require("drex.actions.files").delete("clipboard")', { desc = 'delete (clipboard)' }},
['p'] = { 'lua require("drex.actions.files").copy_and_paste()', { desc = 'copy & paste (clipboard)' }},
['P'] = { 'lua require("drex.actions.files").cut_and_move()', { desc = 'cut & move (clipboard)' }},
['r'] = { 'lua require("drex.actions.files").rename()', { desc = 'rename element' }},
['R'] = { 'lua require("drex.actions.files").multi_rename("clipboard")', { desc = 'rename (clipboard)' }},
['/'] = { 'keepalt lua require("drex.actions.search").search()', { desc = 'search' }},
['M'] = { 'DrexMark', { desc = 'mark element' }},
['u'] = { 'DrexUnmark', { desc = 'unmark element' }},
['m'] = { 'DrexToggle', { desc = 'toggle element' }},
['cc'] = { 'lua require("drex.clipboard").clear_clipboard()', { desc = 'clear clipboard' }},
['cs'] = { 'lua require("drex.clipboard").open_clipboard_window()', { desc = 'edit clipboard' }},
['y'] = { 'lua require("drex.actions.text").copy_name()', { desc = 'copy element name' }},
['Y'] = { 'lua require("drex.actions.text").copy_relative_path()', { desc = 'copy element relative path' }},
[''] = { 'lua require("drex.actions.text").copy_absolute_path()', { desc = 'copy element absolute path' }},
},
['v'] = {
['d'] = { ':lua require("drex.actions.files").delete("visual")', { desc = 'delete elements' }},
['r'] = { ':lua require("drex.actions.files").multi_rename("visual")', { desc = 'rename elements' }},
['M'] = { ':DrexMark', { desc = 'mark elements' }},
['u'] = { ':DrexUnmark', { desc = 'unmark elements' }},
['m'] = { ':DrexToggle', { desc = 'toggle elements' }},
['y'] = { ':lua require("drex.actions.text").copy_name(true)', { desc = 'copy element names' }},
['Y'] = { ':lua require("drex.actions.text").copy_relative_path(true)', { desc = 'copy element relative paths' }},
[''] = { ':lua require("drex.actions.text").copy_absolute_path(true)', { desc = 'copy element absolute paths' }},
}
},
on_enter = nil,
on_leave = nil,
}
```## Internals
Like [vim-dirvish](https://github.com/justinmk/vim-dirvish) every line is just a file path hidden via `conceal` (plus indentation and an icon). For file system scanning, file interactions (add, delete, rename, etc.) and monitoring DREX uses [libuv](https://github.com/libuv/libuv) which is exposed via `vim.loop`
See also `:help drex-customization` and the [Wiki](https://github.com/TheBlob42/drex.nvim/wiki) for more information and examples
## Contributing
Contributions are very welcome :-) doesn't matter if it's a bug, a new feature or an addition/change to the wiki. Just go ahead and open an issue or a pull-request to kick off the discussion about it
In regards to code changes and pull-requests please consider the following points:
- follow the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines for your commit messages
- make sure you're code is properly formatted using [StyLua](https://github.com/JohnnyMorganz/StyLua)
- make sure you have the `lua52` version installed, otherwise there will be problems with `goto` statements (see [here](https://github.com/JohnnyMorganz/StyLua/issues/407))## Credit
- [nvim-tree](https://github.com/kyazdani42/nvim-tree.lua)
- [vim-dirvish](https://github.com/justinmk/vim-dirvish)
- [fern](https://github.com/lambdalisue/fern.vim)