## Problem
The `recent_files` section in the dashboard was not displaying any files
when called without a `cwd` parameter, which is the default usage in
most dashboard examples and documentation.
```lua
-- This would show an empty section after the bug was introduced
{ section = "recent_files", limit = 8 }
```
## Root Cause
When `opts.cwd` was not provided, the code set `root = ""` (empty
string) and passed it to the oldfiles filter:
```lua
local root = opts.cwd and svim.fs.normalize(...) or ""
for file in M.oldfiles({ filter = { [root] = true } }) do
```
The filter logic in `M.oldfiles` checks if a file path starts with the
filter path **AND** if the character immediately after that prefix is a
directory separator (`/` or `\`). With an empty string as the filter
path:
1. `file:sub(1, 0) == ""` is always `true`
2. But `file:sub(1, 1):find("[/\\]")` is `false` for most files (unless
they start with `/` or `\`)
3. This results in `matches = false`, causing all files to be filtered
out
## Solution
Changed the logic to use `nil` instead of an empty string when no `cwd`
is specified:
```lua
local root = opts.cwd and svim.fs.normalize(opts.cwd == true and vim.fn.getcwd() or opts.cwd) or nil
-- Only filter by directory when root is specified. If nil, M.oldfiles will use default filters only (excludes stdpath data/cache/state).
local oldfiles_opts = root and { filter = { [root] = true } } or nil
local ret = {} ---@type snacks.dashboard.Section
for file in M.oldfiles(oldfiles_opts) do
```
When no filter is passed, `M.oldfiles()` uses only its default filters
(excluding stdpath data/cache/state directories), which is the intended
behavior for showing all recent files.
## Testing
All usage scenarios now work correctly:
| Scenario | Code | Behavior |
|----------|------|----------|
| No cwd | `{ section = "recent_files" }` | ✅ Shows all recent files
(except stdpath) |
| Current dir | `{ section = "recent_files", cwd = true }` | ✅ Shows
files in cwd |
| Specific dir | `{ section = "recent_files", cwd = "/path" }` | ✅ Shows
files in specified path |
## Impact
This is a minimal, surgical fix (4 lines changed) that restores the
expected behavior documented in all dashboard examples without affecting
any other functionality.
Fixes the issue where users reported empty recent_files sections after
updating to the latest version.
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>bug: dashboard does not display "recent_files"
section</issue_title>
> <issue_description>### Did you check docs and existing issues?
>
> - [x] I have read all the snacks.nvim docs
> - [x] I have updated the plugin to the latest version before
submitting this issue
> - [x] I have searched the existing issues of snacks.nvim
> - [x] I have searched the existing issues of plugins related to this
issue
>
> ### Neovim version (nvim -v)
>
> 0.11
>
> ### Operating system/version
>
> arch linux
>
> ### Describe the bug
>
> after updating, snacks.dashboard stopped displaying the "recent_files"
section.
> Looking through the commit history, I found that commit `5c4365e` is
relevant to that section. Upon rolling the plugin back to one commit
prior to it (commit `a4de830`), the section displayed as normal.
>
> ### Steps To Reproduce
>
> update to latest commit
>
> ### Expected Behavior
>
> section "recent files" displayed as per the documentations
>
> ### Repro
>
> ```lua
> vim.env.LAZY_STDPATH = ".repro"
> load(vim.fn.system("curl -s
https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
>
> require("lazy.minit").repro({
> spec = {
> { "folke/snacks.nvim", opts = {} },
> -- add any other plugins here
> },
> })
> ```</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
Fixesfolke/snacks.nvim#2283
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: folke <292349+folke@users.noreply.github.com>
## Description
Fix incorrect path filtering when using `recent_files` section with
`cwd`
option in dashboard.
Previously, when setting cwd to `/foo/bar/baz`, files from directories
with
the same prefix like `/foo/bar/bazbaz` were incorrectly included in the
recent
files list. This was due to simple string prefix matching without
considering
directory boundaries.
The fix ensures proper directory boundary checking by verifying that the
path
either exactly matches the filter path or is followed by a "/"
character.
## Screenshots
```lua
return {
"snacks.nvim",
---@type snacks.Config
opts = {
dashboard = {
enabled = true,
sections = {
{
title = "Recent Files " .. vim.uv.cwd(),
section = "recent_files",
cwd = true,
},
},
},
},
}
```
### before
<img width="659" height="149" alt="CleanShot 2025-09-24 at 00 00 13"
src="https://github.com/user-attachments/assets/943ad53f-11c5-49d2-b680-f032ad5fee94"
/>
### after
<img width="639" height="111" alt="CleanShot 2025-09-24 at 00 01 01"
src="https://github.com/user-attachments/assets/0dbde991-5164-4afa-9981-ae6707a8fcc0"
/>
## Description
Supports this plugin for session restorations
https://github.com/rmagatti/auto-session
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Description
I have 5000 oldfiles, every time i go to a new directory and open nvim,
the dashboard recent_files (with `cwd=true`) computation takes 4-5
seconds to go through all oldfiles before deciding nothing should show
up
```lua
sections = {
{ icon = " ", title = "Recent files (current directory)", section = "recent_files", cwd = true },
}
```
It appears to be the `vim.v.oldfiles[i]` indexing. I didn't look much
into it but it opens much faster looping with ipairs.
Repro:
1. add the above section config in dashboard
2. increase oldfiles limit and populate up to the limit
3. `mkdir brand-new-directory; cd brand-new-directory; nvim`
4. the section is empty as expected, but it takes a few seconds before
dashboard shows up
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Description
When `picker` is enabled, the original line removes it from the table
and reinserts it as the first element, preventing the user configuration
in `preset.picker` from being used as the picker. This change inserts it
as the second element instead.
## Description
More info coming tomorrow.
In short:
- very fast. pretty much realtime filtering/sorting in huge repos (like
1.7 million files)
- extensible
- easy to customize the layout (and lots of presets) with
`snacks.layout`
- simple to create custom pickers
- `vim.ui.select`
- lots of builtin pickers
- uses treesitter highlighting wherever it makes sense
- fast lua fuzzy matcher which supports the [fzf
syntax](https://junegunn.github.io/fzf/search-syntax/) and additionally
supports field filters, like `file:lua$ 'function`
There's no snacks picker command, just use lua.
```lua
-- all pickers
Snacks.picker()
-- run files picker
Snacks.picker.files(opts)
Snacks.picker.pick("files", opts)
Snacks.picker.pick({source = "files", ...})
```
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
## Todo
- [x] issue with preview loc not always correct when scrolling fast in
list (probably due to `snacks.scroll`)
- [x] `grep` (`live_grep`) is sometimes too fast in large repos and can
impact ui rendering. Not very noticeable, but something I want to look
at.
- [x] docs
- [x] treesitter highlights are broken. Messed something up somewhere
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Description
This change hashes the caching key for snacks dashboards terminal
sections instead of building the key from the command itself. This
allows for arbitrary length scripts to be given as a terminal section
command instead of relying on existing commands in PATH.
## Related Issue(s)
#379
## Screenshots
<img width="1176" alt="image"
src="https://github.com/user-attachments/assets/77a376c1-75b6-4023-8984-efd590f66a68"
/>
## Description
Adds an `icon` option to the dashboard `startup` section. So people
(like me, who thinks an emoji in a bunch of nerdfonts is awkward) can
change it easily.
## Screenshots
<details>
<summary>Screenshots</summary>
Screenshot with a minimal config

</details>
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
The intention is to make it easier to exclude the dashboard terminal
from some plugins. For example, heirline.nvim sets winbar per-window to
allow for winbar to be optionally disabled in non-floating windows, so
this PR lets me disable heirline for snacks' dashboard terminals over
other floating terminals.
## Description
Don't open dashboard when Neovim opens with only startup option args.
Took a look at how `dashboard.nvim` did it.
They also have an autocmd for `StdInReadPre`, but I tested with piping
`echo "hello" | nvim` and it works as expected.
Not sure if it's the best solution, so feel free to make any additional
changes or completely disregard for something more robust.
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
## Related Issue(s)
Closes#221.
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Description
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
Set the dashboard buffer to not listed for consistency with other
dashboard plugins
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->