Replace GitGrep with Ag

This commit is contained in:
Yan Pritzker
2014-02-15 21:08:32 -06:00
parent 5d72a8c5a4
commit 399d1d290a
8 changed files with 70 additions and 49 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,24 +0,0 @@
"git grep the current word using K (mnemonic Kurrent)
nnoremap <silent> K :GitGrep <cword><CR>
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 :<C-U>execute GitGrep(GetVisual())<CR>
"git grep current word up to the next exclamation point using ,K
nnoremap ,K viwf!:<C-U>execute GitGrep(GetVisual())<CR>
"grep for 'def foo'
nnoremap <silent> ,gd :GitGrep 'def <cword>'<CR>

View File

@@ -4,6 +4,3 @@ nnoremap <silent> <leader>q/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
" Ag for the last search.
nnoremap <silent> <leader>qa/ :execute "Ag! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'"<CR>
" GitGrep the last search (my own invention)
nnoremap <silent> <leader>qg/ :execute "GitGrep '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'"<CR>

43
vim/settings/search.vim Normal file
View File

@@ -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 <silent> K :Ag <cword><CR>
"git grep visual selection
vnoremap K :<C-U>execute Ag(GetVisual())<CR>
"git grep current word up to the next exclamation point using ,K
nnoremap ,K viwf!:<C-U>execute Ag(GetVisual())<CR>
"grep for 'def foo'
nnoremap <silent> ,gd :Ag 'def <cword>'<CR>
",gg = Grep! - using Ag the silver searcher
" open up a grep line, with a quote started for the search
nnoremap ,gg :Ag ""<left>
"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<CR>
"Grep for usages of the current file
nnoremap ,gcf :exec "Ag " . expand("%:t:r")<CR>

View File

@@ -105,7 +105,7 @@ nmap <D-N> :NERDTreeToggle<CR>
" Open the project tree and expose current file in the nerdtree with Ctrl-\
nnoremap <silent> <C-\> :NERDTreeFind<CR>:vertical res 30<CR>
" ,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 <silent> ,qc :cclose<CR>
nmap <silent> ,qo :copen<CR>
@@ -126,13 +126,6 @@ autocmd FileType javascript map <buffer> <D-j> {
map <D-/> :TComment<CR>
imap <D-/> <Esc>:TComment<CR>i
"GitGrep - open up a git grep line, with a quote started for the search
nnoremap ,gg :GitGrep ""<left>
"GitGrep Current Partial
nnoremap ,gcp :GitGrepCurrentPartial<CR>
"GitGrep Current File
nnoremap ,gcf :call GitGrep(expand("%:t:r"))<CR>
"Move back and forth through previous and next buffers
"with ,z and ,x

View File

@@ -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"