feat(picker actions): picker_grep accepts picker to search selected dirs#2623
Open
joshzcold wants to merge 2 commits intofolke:mainfrom
Open
feat(picker actions): picker_grep accepts picker to search selected dirs#2623joshzcold wants to merge 2 commits intofolke:mainfrom
joshzcold wants to merge 2 commits intofolke:mainfrom
Conversation
- 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.
Author
|
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 Maybe this is better stored in a recipe? Thoughts? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
this allows selecting directories in
exporterand 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>/inSnacks.exploreris pretty close, but I think this feature is one step further in nice functionality.Related Issue(s)
Screenshots
<leader>/to show results just from those 2 selected directoriesQuestions
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
Is there a way to pass the
selectedto a separated search outside ofexplorerlikeSnacks.picker.files()Is this concept worth doing the ground work to have different types of
selectedthat don't conflict withcopy/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.