fzf-lua icon indicating copy to clipboard operation
fzf-lua copied to clipboard

Question: built-in `toggle_ignore` action to `grep`/`live_grep`

Open estacioneto opened this issue 1 year ago • 1 comments

First of all, thank you for the amazing plugin ❤️

I was trying to build my own grep/live_grep version of the toggle_ignore action, but after digging into the code I saw it would not be that trivial since the resume action for these commands is very different from the files picker. I've tried adding the toggle_ignore_flag, changing the rg_opts and then resume, but I couldn't get it right.

Are there any plans on adding a built-in toggle_ignore action to these commands?

Thank you!

estacioneto avatar Jan 30 '24 13:01 estacioneto

First of all, thank you for the amazing plugin ❤️

Ty for your kind words.

Are there any plans on adding a built-in toggle_ignore action to these commands?

I'm not sure about adding that, the UI is already loaded with info, perhaps we can make the curren't command work for grep/live_grep too and it can be an optional addition users can add to their actions (as was before I made this the default with files)?

ibhagwan avatar Jan 30 '24 13:01 ibhagwan

@estacioneto, use:

local fzf_lua = require("fzf-lua")
fzf_lua.setup({
  grep = {
    -- use `ctrl-r` to not override the `ctrl-g` regex toggle
    actions = { ["ctrl-r"] = { fzf_lua.actions.toggle_ignore } },
  }
})

For example :FzfLua grep search=testing debug=true: image

After pressing ctrl-r:

Note the rg command added --no-ignore as its first flag as wel as the match in the doc\tags file which is in fzf-lua's .gitignore image

After pressing ctrl-g to switch to live grep, the flag is still respected: image

ibhagwan avatar Jan 30 '24 16:01 ibhagwan

@ibhagwan amazing!

perhaps we can make the curren't command work for grep/live_grep too

That was exactly what I wanted, especially because it will work with the actions descriptions out of the box.

Thank you so much for doing it so fast! 🤩

estacioneto avatar Jan 30 '24 16:01 estacioneto

@ibhagwan amazing!

perhaps we can make the curren't command work for grep/live_grep too

That was exactly what I wanted, especially because it will work with the actions descriptions out of the box.

Thank you so much for doing it so fast! 🤩

Ty @estacioneto, there's just one tiny issue (if you look at my screenshots), the switch to regex header is not displayed properly when toggling gitignore on grep, will be fixed soon too.

ibhagwan avatar Jan 30 '24 16:01 ibhagwan

@estacioneto, should work as expected on latest.

ibhagwan avatar Jan 30 '24 17:01 ibhagwan