I have a BufWritePost autocmd that I want to run every time when a buffer is written but not when Vim is about to exit.The variable v:dying does not really help as it only indicates if Vim exists due to a signal but I also want to detect normal shutdown. So I am looking for some thing along the lines of au BufWritePost * if ! s:do_we_quit() | Neomake | endifbut as of now I have no idea how to write the s:do_we_quit() test.Context:The autocmd just calls :Neomake to run syntax checks and linters on my files and load them into the quickfix/location list. But that does obviously only make sense on :w and not on :wq. Normally Neomake works asynchronously but on exit it seems to me that vim hangs and waits for Neomake and then somehow it ends up in an infinite loop.
Detect if Vim will exit from inside an autocmd
vim
You're looking for QuitPre:let s:quitting = 0autocmd QuitPre      * let s:quitting = 1autocmd BufWritePost * if ! s:quitting | Neomake endifThis assumes you're running a decently recent Vim (QuitPre was added in Vim 7.3.544).You should probably post a bug report about the infinite loop.