๐Ÿฟ explorer

October 25, 2025 ยท View on GitHub

A file explorer for snacks. This is actually a picker in disguise.

This module provide a shortcut to open the explorer picker and a setup function to replace netrw with the explorer.

When the explorer and replace_netrw is enabled, the explorer will be opened:

  • when you start nvim with a directory
  • when you open a directory in vim

Configuring the explorer picker is done with the picker options.

-- lazy.nvim
{
  "folke/snacks.nvim",
  ---@type snacks.Config
  opts = {
    explorer = {
      -- your explorer configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    },
    picker = {
      sources = {
        explorer = {
          -- your explorer picker configuration comes here
          -- or leave it empty to use the default settings
        }
      }
    }
  }
}

image

๐Ÿš€ Usage

File Operations

The explorer provides powerful file operations with an intuitive selection-based workflow.

Moving and Copying Files

The most efficient way to move or copy multiple files:

  1. Select files with <Tab> (works on multiple files)
  2. Navigate to the target directory
  3. Execute the operation:
    • Press m to move selected files to the current directory
    • Press c to copy selected files to the current directory
Example workflow:
1. Navigate to source files
2. Press <Tab> on file1.txt
3. Press <Tab> on file2.txt (both now selected)
4. Navigate to target directory
5. Press 'm' โ†’ files are moved!

Single file operations:

  • m on a single file (no selection) โ†’ renames the file
  • c on a single file (no selection) โ†’ prompts for new name to copy to
  • r โ†’ rename current file
  • d โ†’ delete current/selected files

Copy/Paste with Registers

Alternative workflow using yank and paste:

  1. Select files with <Tab> or visual mode
  2. Press y to yank file paths to register
  3. Navigate to target directory
  4. Press p to paste (copies files from register)

This works across different explorer instances and even after closing/reopening!

Other File Operations

  • a โ†’ Add new file or directory (directories end with /)
  • d โ†’ Delete files (uses system trash if available, see :checkhealth snacks)
  • o โ†’ Open file with system application
  • u โ†’ Update/refresh the file tree
  • <CR> or l โ†’ Open file or toggle directory
  • h โ†’ Close directory
  • <BS> โ†’ Go up one directory
  • . โ†’ Focus on current directory (set as cwd)
  • H โ†’ Toggle hidden files
  • I โ†’ Toggle ignored files (from gitignore)
  • Z โ†’ Close all directories

Quick Actions

  • <leader>/ โ†’ Grep in current directory
  • <c-t> โ†’ Open terminal in current directory
  • <c-c> โ†’ Change tab directory to current directory
  • P โ†’ Toggle preview

Git Integration

When git_status = true (default), files show git status indicators:

  • ]g / [g โ†’ Jump to next/previous git change
  • Directories show aggregate status of contained files

Diagnostics

When diagnostics = true (default), files show diagnostic indicators:

  • ]d / [d โ†’ Jump to next/previous diagnostic
  • ]e / [e โ†’ Jump to next/previous error
  • ]w / [w โ†’ Jump to next/previous warning

Visual Mode

You can use visual mode (v or V) to select multiple files, then:

  • y โ†’ Yank selected file paths
  • Any other operation works on visual selection

๐Ÿ“ฆ Setup

-- lazy.nvim
{
  "folke/snacks.nvim",
  ---@type snacks.Config
  opts = {
    explorer = {
      -- your explorer configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    }
  }
}

โš™๏ธ Config

These are just the general explorer settings. To configure the explorer picker, see snacks.picker.explorer.Config

---@class snacks.explorer.Config
{
  replace_netrw = true, -- Replace netrw with the snacks explorer
  trash = true, -- Use the system trash when deleting files
}

๐Ÿ“ฆ Module

Snacks.explorer()

---@type fun(opts?: snacks.picker.explorer.Config): snacks.Picker
Snacks.explorer()

Snacks.explorer.health()

Snacks.explorer.health()

Snacks.explorer.open()

Shortcut to open the explorer picker

---@param opts? snacks.picker.explorer.Config|{}
Snacks.explorer.open(opts)

Snacks.explorer.reveal()

Reveals the given file/buffer or the current buffer in the explorer

---@param opts? {file?:string, buf?:number}
Snacks.explorer.reveal(opts)