ag.vim
ag.vim copied to clipboard
Check the exit status of `ag` commands
This could be used for displaying an error message when:
- stuff isn't found
- the
agcommand didn't work (if it's not installed org:agprgis wrong)
And probably other things?
Also don't open the error/location list when there aren't any matches because of an error (any nonzero exit status?)
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.