Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature: Keybind for adding all current entries to quickfix list #1196

Closed
1 task done
vlashada opened this issue May 14, 2024 · 18 comments
Closed
1 task done

Feature: Keybind for adding all current entries to quickfix list #1196

vlashada opened this issue May 14, 2024 · 18 comments
Labels
feature request New feature

Comments

@vlashada
Copy link

vlashada commented May 14, 2024

Have you RTFM'd?

  • I have done proper research

Feature Request

If I search for something using :FzfLua grep_project<CR>, I want to add all current entries to a quickfix list without first needing to tab select them. You could for instance search for TODO, and then press to get them all to appear in the quickfix list, without first needing to select them with tab

I think this issue solves it: #324, but I do not think it is clear how to do this. I think that adding something to the documentation would be useful

@vlashada vlashada added the feature request New feature label May 14, 2024
@ibhagwan
Copy link
Owner

ibhagwan commented May 14, 2024

This has been asked and answered many times, I’m AFK atm so I can’t write it for you, you need to have an fzf mapping to select-all+accept, or select all prefix to the file_sel_to_qf, see #1109 as the most recent time this was asked.

@vlashada
Copy link
Author

Sorry, I see that my previous comment was imprecise. I do understand how to do it, but I learned how to do it by looking at the issues. This issue was trying to ask for adding clearer documentation on how to do this, so that you don't need to look through the closed issues for the solution.

@ibhagwan
Copy link
Owner

ibhagwan commented May 15, 2024

There is always room for better docs, I’m the sole maintainer and when I have time it goes towards issues/improvements, the docs are WIP.

The wiki is open edit to all, if you wish you can add a new item in the Wiki homepage with your findings.

@ibhagwan
Copy link
Owner

Sorry, I see that my previous comment was imprecise.

Not your fault, I try to be very responsive to issues so I answer from mobile at times, I sometimes miss the essence of the issue when I do that.

@pinpox
Copy link
Contributor

pinpox commented Oct 22, 2024

I'm failing to get this to work right. Set it up as shown in the wiki:

			require("fzf-lua").setup({
				grep = {
					actions = {
						["ctrl-q"] = {
							fn = actions.file_edit_or_qf,
							prefix = "select-all+",
						},
					},
				},
			})

When pressing alt-q only the first of the results is added to the quickfix, while I was trying to add them all. Has the API changed for this or am I doing something wrong?

demo: https://asciinema.org/a/gI9z2U58lZdmetn6Rf9jiMyPj

@ibhagwan
Copy link
Owner

When pressing alt-q only the first of the results is added to the quickfix, while I was trying to add them all. Has the API changed for this or am I doing something wrong?

What version of fzf are you using? Prefix requires fzf version 0.53 and newer.

@ibhagwan ibhagwan reopened this Oct 22, 2024
@pinpox
Copy link
Contributor

pinpox commented Oct 22, 2024

What version of fzf are you using? Prefix requires fzf version 0.53 and newer.

❯ fzf --version
0.55.0 (v0.55.0)

@ibhagwan
Copy link
Owner

What version of fzf are you using? Prefix requires fzf version 0.53 and newer.

❯ fzf --version
0.55.0 (v0.55.0)

Obvious question but you’re using the action on grep/live grep pickers correct?

What happens if you change the action to file_sel_to_qf?

@pinpox
Copy link
Contributor

pinpox commented Oct 22, 2024

No difference. This is exactly what I'm doing:

config now updated to your proposed action as:

			require("fzf-lua").setup({
				grep = {
					actions = {
						["a-q"] = {
							-- fn = actions.file_edit_or_qf,
							fn = actions.file_sel_to_qf,
							prefix = "select-all+",
						},
					},
				},
			})
		end,
  1. Open nvim in project root
  2. Run :FzfLua live_grep
  3. Type something like TODO (lots of results)
  4. Press alt-q

Same behaviour as before, only one item in the quickfix

@ibhagwan
Copy link
Owner

No difference. This is exactly what I'm doing:

config now updated to your proposed action as:

			require("fzf-lua").setup({
				grep = {
					actions = {
						["a-q"] = {
							-- fn = actions.file_edit_or_qf,
							fn = actions.file_sel_to_qf,
							prefix = "select-all+",
						},
					},
				},
			})
		end,
  1. Open nvim in project root
  2. Run :FzfLua live_grep
  3. Type something like TODO (lots of results)
  4. Press alt-q

Same behaviour as before, only one item in the quickfix

Can you run :FzfLua live_grep debug=true and post the full command from the output in :messages?

@pinpox
Copy link
Contributor

pinpox commented Oct 22, 2024

@ibhagwan

[Fzf-lua]: FZF_DEFAULT_COMMAND: true || true                                                                                                                                                                                                                  
[Fzf-lua]: fzf cmd: fzf --header ':: <^[[38;2;255;235;205mctrl-g^[[0m> to ^[[38;2;255;64;64mFuzzy Search^[[0m' --print-query --query '' --bind 'f4:toggle-preview,alt-shift-down:preview-down,ctrl-b:half-page-up,ctrl-e:end-of-line,alt-shift-up:preview-up,s
hift-down:preview-page-down,ctrl-f:half-page-down,ctrl-a:beginning-of-line,shift-up:preview-page-up,zero:execute-silent(mkdir '\''/tmp/nvim-pinpox.pinpox/FK3321/1'\'' && VIMRUNTIME='\''/nix/store/n081rbw0hcs7qbrzg5ndx1k0h3p4f1qy-neovim-unwrapped-0.10.2/s
hare/nvim/runtime'\'' '\''/nix/store/n081rbw0hcs7qbrzg5ndx1k0h3p4f1qy-neovim-unwrapped-0.10.2/bin/nvim'\'' -n --headless --clean --cmd '\''lua vim.g.did_load_filetypes=1; loadfile([[/nix/store/da3w9rhajhcx9w5h3b2hz71i57ykghbf-plugindirs/fzf-lua/lua/fzf-l
ua/shell_helper.lua]])().rpc_nvim_exec_lua({fzf_lua_server=[[/run/user/1000/fzf-lua.1729628196.658282.1]], fnc_id=2 , debug=true})'\'' -- ),ctrl-u:unix-line-discard,alt-g:last,ctrl-z:abort,f3:toggle-preview-wrap,alt-a:toggle-all,alt-G:first,ctrl-g:print(
ctrl-g)+accept,ctrl-q:print(ctrl-q)+accept,ctrl-t:print(ctrl-t)+accept,enter:print(enter)+accept,ctrl-s:print(ctrl-s)+accept,esc:print(esc)+accept,alt-Q:print(alt-Q)+accept,ctrl-v:print(ctrl-v)+accept,alt-q:print(alt-q)+accept,ctrl-c:print(ctrl-c)+accept
' --preview 'VIMRUNTIME='\''/nix/store/n081rbw0hcs7qbrzg5ndx1k0h3p4f1qy-neovim-unwrapped-0.10.2/share/nvim/runtime'\'' '\''/nix/store/n081rbw0hcs7qbrzg5ndx1k0h3p4f1qy-neovim-unwrapped-0.10.2/bin/nvim'\'' -n --headless --clean --cmd '\''lua vim.g.did_load
_filetypes=1; loadfile([[/nix/store/da3w9rhajhcx9w5h3b2hz71i57ykghbf-plugindirs/fzf-lua/lua/fzf-lua/shell_helper.lua]])().rpc_nvim_exec_lua({fzf_lua_server=[[/run/user/1000/fzf-lua.1729628196.658282.1]], fnc_id=1 , debug=true})'\'' -- {} {q}' --preview-w
indow 'nohidden:right:0' --layout 'reverse' --height '100%' --disabled --info 'inline-right' --multi --ansi --highlight-line --prompt '*Rg> ' --border 'none' --bind='change:reload:VIMRUNTIME='\''/nix/store/n081rbw0hcs7qbrzg5ndx1k0h3p4f1qy-neovim-unwrappe
d-0.10.2/share/nvim/runtime'\'' '\''/nix/store/n081rbw0hcs7qbrzg5ndx1k0h3p4f1qy-neovim-unwrapped-0.10.2/bin/nvim'\'' -n --headless --clean --cmd '\''lua vim.g.did_load_filetypes=1; loadfile([[/nix/store/da3w9rhajhcx9w5h3b2hz71i57ykghbf-plugindirs/fzf-lua
/lua/fzf-lua/libuv.lua]])().spawn_stdio([==[e2NtZCA9ICJyZyAtLWNvbHVtbiAtLWxpbmUtbnVtYmVyIC0tbm8taGVhZGluZyAtLWNvbG9yPWFsd2F5cyAtLXNtYXJ0LWNhc2UgLS1tYXgtY29sdW1ucz00MDk2IC1lIHthcmd2en0gIiwgZyA9IHtfZnpmX2x1YV9zZXJ2ZXIgPSAiL3J1bi91c2VyLzEwMDAvZnpmLWx1YS4xNz
I5NjI4MTk2LjY1ODI4Mi4xIiwgX2Rldmljb25zX3BhdGggPSAiL25peC9zdG9yZS9kYTN3OXJoYWpoY3g5dzVoM2IyaHo3MWk1N3lrZ2hiZi1wbHVnaW5kaXJzL252aW0td2ViLWRldmljb25zLyJ9LCBhcmd2X2V4cHIgPSB0cnVlLCBkZWJ1ZyA9IHRydWUsIGNvbG9yX2ljb25zID0gdHJ1ZSwgZmlsZV9pY29ucyA9IHRydWUsIGdpdF9p
Y29ucyA9IGZhbHNlfQ==]==],[==[cmV0dXJuIHJlcXVpcmUoIm1ha2VfZW50cnkiKS5maWxl]==],[==[cmV0dXJuIHJlcXVpcmUoIm1ha2VfZW50cnkiKS5wcmVwcm9jZXNz]==],[==[bmls]==])'\'' -- {q} 2>&1 || true' > '/tmp/nvim-pinpox.pinpox/FK3321/3'  

@ibhagwan
Copy link
Owner

From the command: alt-q:print(alt-q)+accept, there is no select-all+ added - is it possible you have 2 versions of fzf installed and neovim uses the older version? Can you run :new | term and verify the path of fzf and version?

I’m still traveling but I’ll be back tomorrow so I’ll be back to debug this if there’s a deeper issue.

@pinpox
Copy link
Contributor

pinpox commented Oct 22, 2024

The version is correct, here is a screenshot from the terminal inside nvim:
image

@ibhagwan
Copy link
Owner

The version is correct

Alright, I’ll do some testing when I get back tomorrow.

@pinpox
Copy link
Contributor

pinpox commented Oct 22, 2024

Alright, I’ll do some testing when I get back tomorrow.

No worries. Thanks for looking into it, just let me know if you need further info !

@ibhagwan
Copy link
Owner

Alright, I’ll do some testing when I get back tomorrow.

No worries. Thanks for looking into it, just let me know if you need further info !

@pinpox, I just tried the below, with alt-q instead of a-q (i'm assuming you had a typo in the issue as a-q is not a supported bind and the interface doesn't open with it) and it works as expected:

require("fzf-lua").setup({
  grep = {
    actions = {
      ["alt-q"] = {
        fn = require("fzf-lua").actions.file_edit_or_qf,
        prefix = "select-all+",
      },
    },
  },
})

Tried with both zsh and fish (longshot) and it works as expected, using debug=true the alt-q bind shows up like this:

alt-q:print(alt-q)+select-all+accept

I'm not sure what else can be the reason preventing your custom function from being loaded, can you try with mini.sh?

  • Create test.lua with the contents I posted above
  • Run:
sh -c "$(curl -s https://raw.githubusercontent.com/ibhagwan/fzf-lua/main/scripts/mini.sh)"
  • Open :e test.lua
  • Source it with :so %
  • Run FzfLua live_grep debug=true and test?

@pinpox
Copy link
Contributor

pinpox commented Oct 23, 2024

Solved! 😍
I tried testing with mini.sh as you requested and it worked. Copying the same config to my own vim config did not though though, upon searching, it seems I had an error in my lazy.nvim config, fzf-lua was not being setup as specified, but still being loaded as a dependency of another plugin making the command available but not working correctly (without showing any errors)
Thanks for the help debugging!

@ibhagwan
Copy link
Owner

Solved! 😍 I tried testing with mini.sh as you requested and it worked. Copying the same config to my own vim config did not though though, upon searching, it seems I had an error in my lazy.nvim config, fzf-lua was not being setup as specified, but still being loaded as a dependency of another plugin making the command available but not working correctly (without showing any errors) Thanks for the help debugging!

Great! Ty for the update @pinpox!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature request New feature
Projects
None yet
Development

No branches or pull requests

3 participants