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

Check the exit status of `ag` commands #32

Open losingkeys opened 10 years ago

losingkeys commented 10 years ago

This could be used for displaying an error message when:

And probably other things?

losingkeys commented 10 years ago

Also don't open the error/location list when there aren't any matches because of an error (any nonzero exit status?)

losingkeys commented 10 years ago

It seems like checking v:shell_error would work, but that doesn't seem to be set for :grep. The error message could be parsed, but sometimes (imo) it's confusing. For instance, if you do ag --max-count=garbage test it'll still search for test, but in addition to results it'll display something like:

ERR: Too many matches in ./autoload/ag.vim. Skipping the rest of this file.
ERR: Too many matches in ./doc/ag.txt. Skipping the rest of this file.

At the top of the matches.

Also, ag ----- (invalid option) gives:

ag: unrecognized option `-----'

Usage: ag [FILE-TYPE] [OPTIONS] PATTERN [PATH]

  Recursively search for PATTERN in PATH.
  Like grep or ack, but faster.
...

ag vim dsfajlkfdjsasdj/2/ (invalid path) gives:

ERR: Error stat()ing: dsfajlkfdjsasdj/2
ERR: Error opening directory dsfajlkfdjsasdj/2: No such file or directory

So ERR doesn't always show up, and sometimes you still get results when it does (so it might not be worth it to hide the quickfix window and show the message in those cases.