From 399d1d290a72bb9d621fa2fcaa7068406762f665 Mon Sep 17 00:00:00 2001 From: Yan Pritzker Date: Sat, 15 Feb 2014 21:08:32 -0600 Subject: [PATCH] Replace GitGrep with Ag --- CHANGELOG.md | 20 ++++++++++++--- README.md | 16 ++++++------ doc/vim/navigation.md | 2 +- vim/settings/git-grep.vim | 24 ------------------ vim/settings/quickfix-search.vim | 3 --- vim/settings/search.vim | 43 ++++++++++++++++++++++++++++++++ vim/settings/yadr-keymap.vim | 9 +------ vim/vundles.vim | 2 -- 8 files changed, 70 insertions(+), 49 deletions(-) delete mode 100644 vim/settings/git-grep.vim create mode 100644 vim/settings/search.vim diff --git a/CHANGELOG.md b/CHANGELOG.md index 052a04ee..a6e1e5ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,29 @@ -### Jan 5, 2013 + +2014-02-15 +================== + + * Replace Git Grep with Ag and remove unused plugins + * Sneak: hit Space and type two letters to quickly jump somewhere + * Added Ctrl-R, reverse history search for :commands + * Remove ;; semicolon mapping. Messes with regular semicolon usage (find next char) + * Change to Lightline instead of Airline [Fix #418] + +Jan 5, 2013 +================== + * Switch to lightline instead of airline for status bar. Works better in terminal vim and should be faster. * Added investigate.vim (gK for docs) * Fix homebrew installation of macvim with lua enabled, and fix deprecated homebrew install. -### Dec 17, 2013 +Dec 17, 2013 +================== * Cleanup of README to make it more palatable, focusing on the primary key bindings * Improved integration with Ag, giving ,ag and ,af aliases * Got rid of conque term, implemented a "send to iTerm" rspec runner (invoke with ,rs ,rl ,ss ,sl) for the rspec and spring/rspec versions. -### March 29, 2013 +March 29, 2013 +================== * Migrated to Vundle instead of pathogen for easier bundle management * Added Silver Searcher for lightning fast :Gsearch diff --git a/README.md b/README.md index c207c1a6..4fc74004 100644 --- a/README.md +++ b/README.md @@ -172,15 +172,15 @@ of plugins above to learn more. * `,F` - same as `,f` but in a vertical split * `,gf` or `Ctrl-f` - same as vim normal gf (go to file), but in a vertical split (works with file.rb:123 line numbers also) * `gF` - standard vim mapping, here for completeness (go to file at line number) - * `K` - GitGrep the current word under the cursor and show results in quickfix window - * `,K` - GitGrep the current word up to next exclamation point (useful for ruby foo! methods) + * `K` - Search the current word under the cursor and show results in quickfix window + * `,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` - GitGrep command line, type between quotes - * `,gd` - GitGrep def (greps for 'def [function name]') when cursor is over the function name - * `,gcp` - GitGrep Current Partial to find references to the current view partial - * `,gcf` - GitGrep Current File to find references to the current file - * `,ag` - Ag - silver searcher. Alternative to GitGrep that is as fast or faster. + * `,gg` - Grep command line, type between quotes + * `,gd` - Grep def (greps for 'def [function name]') when cursor is over the function name + * `,gcp` - Grep Current Partial to find references to the current view partial + * `,gcf` - Grep Current File to find references to the current file + * `,ag` - Ag - silver searcher. Alternative to Grep that is as fast or faster. * `,af` - AgFile - silver searcher for a filename * `//` - clear the search * `,T` - Tag list (list of methods in a class) @@ -229,7 +229,7 @@ of plugins above to learn more. * `Q` - Intelligent Window Killer. Close window `wincmd c` if there are multiple windows to same buffer, or kill the buffer `bwipeout` if this is the last window into it. * `vv` - vertical split (`Ctrl-w,v`) * `ss` - horizontal split (`Ctrl-w,s`) - * `,qo` - open quickfix window (this is where output from GitGrep goes) + * `,qo` - open quickfix window (this is where output from Grep goes) * `,qc` - close quickfix #### Utility diff --git a/doc/vim/navigation.md b/doc/vim/navigation.md index 6d14f4c1..8476baaf 100644 --- a/doc/vim/navigation.md +++ b/doc/vim/navigation.md @@ -5,4 +5,4 @@ * TagBar - hit ,T to see a list of methods in a class (uses ctags) * CtrlP - ,t to find a file * Visual-star-search - make the * (star) search in visual mode behave like expected: searching for the whole selection instead of just the word under the cursor. -* GitGrep - much better than the grep provided with fugitive; use `:GitGrep` or hit `K` to grep current word +* Ag - super fast search by Silver Searcher. hit `K` to grep current word diff --git a/vim/settings/git-grep.vim b/vim/settings/git-grep.vim deleted file mode 100644 index 8c838cc1..00000000 --- a/vim/settings/git-grep.vim +++ /dev/null @@ -1,24 +0,0 @@ -"git grep the current word using K (mnemonic Kurrent) -nnoremap K :GitGrep - -function! GetVisual() - let reg_save = getreg('"') - let regtype_save = getregtype('"') - let cb_save = &clipboard - set clipboard& - normal! ""gvy - let selection = getreg('"') - call setreg('"', reg_save, regtype_save) - let &clipboard = cb_save - return selection -endfunction - -"git grep visual selection -vnoremap K :execute GitGrep(GetVisual()) - -"git grep current word up to the next exclamation point using ,K -nnoremap ,K viwf!:execute GitGrep(GetVisual()) - -"grep for 'def foo' -nnoremap ,gd :GitGrep 'def ' - diff --git a/vim/settings/quickfix-search.vim b/vim/settings/quickfix-search.vim index e1d8e7eb..a1d6414e 100644 --- a/vim/settings/quickfix-search.vim +++ b/vim/settings/quickfix-search.vim @@ -4,6 +4,3 @@ nnoremap q/ :execute 'vimgrep /'.@/.'/g %':copen " Ag for the last search. nnoremap qa/ :execute "Ag! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'" - -" GitGrep the last search (my own invention) -nnoremap qg/ :execute "GitGrep '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'" diff --git a/vim/settings/search.vim b/vim/settings/search.vim new file mode 100644 index 00000000..74947e51 --- /dev/null +++ b/vim/settings/search.vim @@ -0,0 +1,43 @@ +function! GetVisual() + let reg_save = getreg('"') + let regtype_save = getregtype('"') + let cb_save = &clipboard + set clipboard& + normal! ""gvy + let selection = getreg('"') + call setreg('"', reg_save, regtype_save) + let &clipboard = cb_save + return selection +endfunction + +"git grep the current word using K (mnemonic Kurrent) +nnoremap K :Ag + +"git grep visual selection +vnoremap K :execute Ag(GetVisual()) + +"git grep current word up to the next exclamation point using ,K +nnoremap ,K viwf!:execute Ag(GetVisual()) + +"grep for 'def foo' +nnoremap ,gd :Ag 'def ' + +",gg = Grep! - using Ag the silver searcher +" open up a grep line, with a quote started for the search +nnoremap ,gg :Ag "" + +"Grep Current Partial +function! AgCurrentPartial() + let l:fileNameWithoutExtension = expand('%:t:r') + let l:fileNameWithoutUnderscore = substitute(l:fileNameWithoutExtension, '^_','','g') + let l:grepPattern = "render.*[\\\'\\\"].*" . l:fileNameWithoutUnderscore . "[\\\'\\\"]$" + exec 'Ag "' . l:grepPattern . '"' +endfunction + +command! AgCurrentPartial call AgCurrentPartial() +" +nnoremap ,gcp :AgCurrentPartial + +"Grep for usages of the current file +nnoremap ,gcf :exec "Ag " . expand("%:t:r") + diff --git a/vim/settings/yadr-keymap.vim b/vim/settings/yadr-keymap.vim index d6c34045..4de67c5a 100644 --- a/vim/settings/yadr-keymap.vim +++ b/vim/settings/yadr-keymap.vim @@ -105,7 +105,7 @@ nmap :NERDTreeToggle " Open the project tree and expose current file in the nerdtree with Ctrl-\ nnoremap :NERDTreeFind:vertical res 30 -" ,q to toggle quickfix window (where you have stuff like GitGrep) +" ,q to toggle quickfix window (where you have stuff like Ag) " ,oq to open it back up (rare) nmap ,qc :cclose nmap ,qo :copen @@ -126,13 +126,6 @@ autocmd FileType javascript map { map :TComment imap :TCommenti -"GitGrep - open up a git grep line, with a quote started for the search -nnoremap ,gg :GitGrep "" -"GitGrep Current Partial -nnoremap ,gcp :GitGrepCurrentPartial -"GitGrep Current File -nnoremap ,gcf :call GitGrep(expand("%:t:r")) - "Move back and forth through previous and next buffers "with ,z and ,x diff --git a/vim/vundles.vim b/vim/vundles.vim index e1bc413f..3d2723be 100644 --- a/vim/vundles.vim +++ b/vim/vundles.vim @@ -83,8 +83,6 @@ Bundle "justinmk/vim-sneak" "Search Bundle "rking/ag.vim" -Bundle "skwp/vim-git-grep-rails-partial" -Bundle "tjennings/git-grep-vim" Bundle "vim-scripts/IndexedSearch" Bundle "nelstrom/vim-visual-star-search"