7

I have found a lot of pages with config examples such as:

let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts =
  \ '--line-numbers --nocolor --nogroup --hidden --ignore '
let g:unite_source_grep_recursive_opt = ''

or

" Use ag for searching
let g:unite_source_rec_async_command =
  \ 'ag --follow --nocolor --nogroup --hidden -g ""'
let g:ackprg = 'ag --nogroup --column'
nnoremap <space>/ :Unite grep:.<cr>

Unfortunately, I don't really understand what these are doing or why. What I've played around with it some and have gotten parts of what I want working.

Ideally, I'd just like something similar to what Ack.vim does:

  1. I hit some key mapping, let's say /
  2. I put in my search query
  3. That opens a Unite.vim buffer split at the top which asynchronously uses ack or ag to searches for my search query
  4. I can navigate through results and select one or some to open in splits
Andy Lester
  • 91,102
  • 13
  • 100
  • 152
Jeff
  • 1,051
  • 1
  • 13
  • 26

1 Answers1

1

Perhaps I'm missing the spirit of this question, but if you just need to configure Unite with ag, that's straightforward: in your .vimrc add:

let g:unite_source_grep_command="ag"
let g:unite_source_grep_default_opts="-i --nocolor --nogroup"

In vim, you would invoke a search like so:

:Unite grep:.
pattern: foobar

Note: Unite doesn't comes with pre-defined mappings, so you have to add your own. If Unite is too much functionality for your needs, consider using Ack.vim with ag (Ag.vim is no longer maintained.) Both plugins fulfill your ideal usage patten; but Unite does a whole bunch more.

gregory
  • 10,969
  • 2
  • 30
  • 42