ag.vim
ag.vim copied to clipboard
search highlighting not working when specifying paths
When I set g:aghighlight to enable search lighting, it works only if I don't specify a path to search. However, I like to include a path to significantly speed up my search.
e.g.
Ag searchthis
will highlight search results
`Ag seachthis here/' will not
Furthermore, when it does work, it turns search highlighting on for all future searches in all buffers (not Ag search, but in buffer /
searching). It would be nice if it were restricted to the quickfix search window.
Any way to do this? Thanks!
Hmm. The fact that it doesn't highlight terms when you specify a path is a bug, so that'll need to be fixed.. but the docs aren't clear on where the terms should be highlighted (just in the quickfix window? or in all other buffers?
The reason new searches are highlighted is because internally this plugin uses hlsearch to highlight the matches, and doesn't try to toggle that option (probably with :nohlsearch) when you've left buffers opened from the quickfix window.
I think either restricting highlighting to the quickfix window (either by using autocmds or if hlsearch supports being set just for that window) or leaving it how it is is acceptable.
The bug is these lines: if exists("g:ag_highlight") let @/=a:args
the "a:args" is "searchthis here/" and should only be "searchthis". I don't know enough about vimscript to fix this though.
I'm not sure if we can reliably fix this very easily. Not only might you specify one or more paths when searching, but you might specify options. For example:
-
:Ag --literal searchterm dir/ dir2/