stefandtw/quickfix-reflector.vim

BufReadPost autocommand not triggered after grep

Closed this issue · 8 comments

After :grep ... the quickfix window opens up and displays the results by the autocmd

  autocmd QuickFixCmdPost grep cwindow

However, the BufReadPost autocmd of quickfix-reflector is not
triggered. Only after closing and reopening the quickfix window.

How about triggering the BufReadPost autocmd directly after the
quickfix windows opens for the first time?

Try

  autocmd QuickFixCmdPost grep nested cwindow

See :h autocmd-nested

Thank you, that's nailed it. Has been bugging me for ages.

I have the same issue when I'm using Ack to search across files. I need to close the quickfix window and open again using cwindow for the plugin to work.

I'm executing Ack like following -

nnoremap <Leader>vv :silent Ack! -k <cword> .<CR>

Does it work without silent ?

You need to know what Ack does. Is it coming from a plugin? If so, which one?

I could reproduce the problem using the option in your vimrc
let g:ack_use_dispatch=2

So this executes ack in the background somehow. But I don't know how it actually fills the quickfix list. I'm guessing it either calls setqflist() directly or uses autocmds internally without nesting. Either of those would make it impossible for quickfix-reflector to notice a change in the quickfix list. Nothing I can do really.

The easy way to make it work is not to use the dispatch mechanism. Another option might be to find a way how you can call copen automatically after the quickfix list has been filled. This would guarantee quickfix-reflector to trigger.

Regarding the latter option, wouldn't autocmd QuickFixCmdPost * nested cwindow achieve that?

That's definitely worth a try! Maybe use copen instead of cwindow to make sure it's opened again, since the ack plugin already seems to open the quickfix window before.

autocmd QuickFixCmdPost * nested copen

works well. Removing silent didn't help.