Migrate from the silver searcher to ripgrep
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
if exists("g:ctrlp_user_command")
|
||||
unlet g:ctrlp_user_command
|
||||
endif
|
||||
if executable('ag')
|
||||
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
|
||||
let g:ctrlp_user_command =
|
||||
\ 'ag %s --files-with-matches -g "" --ignore "\.git$\|\.hg$\|\.svn$"'
|
||||
|
||||
" ag is fast enough that CtrlP doesn't need to cache
|
||||
if executable('rg')
|
||||
" Use rg in CtrlP for listing files. Lightning fast and respects .gitignore
|
||||
let g:ctrlp_user_command = 'rg --files --smart-case %s'
|
||||
|
||||
" rg is fast enough that CtrlP doesn't need to cache
|
||||
let g:ctrlp_use_caching = 0
|
||||
else
|
||||
" Fall back to using git ls-files if Ag is not available
|
||||
|
||||
3
vim/settings/ripgrep.vim
Normal file
3
vim/settings/ripgrep.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
" Open the Rg command and place the cursor into the quotes
|
||||
nmap ,rg :Rg ""<Left>
|
||||
nmap ,rf :Rg --files ""<Left>
|
||||
@@ -11,20 +11,20 @@ function! GetVisual()
|
||||
endfunction
|
||||
|
||||
"grep the current word using K (mnemonic Kurrent)
|
||||
nnoremap <silent> K :Ag <cword><CR>
|
||||
nnoremap <silent> K :Rg <cword><CR>
|
||||
|
||||
"grep visual selection
|
||||
vnoremap K :<C-U>execute "Ag " . GetVisual()<CR>
|
||||
vnoremap K :<C-U>execute "Rg " . GetVisual()<CR>
|
||||
|
||||
"grep current word up to the next exclamation point using ,K
|
||||
nnoremap ,K viwf!:<C-U>execute "Ag " . GetVisual()<CR>
|
||||
nnoremap ,K viwf!:<C-U>execute "Rg " . GetVisual()<CR>
|
||||
|
||||
"grep for 'def foo'
|
||||
nnoremap <silent> ,gd :Ag 'def <cword>'<CR>
|
||||
nnoremap <silent> ,gd :Rg 'def <cword>'<CR>
|
||||
|
||||
",gg = Grep! - using Ag the silver searcher
|
||||
",gg = Grep! - using Rg RipGrep
|
||||
" open up a grep line, with a quote started for the search
|
||||
nnoremap ,gg :Ag ""<left>
|
||||
nnoremap ,gg :Rg ""<left>
|
||||
|
||||
"Grep for usages of the current file
|
||||
nnoremap ,gcf :exec "Ag " . expand("%:t:r")<CR>
|
||||
nnoremap ,gcf :exec "Rg " . expand("%:t:r")<CR>
|
||||
|
||||
Reference in New Issue
Block a user