## For people who want to use it NOW!
Use `init` to hack the latest version before this PR merge.
```lua
{
"folke/snacks.nvim",
init = function()
local sources = require("snacks.picker.config.sources")
sources.grep.toggles = {
regex = { value = true },
}
sources.grep.win = {
input = {
keys = {
["<a-r>"] = { "toggle_regex", mode = { "n", "i" }, desc = "Toggle Regex" },
},
},
}
end,
},
```
## Description
This PR adds a new keymap `<a-r>` for toggling the regex in grep picker.
It allows user to get faster when searching some special strings like
`$props()`, or just put a part of line `test to jump faster.
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
https://github.com/user-attachments/assets/2442b21c-898f-4682-a966-5a82abdd23e8
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
## Description
Before this fix, identical items are added to history repeatedly. This
PR fixes this by only adding an item to history if it's different from
the last recorded value.
This doesn't completely remove duplicate entries in the history, it only
prevents consecutive identical entries.
## Description
- I was trying to go to the commit page from fugitive commit buffers
- but snacks.nvim doesn't support this (fugitive does) and so I wanted a
way to send the commit IDs to the gitbrowse function after parsing it
myself in my dotfiles
### changes
- added `commit` option to `gitbrowse` config to allow passing commit
hashes directly instead of only auto-detecting from cursor word or file
history
- only falls back to auto-detection when `commit` is not explicitly
provided
## 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
the documentation for `snacks.notifier.Config` says:
f6c06415a2/lua/snacks/notifier.lua (L120-L122)
But currently all notifications filtered out by either `opts.level` or
`opts.filter` are also omitted from the history, on top of being
suppressed from displaying
Fixes this regression
## Related Issue(s)
* Related to #93, although that was caused by misconfiguration. This one
is an actual bug
* Closes#2208
## Screenshots
n/a
## Description
When opening a terminal with position='current', the terminal buffer
wasn't being set in the current window, causing the original buffer
content to remain visible with terminal styling applied.
This fix adds a call to vim.api.nvim_win_set_buf() to properly set the
terminal buffer when using position='current'. Also updates type
annotations to include the 'current' position option and adds tests to
prevent regression.
Credit to the solution to by @Baricus in issue #2148.
## Related Issue(s)
Fixes#2148
Co-authored-by: Baricus <31926270+Baricus@users.noreply.github.com>
## Description
GitLab highlighting uses a different scheme for range of lines
fb2f3ce787/app/assets/javascripts/repository/mixins/highlight_mixin.js (L114)
## 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 PR fixes an issue where normal mode commands were being executed in
terminal mode buffers. The change ensures that the command `norm! zz` is
only executed if the buffer type is not "terminal". This prevents errors
when using Zen mode with terminal buffers.
## Related Issue(s)
- Fixes#1911
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Description
Fix typo in snacks-picker docs. I've noticed the docs are
auto-generated, so I split my changes into 2 commits so I can drop the
change to the markdown file if preferred. Just let me know!
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
## Description
Allow specifying a page number for pdfs inside of markdown.
This is done by adding "#page=<page-number>" to the file name. This is
same way it is done in obsidian (as discussed in
https://forum.obsidian.md/t/link-to-the-exact-page-of-and-external-pdf-file/2111)
The parsing of the page info should probably be done way before the
conversion, but this was the best I could with my limited time.
I'm pretty new to lua, and this codebase, so this might not be the best
code, but I hope it at least helps :D
## Related Issue(s)
- Fixes#1805
Fix off-by-one issue in render_fallback when a tabline is shown (e.g.
with plugins like bufferline.nvim).
## Description
When a tabline is used/shown, the positioning in render_fallback is off
by one. This change checks whether a tabline would be shown and uses the
correct math for that case and, otherwise, works as before.
## Related Issue(s)
- Fixes#1557
## Description
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
This fixes the `image.src` capture for markdown shortcut links, which
(imho) are links like `![[attachments/test.jpg]]`.
The current query captures also the `[...]`.
If we talk about a different type of links for this query, it would be
interesting to know which ones :).
## 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 PR adds basic support for visual block selections to
`Snacks.debug.run()`. This is useful when code doesn't start at the
beginning of a line, such as in comment blocks.
## 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. -->
<img width="271" alt="Screenshot 2025-02-19 at 23 02 35"
src="https://github.com/user-attachments/assets/5a440b32-6846-4345-b105-42e64796ac65"
/>
## 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
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
I recently got really into improving my experience with netrw, in one of
those explorations I managed to integrate with the `Snacks.rename`
module by remapping the default rename mapping. So I thought it would be
cool to include a more native approach to the documentation of this
module.
> PS: In the example I implemented with the `vim.ui.input` interface
since it should be the new standard, but if you prefer with the original
`vim.fn.input` I can change it.
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
N/a
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
[](https://asciinema.org/a/735692)
## 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"
/>