Closed Napoleon-Jm closed 2 years ago
I think you can use eval
like this:
fzf --disabled --bind 'change:reload:eval "ls "{q}'
# and type in something like "-al /"
since it's a 'advanced integration'
Advanced fzf, not advanced Ripgrep :)
I think you can use
eval
like this:fzf --disabled --bind 'change:reload:eval "ls "{q}' # and type in something like "-al /"
since it's a 'advanced integration'
Advanced fzf, not advanced Ripgrep :)
Changed like this?
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, a:query)
let reload_command = printf(command_fmt, ':eval "ls "{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
It's not work, and I used wrong case, I guess, fresh for fzf, forgive me.... @junegunn
This works for me
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case '
let initial_command = command_fmt.(a:query)
let reload_command = printf(command_fmt.('%s'), '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:eval '.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
For a normal :RG<cr>
(live grep) not :RG -w 'foo'<cr>
this works for me:
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case '
let initial_command = printf(command_fmt.shellescape(a:query))
let reload_command = printf(command_fmt.('%s'), '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:eval '.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
man fzf
)When I use the 'Advanced ripgrep integration', I changed the initial_command not shellescape the query, in case I can use opts for rg command.
let initial_command = printf(command_fmt, shellescape(a:query))
tolet initial_command = printf(command_fmt,a:query)
and remove the last--
.The :RG -w foo, work's fine, btw, the preview reload will quote the {q}, so when query changed in preivew, the reload will false to
rg --<some initial flag> '-w foo'
.So I want to know could be supported some args to forbid the quote action when replace the {q} template.
The fzf template replace source code I found: https://github.com/junegunn/fzf/blob/cd2340141100e057005d31e653c0ce7a0f7a4af7/src/terminal.go#L1708
By the way, since it's a 'advanced integration', the user may be know the rg rule, maybe remove the quote action?