Home

Awesome

dired.nvim

A file browser inspired from Emacs Dired for neovim.

Screenshots

output

Different types of files in dired.nvim Screenshot from 2023-02-02 20-16-20 Screenshot from 2023-02-02 20-15-57

Installation

Requires Neovim 0.6 or higher.

Packer.nvim

use {
    "X3eRo0/dired.nvim",
    requires = "MunifTanjim/nui.nvim",
    config = function()
        require("dired").setup {
            path_separator = "/",
            show_banner = false,
            show_icons = false,
            show_hidden = true,
            show_dot_dirs = true,
            show_colors = true,
        }
    end
}

Setup

You can require this plugin and use it like this.

-- Neovim configuration for the 'dired' plugin

-- Set up the 'dired' plugin with custom options
require("dired").setup({
    path_separator = "/",                -- Use '/' as the path separator
    show_hidden = true,                  -- Show hidden files
    show_icons = false,                  -- Show icons (patched font required)
    show_banner = false,                 -- Do not show the banner
    hide_details = false,                -- Show file details by default
    sort_order = "name",                 -- Sort files by name by default

    -- Define keybindings for various 'dired' actions
    keybinds = {
        dired_enter = "<cr>",
        dired_back = "-",
        dired_up = "_",
        dired_rename = "R",
        -- ... (add more keybindings as needed)
        dired_quit = "q",
    },

    -- Define colors for different file types and attributes
    colors = {
        DiredDimText = { link = {}, bg = "NONE", fg = "505050", gui = "NONE" },
        DiredDirectoryName = { link = {}, bg = "NONE", fg = "9370DB", gui = "NONE" },
        -- ... (define more colors as needed)
        DiredMoveFile = { link = {}, bg = "NONE", fg = "ff3399", gui = "bold" },
    },
})

Usage

Run the command :Dired to open a 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 buffer, overriding Netrw.

Commands

You can use the following commands to add in your custom keybinds.

CommandDescription
DiredOpen Dired UI (dir completion)
DiredRenameRename file/directory under cursor (file completion)
DiredDeleteDelete file/directory under cursor (file completion)
DiredMarkMark file/directory under cursor (file completion)
DiredDeleteRangeDelete selected files/directories (visual)
DiredDeleteMarkedDelete marked files/directories
DiredMarkRangeMark a range of files/directories (visual)
DiredGoBackNavigate back in the directory history
DiredGoUpMove up to the parent directory
DiredCopyCopy the file/directory under the cursor
DiredCopyRangeCopy selected files/directories (visual)
DiredCopyMarkedCopy marked files/directories
DiredMoveMove the file/directory under the cursor
DiredMoveRangeMove selected files/directories (visual)
DiredMoveMarkedMove marked files/directories
DiredPastePaste copied or moved files in the current directory
DiredEnterOpen the file or directory at the cursor
DiredCreateCreate a new directory
DiredToggleHiddenToggle the visibility of hidden files
DiredToggleSortOrderToggle the sorting order of files and directories
DiredToggleColorsToggle the display of colors
DiredToggleIconsToggle the display of filetype icons
DiredToggleHideDetailsToggle hiding/showing file details
DiredQuitQuit the 'dired' interface

Keybinding

Inside a directory buffer, there are the following keybindings:

KeybindingDescription
<CR>Open the file or directory at the cursor.
dCreate new directories and files.
MMark directories and files (both in normal and visual mode).
CCopy files.
XMove files.
PPaste files in the current directory.
DDelete directories and files (both in normal and visual mode).
RRename directories and files.
MDDelete marked files.
MCCopy marked files.
MXMove marked files.
-Open the parent directory.
.Toggle show_hidden.
,Change sort_order.
cToggle colors.
_Move selection up one line.
,Toggle color display.
*Toggle filetype icons.
(Toggle hiding/showing file details.
qQuit the 'dired' interface.

The default keybinds are given below.

{
    dired_enter = "<cr>",
    dired_back = "-",
    dired_up = "_",
    dired_rename = "R",
    dired_create = "d",
    dired_delete = "D",
    dired_delete_range = "D",
    dired_copy = "C",
    dired_copy_range = "C",
    dired_copy_marked = "MC",
    dired_move = "X",
    dired_move_range = "X",
    dired_move_marked = "MX",
    dired_paste = "P",
    dired_mark = "M",
    dired_mark_range = "M",
    dired_delete_marked = "MD",
    dired_toggle_hidden = ".",
    dired_toggle_sort_order = ",",
    dired_toggle_icons = "*",
    dired_toggle_colors = "c",
    dired_toggle_hide_details = "(",
    dired_quit = "q",
}

Colors

You can change the colors of each component in the output by specifiying a table of options for each Hightlight group used in Dired.

local DiredDimText = {
    link = {},
    bg = "232323",
    fg = "f3f3f3"
    gui = "bold",
}

The options are explained below.

OptionDescript
linkA list of highlight groups to link to, in order of priority. The first one that exists will be used.
bgThe background color to use, in hex, if the highlight group is not defined and it is not linked to another group.
fgThe foreground color to use, in hex, if the highlight group is not defined and it is not linked to another group.
guiThe gui to use, if the highlight group is not defined and it is not linked to another group.

The gui arg is described in syntax.txt and valid arguments are defined in attr-list :h attr-list

gui={attr-list}
	These give the attributes to use in the GUI mode.
	See |attr-list| for a description.
	Note that "bold" can be used here and by using a bold font.  They
	have the same effect.
	Note that the attributes are ignored for the "Normal" group.

attr-list is a comma-separated list (without spaces) of the following items (in any order):

OptionDescription
bold
underline
undercurlcurly underline
underdoubledouble underline
underdotteddotted underline
underdasheddashed underline
strikethrough
reverse
inversesame as reverse
italic
standout
altfont
nocombineoverride attributes instead of combining them
NONEno attributes used (used to reset it)

The default color configuration is given below

{
    DiredDimText = { link = {}, bg = "NONE", fg = "505050", gui = "NONE" },
    DiredDirectoryName = { link = {}, bg = "NONE", fg = "9370DB", gui = "NONE" },
    DiredDotfile = { link = {}, bg = "NONE", fg = "626262" },
    DiredFadeText1 = { link = {}, bg = "NONE", fg = "626262", gui = "NONE" },
    DiredFadeText2 = { link = {}, bg = "NONE", fg = "444444", gui = "NONE" },
    DiredSize = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "NONE" },
    DiredUsername = { link = {}, bg = "NONE", fg = "87CEFA", gui = "bold" },
    DiredMonth = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "bold" },
    DiredDay = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "bold" },
    DiredFileName = { link = {}, bg = "NONE", fg = "NONE", gui = "NONE" },
    DiredFileSuid = { link = {}, bg = "ff6666", fg = "000000", gui = "bold" },
    DiredNormal = { link = { "Normal" }, bg = "NONE", fg = "NONE", gui = "NONE" },
    DiredNormalBold = { link = {}, bg = "NONE", fg = "ffffff", gui = "bold" },
    DiredSymbolicLink = { link = {}, bg = "NONE", fg = "33ccff", gui = "bold" },
    DiredBrokenLink = { link = {}, bg = "2e2e1f", fg = "ff1a1a", gui = "bold" },
    DiredSymbolicLinkTarget = { link = {}, bg = "5bd75b", fg = "000000", gui = "bold" },
    DiredBrokenLinkTarget = { link = {}, bg = "2e2e1f", fg = "ff1a1a", gui = "bold" },
    DiredFileExecutable = { link = {}, bg = "NONE", fg = "5bd75b", gui = "bold" },
    DiredMarkedFile = { link = {}, bg = "NONE", fg = "a8b103", gui = "bold" },
    DiredCopyFile = { link = {}, bg = "NONE", fg = "ff8533", gui = "bold" },
    DiredMoveFile = { link = {}, bg = "NONE", fg = "ff3399", gui = "bold" },
}

TODO

  1. Allow changing file permissions.