mirror of
https://github.com/itme-brain/vim.git
synced 2026-05-08 07:30:13 -04:00
grep compat
This commit is contained in:
parent
024b6ee244
commit
5ce1ceea15
1 changed files with 12 additions and 8 deletions
18
vimrc
18
vimrc
|
|
@ -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())
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue