Skip to content

Commit 0db29b2

Browse files
committed
Add ripgrep support with ag fallback
Before, we relied on [`ag`][] for searching, but the maintainer last updated it five years ago. We want to ensure that folks maintain our tools, and we use the fastest tools available. We added [`ripgrep`][] as an alternative to `ag` but ensured backwards compatibility. [`ag`]: https://github.com/ggreer/the_silver_searcher [`ripgrep`]: https://github.com/BurntSushi/ripgrep
1 parent 084cf34 commit 0db29b2

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

bin/bundler-search

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
# 2. Which gem names to search (defaults to all gems)
1313

1414
pattern="$1"; shift
15-
ag "$pattern" $(bundle show --paths "$@")
15+
if command -v rg &>/dev/null; then
16+
rg "$pattern" $(bundle show --paths "$@")
17+
else
18+
ag "$pattern" $(bundle show --paths "$@")
19+
fi

vimrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,17 @@ set list listchars=tab:»·,trail:·,nbsp:·
9191
" Use one space, not two, after punctuation.
9292
set nojoinspaces
9393

94+
" Use ripgrep https://github.com/BurntSushi/ripgrep
95+
if executable('rg')
96+
" Use Rg over Grep
97+
set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case
98+
99+
" Use rg in fzf for listing files. Lightning fast and respects .gitignore
100+
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
101+
102+
nnoremap \ :Rg<SPACE>
94103
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
95-
if executable('ag')
104+
elseif executable('ag')
96105
" Use Ag over Grep
97106
set grepprg=ag\ --nogroup\ --nocolor
98107

0 commit comments

Comments
 (0)