Fallback to ag if rg is not present
This commit is contained in:
parent
5f84472e2b
commit
156e7fad14
3
vim/settings/ag.vim
Normal file
3
vim/settings/ag.vim
Normal file
@ -0,0 +1,3 @@
|
||||
" Open the Ag command and place the cursor into the quotes
|
||||
nmap ,ag :Ag ""<Left>
|
||||
nmap ,af :AgFile ""<Left>
|
@ -7,6 +7,12 @@ if executable('rg')
|
||||
|
||||
" rg is fast enough that CtrlP doesn't need to cache
|
||||
let g:ctrlp_use_caching = 0
|
||||
elseif 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
|
||||
let g:ctrlp_use_caching = 0
|
||||
else
|
||||
" Fall back to using git ls-files if Ag is not available
|
||||
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
|
||||
|
@ -11,20 +11,20 @@ function! GetVisual()
|
||||
endfunction
|
||||
|
||||
"grep the current word using ,k (mnemonic Kurrent)
|
||||
nnoremap <silent> ,k :Rg <cword><CR>
|
||||
nnoremap <silent> ,k :Ag <cword><CR>
|
||||
|
||||
"grep visual selection
|
||||
vnoremap ,k :<C-U>execute "Rg " . GetVisual()<CR>
|
||||
vnoremap ,k :<C-U>execute "Ag " . GetVisual()<CR>
|
||||
|
||||
"grep current word up to the next exclamation point using ,K
|
||||
nnoremap ,K viwf!:<C-U>execute "Rg " . GetVisual()<CR>
|
||||
nnoremap ,K viwf!:<C-U>execute "Ag " . GetVisual()<CR>
|
||||
|
||||
"grep for 'def foo'
|
||||
nnoremap <silent> ,gd :Rg 'def <cword>'<CR>
|
||||
nnoremap <silent> ,gd :Ag 'def <cword>'<CR>
|
||||
|
||||
",gg = Grep! - using Rg RipGrep"
|
||||
",gg = Grep! - using Ag the silver searcher
|
||||
" open up a grep line, with a quote started for the search
|
||||
nnoremap ,gg :Rg ""<left>
|
||||
nnoremap ,gg :Ag ""<left>
|
||||
|
||||
"Grep for usages of the current file
|
||||
nnoremap ,gcf :exec "Rg " . expand("%:t:r")<CR>
|
||||
nnoremap ,gcf :exec "Ag " . expand("%:t:r")<CR>
|
||||
|
Loading…
Reference in New Issue
Block a user