From a0bfa3f963d5468311212a687c7f7c968a138458 Mon Sep 17 00:00:00 2001 From: hophacker Date: Wed, 10 Apr 2019 17:53:39 +0800 Subject: [PATCH] Migrate from the silver searcher to ripgrep --- README.md | 4 ++-- Rakefile | 2 +- doc/vim/utils.md | 26 +++++++++++++------------- vim/settings/ag.vim | 3 --- vim/settings/ctrlp.vim | 8 ++++---- vim/settings/ripgrep.vim | 3 +++ vim/settings/search.vim | 14 +++++++------- vim/vundles/search.vundle | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 vim/settings/ag.vim create mode 100644 vim/settings/ripgrep.vim diff --git a/README.md b/README.md index 85451b2..123dba2 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ rake update Homebrew是_缺失了的OSX包管理系统_,它会被自动安装。 -我们自动安装了一些常用的包,例如ctags, git, macvim, hub, 以及silver searcher ('ag')。 +我们自动安装了一些常用的包,例如ctags, git, macvim, hub, 以及RipGrep ('rg')。 注意我们的自动补全插件需要MacVim支持Lua。安装器知道如何安装,但如果你以前安装过,你需要手动删除你以前的MacVim。 ### ZSH @@ -194,7 +194,7 @@ YADR会接管你的`~/.gitconfig`, 所以如果你想存储你的git用户名及 * `,K` - Grep当前单词一直到下一个感叹号(在ruby foo!方法中很有用) * `Cmd-*` - 将所有当前单词出现的地方高亮(与正常的`*`一样,除了不移动) * `,hl` - 切换搜索高亮 - * `,gg` 或 `,ag` - 在命令行中grep,在双引号之间输入。 使用 Ag(Silver Searcher)。 + * `,gg` 或 `,ag` - 在命令行中grep,在双引号之间输入。 使用RipGrep。 * 在使用`,gg`搜索过,你可以用`Ctrl-x` 和 `Ctrl-z`来浏览 (或者标准vim命令 `:cn` 和 `:cp`) * `,gd` - 当光标在函数名字上的时候,Grep定义 (检索'def [function name]') * `,gcf` - 在当前文件搜索对当前文件的索引 diff --git a/Rakefile b/Rakefile index 11b66c3..199959c 100644 --- a/Rakefile +++ b/Rakefile @@ -200,7 +200,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 diff --git a/doc/vim/utils.md b/doc/vim/utils.md index 078a96b..9545a8c 100644 --- a/doc/vim/utils.md +++ b/doc/vim/utils.md @@ -1,14 +1,14 @@ * SplitJoin - easily split up things like ruby hashes into multiple lines or join them back together. Try :SplitjoinJoin and :SplitjoinSplit or use the bindings sj(split) and sk(unsplit) - mnemonically j and k are directions down and up -* tabularize - align code effortlessly by using :Tabularize /[character] to align by a character, or try the keymaps -* yankring - effortless sanity for pasting. every time you yank something it goes into a buffer. after hitting p to paste, use ctrl-p or ctrl-n to cycle through the paste options. great for when you accidentally overwrite your yank with a delete. -* surround - super easy quote and tag manipulation - ysiw" - sourround inner word with quotes. ci"' - change inner double quotes to single quotes, etc -* greplace - use :Gsearch to find across many files, replace inside the changes, then :Greplace to do a replace across all matches - made lightning fast with Silver Searcher -* vim-markdown-preview - :Mm to view your README.md as html -* html-escape - ,he and ,hu to escape and unescape html -* Gundo - visualize your undos - pretty amazing plugin. Hit ,u with my keymappings to trigger it, very user friendly -* vim-indent-guides - visual indent guides, off by default -* 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. -* vim-session: use `:SaveSession` and `:OpenSession` to come back to your saved window layout +* * tabularize - align code effortlessly by using :Tabularize /[character] to align by a character, or try the keymaps +* * yankring - effortless sanity for pasting. every time you yank something it goes into a buffer. after hitting p to paste, use ctrl-p or ctrl-n to cycle through the paste options. great for when you accidentally overwrite your yank with a delete. +* * surround - super easy quote and tag manipulation - ysiw" - sourround inner word with quotes. ci"' - change inner double quotes to single quotes, etc +* * greplace - use :Gsearch to find across many files, replace inside the changes, then :Greplace to do a replace across all matches - made lightning fast with Silver Searcher +* * vim-markdown-preview - :Mm to view your README.md as html +* * html-escape - ,he and ,hu to escape and unescape html +* * Gundo - visualize your undos - pretty amazing plugin. Hit ,u with my keymappings to trigger it, very user friendly +* * vim-indent-guides - visual indent guides, off by default +* * 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) +* * 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' diff --git a/vim/settings/ag.vim b/vim/settings/ag.vim deleted file mode 100644 index a6dcd27..0000000 --- a/vim/settings/ag.vim +++ /dev/null @@ -1,3 +0,0 @@ -" Open the Ag command and place the cursor into the quotes -nmap ,ag :Ag "" -nmap ,af :AgFile "" diff --git a/vim/settings/ctrlp.vim b/vim/settings/ctrlp.vim index 63cd721..0f81282 100644 --- a/vim/settings/ctrlp.vim +++ b/vim/settings/ctrlp.vim @@ -1,11 +1,11 @@ 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$"' +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' - " ag is fast enough that CtrlP doesn't need to cache + " 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 diff --git a/vim/settings/ripgrep.vim b/vim/settings/ripgrep.vim new file mode 100644 index 0000000..ccece01 --- /dev/null +++ b/vim/settings/ripgrep.vim @@ -0,0 +1,3 @@ +" Open the Rg command and place the cursor into the quotes +nmap ,rg :Rg "" +nmap ,rf :Rg --files "" diff --git a/vim/settings/search.vim b/vim/settings/search.vim index 82cf075..49c4612 100644 --- a/vim/settings/search.vim +++ b/vim/settings/search.vim @@ -11,20 +11,20 @@ function! GetVisual() endfunction "grep the current word using ,k (mnemonic Kurrent) -nnoremap ,k :Ag +nnoremap ,k :Rg "grep visual selection -vnoremap ,k :execute "Ag " . GetVisual() +vnoremap ,k :execute "Rg " . GetVisual() "grep current word up to the next exclamation point using ,K -nnoremap ,K viwf!:execute "Ag " . GetVisual() +nnoremap ,K viwf!:execute "Rg " . GetVisual() "grep for 'def foo' -nnoremap ,gd :Ag 'def ' +nnoremap ,gd :Rg 'def ' -",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 "" +nnoremap ,gg :Rg "" "Grep for usages of the current file -nnoremap ,gcf :exec "Ag " . expand("%:t:r") +nnoremap ,gcf :exec "Rg " . expand("%:t:r") diff --git a/vim/vundles/search.vundle b/vim/vundles/search.vundle index 4e13314..e761d66 100644 --- a/vim/vundles/search.vundle +++ b/vim/vundles/search.vundle @@ -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 "dkprice/vim-easygrep"