I use a convenience package fzf.vim to integrate fzf with vim. The file search works perfect and has completely replaced CtrlP plugin, but the functionality to grep files has unfortunate side-effect of fzf thinking the auto-appended filename (by ripgrep, but this would be the case with ag (silver-searcher) and regular grep as well) is part of the search string.
As a result, the best result doesn't always come to the top (or bottom in my case based on layout). Here is an example:
The result that appears last in this case should actually be first because it's the only result that matches by content (as intended by Rg) rather than file name. This problem is especially frustrating on large repos, where irrelevant results could litter your entire search space.
I should also clarify that the problem occurs because I invoke :Rg
from a shortcut, so the filtering is done by fzf, not rg (which just dumps everything to fzf).
This problem occurs in default :Rg
implementation bundled with fzf.vim as well as my attempt to roll my own:
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
I couldn't figure out how to remedy this issue. Can someone help?