grep compat

This commit is contained in:
Bryan Ramos 2026-05-07 11:04:04 -04:00
parent 024b6ee244
commit 5ce1ceea15

20
vimrc
View file

@ -145,20 +145,24 @@ function! GitRoot()
endfunction
function! FzfRg()
if exists(':Rg') != 2
echohl WarningMsg | echom 'fzf.vim :Rg command is not available' | echohl None
if exists(':Rg') != 2 && exists(':grep') != 2
echohl WarningMsg | echom 'No project search command is available' | echohl None
return
endif
if !executable('rg')
echohl WarningMsg | echom 'ripgrep executable "rg" is not available' | echohl None
return
endif
let l:query = input('Rg: ')
let l:query = input('Search: ')
if empty(l:query)
return
endif
execute 'lcd ' . fnameescape(GitRoot())
execute 'Rg ' . escape(l:query, '|')
if executable('rg') && exists(':Rg') == 2
execute 'Rg ' . escape(l:query, '|')
else
let l:grepprg = &grepprg
set grepprg=grep\ -RIn
execute 'silent grep! ' . shellescape(l:query) . ' .'
let &grepprg = l:grepprg
copen
endif
endfunction
function! SafeBdelete()