Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from the silver searcher to ripgrep #738

Merged
merged 4 commits into from
May 30, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Read on to learn what YADR provides!

Homebrew is _the missing package manager for OSX_. Installed automatically.

We automatically install a few useful packages including ctags, git, macvim, hub, and the silver searcher ('ag')
We automatically install a few useful packages including ctags, git, macvim, hub, and RipGrep ('rg')
Note that our autocomplete plugin requires a MacVim that supports Lua. The installer knows how to install it, but if you had one installed before, you may need to manually remove your old MacVim.

### ZSH
Expand Down Expand Up @@ -190,7 +190,7 @@ of plugins above to learn more.
* `,K` - Grep the current word up to next exclamation point (useful for ruby foo! methods)
* `Cmd-*` - highlight all occurrences of current word (similar to regular `*` except doesn't move)
* `,hl` - toggle search highlight on and off
* `,gg` or `,ag` - Grep command line, type between quotes. Uses Ag Silver Searcher.
* `,gg` or `,rg` - Grep command line, type between quotes. Uses RipGrep.
* After searching with `,gg` you can navigate the results with `Ctrl-x` and `Ctrl-z` (or standard vim `:cn` and `:cp`)
* `,gd` - Grep def (greps for 'def [function name]') when cursor is over the function name
* `,gcf` - Grep Current File to find references to the current file
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def install_homebrew
puts "======================================================"
puts "Installing Homebrew packages...There may be some warnings."
puts "======================================================"
run %{brew install zsh ctags git hub tmux reattach-to-user-namespace the_silver_searcher ghi hub}
run %{brew install zsh ctags git hub tmux reattach-to-user-namespace ripgrep ghi hub}
run %{brew install macvim --custom-icons --with-override-system-vim --with-lua --with-luajit}
puts
puts
Expand Down
2 changes: 1 addition & 1 deletion doc/vim/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
* color_highlight - use :ColorCodes to see hex colors highlighted
* change-inside-surroundings - change content inside delimiters like quotes/brackets
* rspec.vim - used for color highlighting rspec correctly even if specs live outside of spec/ (rails.vim doesn't handle this)
* Ag - use :Ag to search across multiple files. Faster than Grep and Ack.
* Rg - use :Rg to search across multiple files. Faster than Ag, Grep and Ack.
* vim-session: use `:SaveSession` and `:OpenSession` to come back to your saved window layout
10 changes: 5 additions & 5 deletions vim/settings/ctrlp.vim
Original file line number Diff line number Diff line change
@@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would do a fallback to ag here

" Fall back to using git ls-files if Ag is not available
Expand Down
5 changes: 3 additions & 2 deletions vim/settings/grep.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"Use the silver searcher for lightning fast Gsearch command
set grepprg=git\ grep
"Use RipGrep for lightning fast Gsearch command
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
let g:grep_cmd_opts = '--line-number'
3 changes: 3 additions & 0 deletions vim/settings/ripgrep.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
" Open the Rg command and place the cursor into the quotes
nmap ,rg :Rg ""<Left>
nmap ,rf :Rg --files ""<Left>
14 changes: 7 additions & 7 deletions vim/settings/search.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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>
2 changes: 1 addition & 1 deletion vim/vundles/search.vundle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Bundle "justinmk/vim-sneak"
Bundle "rking/ag.vim"
Bundle "jremmen/vim-ripgrep"
Bundle "henrik/vim-indexed-search"
Bundle "nelstrom/vim-visual-star-search"
Bundle "skwp/greplace.vim"
Expand Down