feat(picker): add toggle_regex for grep (#1594)

## 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>
This commit is contained in:
Zhou Fang 2025-10-20 22:52:54 +09:00 committed by GitHub
parent d0a5310417
commit bd6ee23546
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -217,6 +217,7 @@ local defaults = {
["<a-f>"] = { "toggle_follow", mode = { "i", "n" } },
["<a-h>"] = { "toggle_hidden", mode = { "i", "n" } },
["<a-i>"] = { "toggle_ignored", mode = { "i", "n" } },
["<a-r>"] = { "toggle_regex", mode = { "i", "n" } },
["<a-m>"] = { "toggle_maximize", mode = { "i", "n" } },
["<a-p>"] = { "toggle_preview", mode = { "i", "n" } },
["<a-w>"] = { "cycle_win", mode = { "i", "n" } },