Skip to content

feat(picker actions): picker_grep accepts picker to search selected dirs#2623

Open
joshzcold wants to merge 2 commits intofolke:mainfrom
joshzcold:main
Open

feat(picker actions): picker_grep accepts picker to search selected dirs#2623
joshzcold wants to merge 2 commits intofolke:mainfrom
joshzcold:main

Conversation

@joshzcold
Copy link

@joshzcold joshzcold commented Dec 14, 2025

Description

  • this allows selecting directories in exporter and doing <leader>/
    to search the selected dirs from the user. This still supports a
    single item from the explorer as well.

    This is helpful in mono-repo setups where usually to get "scoped search" you would need to :cd <dir> then search which removes the context from the sibling repos. Being able to <leader>/ in Snacks.explorer is pretty close, but I think this feature is one step further in nice functionality.

Related Issue(s)

None that I can find.

Screenshots

  1. Selecting a few directories to search
image
  1. Pressing <leader>/ to show results just from those 2 selected directories
image

Questions

  1. Does it make sense to deselect from these directories in explorer after the search is done or is it more useful to keep them selected for next searches

  2. Is there a way to pass the selected to a separated search outside of explorer like Snacks.picker.files()

  3. Is this concept worth doing the ground work to have different types of selected that don't conflict with copy/paste ? Other IDEs let you enable and disable "folders" within a project to scope search. Could be next to have that also be a supported feature in Snacks.picker.

- this allows selecting directories in `exporter` and doing `<leader>/`
  to search the selected dirs from the user. This still supports a
  single item from the explorer as well.
@github-actions github-actions bot added picker size/s Small PR (<10 lines changed) labels Dec 14, 2025
@joshzcold
Copy link
Author

joshzcold commented Dec 14, 2025

To answer question number 2, this works:

      { "<leader>e",      function()
        local pickers = Snacks.picker.get({source= "explorer"})
        local picker = pickers[1]

        local search_dirs = {}
        for _, selected in ipairs(picker:selected({ fallback = true })) do
          table.insert(search_dirs, Snacks.picker.util.path(selected))
        end

        if search_dirs then
          Snacks.picker.files({ dirs = search_dirs })
        else
          Snacks.picker.files()
        end

      end, desc = "Find Config File" },

This works for getting the active picker.

Considering that this works while the explorer is open, it might not be needed to overwrite the <leader>/ behavior of picker_grep considering that I could achieve the same result in my config?

Maybe this is better stored in a recipe?

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

picker size/s Small PR (<10 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant