mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-06 12:44:24 +08:00
Change fzf#vim#grep to rely on temporary FZF_DEFAULT_COMMAND
Related #907 Also https://github.com/junegunn/fzf/issues/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)
This commit is contained in:
@@ -695,7 +695,7 @@ function! fzf#vim#ag_raw(command_suffix, ...)
|
||||
return call('fzf#vim#grep', extend(['ag --nogroup --column --color '.a:command_suffix, 1], a:000))
|
||||
endfunction
|
||||
|
||||
" command, with_column, [options]
|
||||
" command (string), with_column (0/1), [options (dict)], [fullscreen (0/1)]
|
||||
function! fzf#vim#grep(grep_command, with_column, ...)
|
||||
let words = []
|
||||
for word in split(a:grep_command)
|
||||
@@ -708,7 +708,6 @@ function! fzf#vim#grep(grep_command, with_column, ...)
|
||||
let name = join(words, '-')
|
||||
let capname = join(map(words, 'toupper(v:val[0]).v:val[1:]'), '')
|
||||
let opts = {
|
||||
\ 'source': a:grep_command,
|
||||
\ 'column': a:with_column,
|
||||
\ 'options': ['--ansi', '--prompt', capname.'> ',
|
||||
\ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all',
|
||||
@@ -718,7 +717,13 @@ function! fzf#vim#grep(grep_command, with_column, ...)
|
||||
return s:ag_handler(a:lines, self.column)
|
||||
endfunction
|
||||
let opts['sink*'] = remove(opts, 'sink')
|
||||
try
|
||||
let prev_default_command = $FZF_DEFAULT_COMMAND
|
||||
let $FZF_DEFAULT_COMMAND = a:grep_command
|
||||
return s:fzf(name, opts, a:000)
|
||||
finally
|
||||
let $FZF_DEFAULT_COMMAND = prev_default_command
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user