-
-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: new fzf feature reload inside vim #907
Comments
Please post the code you tried. |
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let options = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, options, a:fullscreen)
endfunction
command! -nargs=1 -bang RF call RipgrepFzf(<q-args>, <bang>0) This works for me. There is one problem though, that the command requires an initial query. This is to avoid starting ripgrep command for an empty query that can run for a very long time producing a lot of lines. And fzf cannot kill the initial command on "change", because it wasn't started by fzf process. # fzf can kill subsequent-rg-command because it started it, but not initial-rg-command
initial-rg-command | fzf ... --bind 'change:reload:subsequent-rg-command' A workaround is to set # fzf can now kill both initial command and subsequent command
FZF_DEFAULT_COMMAND=initial-rg-command \
fzf ... --bind 'change:reload:subsequent-rg-command' However, |
Related #907 Also junegunn/fzf#1750 function! RipgrepFzf(query, fullscreen) let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' let initial_command = printf(command_fmt, shellescape(a:query)) let reload_command = printf(command_fmt, '{q}') let options = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} call fzf#vim#grep(initial_command, 1, options, a:fullscreen) endfunction command! -nargs=* -bang RF call RipgrepFzf(<q-args>, <bang>0)
Now this works well with the above commit. function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let options = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(options), a:fullscreen)
endfunction
command! -nargs=* -bang RF call RipgrepFzf(<q-args>, <bang>0) |
Thank you. |
@amebrahimi I had the same issue , turns out I've not installed rg , maybe it is the case? |
I've the same issue as amebrahimi here above even though I've installed all required packages (arch distro). " This is the default extra key bindings " Enable per-command history. map :Files let g:fzf_tags_command = 'ctags -R' let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' " Customize fzf colors to match your color scheme "Get Files " Get text in files with Rg " Ripgrep advanced |
I have this "Command failed..." issue shown in the screenshot above. It happens when I start :Rg with a command and it finds no matches (e.g. :Rg ksdfjsdjfskdlfsalkdjf). Start it with something where it will have hits (e.g. :Rg vim) and it's fine. Would be nice if done more elegantly though. |
Is it possible to use it and execute vim function or command? If yes, can you please explain how to do it. Because my several attempts failed with
[Command failed: ...]
.Or by now only possible way is to imitate same command as
source
of fzf#run?Thank you.
The text was updated successfully, but these errors were encountered: