Skip to main content
Snacks.nvim is a comprehensive plugin that provides multiple utilities in one package. It’s loaded early with high priority for immediate availability.
lua/plugins/snacks.lua
priority = 1000,
lazy = false,

Core features

Picker

Fuzzy finder for files, grep, buffers, LSP, and more

Explorer

File explorer with diagnostics and git integration

Notifier

Notification system with history

Dashboard

Startup dashboard with quick actions

Scratch buffers

Temporary note-taking buffers

Zen mode

Distraction-free editing modes

Picker

The picker is the primary way to find and navigate files, code, and git objects.

File finding

KeyActionDescription
<leader>ffFind filesSearch files in current directory
<leader><leader>Smart findAuto-detect git root or use cwd
<leader>frRecent filesBrowse recently opened files
<leader>fpProjectsSwitch between projects
<leader>ncConfig filesSearch Neovim config directory
lua/plugins/snacks.lua
{
  "<leader>ff",
  function()
    Snacks.picker.files({
      layout = "ivy_taller",
      supports_live = true,
      format = "file",
      finder = "files",
    })
  end,
  desc = "[F]ind [F]iles",
}
The picker automatically shows hidden files (dotfiles) by default.

Text searching

KeyActionDescription
<leader>faGrep allLive grep across all files
<leader>fvGrep wordSearch for word under cursor or visual selection
lua/plugins/snacks.lua
{
  "<leader>fa",
  function()
    local layout = "ivy_split"
    if vim.bo.filetype == "snacks_dashboard" then
      layout = "dashboard_ivy_split"
    end
    Snacks.picker.grep({ layout = layout })
  end,
  desc = "[F]ind [A]ll",
}

Buffer management

lua/plugins/snacks.lua
{
  "<leader>jk",
  function()
    Snacks.picker.buffers({
      on_show = function()
        vim.cmd.stopinsert()
      end,
      finder = "buffers",
      hidden = false,
      unloaded = true,
      current = true,
      sort_lastused = true,
      win = {
        input = { keys = { ["d"] = "bufdelete" } },
        list = { keys = { ["d"] = "bufdelete" } },
      },
      layout = "ivy_taller",
    })
  end,
  desc = "Snacks picker buffers",
}
Press d on any buffer in the picker to delete it without opening.

LSP navigation

Snacks picker powers all LSP navigation:
gd - Go to definition with auto-confirm for single results
Snacks.picker.lsp_definitions({
  unique_lines = true,
  auto_confirm = true,
  jump = { reuse_win = true },
})

Git pickers

KeyCommandDescription
<leader>glGit log lineCommits that modified current line
<leader>gdGit diffBrowse all changed hunks
<leader>gSGit stashManage stashes interactively
<leader>goGit browseOpen file on GitHub/GitLab
lua/plugins/snacks.lua
{
  "<leader>gl",
  function()
    Snacks.picker.git_log_line({
      on_show = function()
        vim.cmd.stopinsert()
      end,
    })
  end,
  desc = "Git log for current line",
}

Search utilities

KeyActionDescription
<leader>shHelp pagesSearch Neovim help documentation
<leader>skKeymapsBrowse all keybindings
<leader>sCCommandsSearch Neovim commands
<leader>sdDiagnosticsBuffer diagnostics
<leader>sDDiagnosticsWorkspace diagnostics
<leader>spPluginsSearch plugin specs
<leader>suUndo historyBrowse undo tree
<leader>smMarksBrowse marks
<leader>sjJumpsBrowse jump list
<leader>srResumeResume last picker

Picker keybindings

Inside any picker window:
KeyActionDescription
<Esc>CloseClose picker (normal and insert mode)
<M-p>Cycle layoutsSwitch between layout presets
<Tab>Focus previewJump to preview window
JScroll downScroll preview down (normal mode)
KScroll upScroll preview up (normal mode)
HScroll leftScroll preview left (normal mode)
LScroll rightScroll preview right (normal mode)
lua/plugins/snacks.lua
win = {
  input = {
    keys = {
      ["<Esc>"] = { "close", mode = { "n", "i" } },
      ["<M-p>"] = { "cycle_layouts", mode = { "i", "n" } },
      ["<Tab>"] = { "focus_preview", mode = { "i", "n" } },
    },
  },
}

Picker configuration

lua/plugins/snacks.lua
picker = {
  sources = {
    files = {
      hidden = true, -- Show hidden files (dotfiles) by default
    },
  },
  matcher = {
    frecency = true, -- Use frequency + recency for sorting
  },
  formatters = {
    file = {
      filename_first = true, -- Display filename before path
      truncate = 80,
    },
  },
}

Explorer

File explorer with git status and diagnostics integration.

Opening explorer

lua/plugins/snacks.lua
{
  "<M-e>",
  function()
    Snacks.explorer()
  end,
  desc = "File Explorer",
}

Configuration

lua/plugins/snacks.lua
explorer = {
  enabled = true,
  show_hidden = true,
}

Features

Git integration

Shows git status indicators for files

Diagnostics

Auto-opens folders with errors/warnings

Netrw replacement

Replaces default file explorer

Line numbers

Shows absolute line numbers in list

Notifications

Beautiful notification system with history.

Usage

vim.notify("Message", vim.log.levels.INFO)

Configuration

lua/plugins/snacks.lua
notifier = {
  enabled = true,
  timeout = 3000, -- Auto-dismiss after 3 seconds
}

Managing notifications

KeyActionDescription
<leader>nhHistoryShow notification history
<leader>unDismissDismiss all notifications
lua/plugins/snacks.lua
{
  "<leader>nh",
  function()
    Snacks.notifier.show_history()
  end,
  desc = "Notification History",
}

Scratch buffers

Temporary buffers for notes and experiments.
KeyActionDescription
<leader>.ScratchToggle scratch buffer
<leader>SSelectSelect from multiple scratch buffers
lua/plugins/snacks.lua
{
  "<leader>.",
  function()
    Snacks.scratch()
  end,
  desc = "Toggle Scratch Buffer",
}
Scratch buffers are persisted across sessions. Use them for quick notes, calculations, or testing code snippets.

Zen mode

Distraction-free editing with two modes:
<leader>z - Full zen mode with hidden UI elements
function()
  Snacks.zen()
end
Hides statusline, tabline, and centers content.

Dashboard

Startup dashboard with quick actions:
lua/plugins/snacks.lua
dashboard = { enabled = true }
Launches automatically when opening Neovim without a file.

Indent guides

Animated indent guides with scope highlighting:
lua/plugins/snacks.lua
indent = {
  enabled = true,
  animate = {
    style = "up_down",
    duration = {
      step = 25, -- ms per step
      total = 1000, -- maximum duration
    },
  },
  scope = {
    underline = true, -- underline the start of the scope
  },
}
Toggle indent guides with <leader>ug.

Utility functions

Buffer operations

KeyActionDescription
<leader>bdDelete bufferSmart buffer deletion
<leader>cRRename fileRename file and update imports
lua/plugins/snacks.lua
{
  "<leader>bd",
  function()
    Snacks.bufdelete()
  end,
  desc = "Delete Buffer",
}

Word navigation

KeyActionDescription
<leader>fnNext referenceJump to next reference of word under cursor
<leader>fNPrev referenceJump to previous reference

Toggles

Snacks provides convenient toggles for various options:
KeyToggleDescription
<leader>usSpellingToggle spell check
<leader>uwWrapToggle line wrapping
<leader>uLRelative numberToggle relative line numbers
<leader>udDiagnosticsToggle diagnostic display
<leader>ulLine numberToggle line numbers
<leader>ucConcealToggle conceallevel
<leader>uTTreesitterToggle treesitter highlighting
<leader>ubBackgroundToggle light/dark background
<leader>ugIndent guidesToggle indent guides
<leader>uDDimToggle dim inactive windows
lua/plugins/snacks.lua
Snacks.toggle.option("spell", { name = "Spelling" }):map("<leader>us")
Snacks.toggle.option("wrap", { name = "Wrap" }):map("<leader>uw")
Snacks.toggle.diagnostics():map("<leader>ud")

Input dialogs

Snacks provides improved input dialogs:
lua/plugins/snacks.lua
input = { enabled = true }
All vim.ui.input() calls use Snacks input for better UI.

Advanced configuration

Custom layouts

The configuration uses custom layouts defined in utils/snacks_picker.lua:
lua/plugins/snacks.lua
layout = {
  preset = function()
    return require("utils.snacks_picker").preferred_layout()
  end,
  cycle = false,
}

File exclusions

lua/plugins/snacks.lua
exclude = {
  "*.pb",
  "*.gw",
  "*.pb.go",
  "*.pb.gw.go",
  "*.pb.validate.go",
  "*.swagger.json",
  ".git",
  "node_modules",
}

Integration with other plugins

Snacks integrates with:
  • Neogit: Git operations use Snacks pickers
  • Trouble: Send picker results to Trouble with <c-t>
  • CodeDiff: Git browsing uses Snacks for stash management

Performance

High priority

Loaded early (priority = 1000) for immediate availability

Not lazy

Always loaded to ensure utilities are ready

Frecency sorting

Intelligent file ranking based on frequency and recency

Efficient rendering

Optimized for large directories and search results

Build docs developers (and LLMs) love