rking / ag.vim

Vim plugin for the_silver_searcher, 'ag', a replacement for the Perl module / CLI script 'ack'
1.74k stars 131 forks source link

how use ‘git grep’ in ag.vim? #116

Open kdurant opened 9 years ago

kdurant commented 9 years ago

let g:ag_prg="git grep -n", it works, but can't use command to open file

I want use jump command to open file

losingkeys commented 9 years ago

This plugin overrides vim's builtin 'errorformat' option temporarily so vim parses ag's output correctly. You can adjust what ag.vim uses with the g:ag_format option.

Vim's default value should work fine (see it with set errorformat?, vim 7.4.889's value for this option is below):

set errorformat=%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared ide
ntifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn
file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\,,%-GIn file incl
uded from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]
from %f:%l:,%-G%*[ ]from %f:%l\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:
%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory %*[`']%f',%X%*
\a[%*\d]: Leaving directory %*[`']%f',%D%*\a: Entering directory %*[`']%f',%X%*\
a: Leaving directory %*[`']%f',%DMaking %*\a in %f,%f|%l| %m

Leaving this issue open. We could parse the value of g:ag_prg and try to choose from a list of known errorformats based on its value (e.g. for grep, ack, find, whatever).

kdurant commented 9 years ago

vim 7.4 1-460patch

 errorformat=%f(%l) : %t%*\D%n: %m,%*[^"]"%f"%*\D%l: %m,%f(%l) : %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m