From 8931ce9d1e199b366d020ec0b6890aa1554396b6 Mon Sep 17 00:00:00 2001 From: Rob Whittaker Date: Fri, 12 Sep 2025 15:37:41 +0100 Subject: [PATCH] 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 --- bin/bundler-search | 6 +++++- vimrc | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/bundler-search b/bin/bundler-search index 18a973f735..6f911734a7 100755 --- a/bin/bundler-search +++ b/bin/bundler-search @@ -12,4 +12,8 @@ # 2. Which gem names to search (defaults to all gems) pattern="$1"; shift -ag "$pattern" $(bundle show --paths "$@") +if command -v rg &>/dev/null; then + rg "$pattern" $(bundle show --paths "$@") +else + ag "$pattern" $(bundle show --paths "$@") +fi diff --git a/vimrc b/vimrc index 3774132a50..6001cdc117 100644 --- a/vimrc +++ b/vimrc @@ -90,8 +90,17 @@ set list listchars=tab:»·,trail:·,nbsp:· " Use one space, not two, after punctuation. set nojoinspaces +" Use ripgrep https://github.com/BurntSushi/ripgrep +if executable('rg') + " Use Rg over Grep + set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case + + " Use rg in fzf for listing files. Lightning fast and respects .gitignore + let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"' + + nnoremap \ :Rg " Use The Silver Searcher https://github.com/ggreer/the_silver_searcher -if executable('ag') +elseif executable('ag') " Use Ag over Grep set grepprg=ag\ --nogroup\ --nocolor