1

How do I attach a callback to :NeomakeProject so that :cwindow is executed after compilation finishes?

i.e. I'm too lazy and want everything (open the error list) to happen automatically. (currently I'm opening :cwindow with a shortcut)

/callback in :help neomake shows that neomake#Make() accepts a callback as third argument but this doesn't seem to be connected to my problem as it's a function, called internally by :Neomake

Googling for "neovim job control" shows that callbacks are set as argument to the jobstart function. A search for jobstart in the neomake repository shows that neomake sets neomake#MakeHandler as a callback. And the fact that this function is 98 lines long stopped my further research.

4

Neomake runs a user autocmd called NeomakeFinished when it's done. It sets the context variable: g:neomake_hook_context.file_mode. If it's 1 it's using the location list.

If you only want it to run when it's finished with a project:

autocmd User NeomakeFinished if !g:neomake_hook_context.file_mode | cwindow | endif

There is also an option:

*g:neomake_open_list*

This setting will open the |loclist| or |quickfix| list (depending on whether it is operating on a file) when adding entries. A value of 2 will preserve the cursor position when the |loclist| or |quickfix| window is opened. Defaults to 0.

|improve this answer|||||
  • It worked with g:neomake_open_list. Thanks! – Al.G. Jul 10 '16 at 16:07
4

I don't know first hand if it works with your fork but the following snippets works perfectly in real Vim:

augroup qf
    autocmd!

    " automatically open the location/quickfix window after :make, :grep,
    " :lvimgrep and friends if there are valid locations/errors
    autocmd QuickFixCmdPost [^l]* cwindow
    autocmd QuickFixCmdPost l*    lwindow
augroup END
|improve this answer|||||
  • Yes, it works for :make but not for :Neomake. Thank you anyway :) – Al.G. Jul 10 '16 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.