I want vim to automatically run a syntax check whenever I save a Puppet manifest. The command for validating a manifest is
puppet parser validate FILE
and I can run the command on the file in the current buffer by setting makeprg
for Puppet manifests and then running the configured make command:
autocmd FileType puppet set makeprg=puppet\ parser\ validate\ %
autocmd BufWritePost *.pp :silent make | redraw!
However, I only see the validation output when I tell vim to always display the quickfix window:
autocmd QuickFixCmdPost [^l]* nested copen
What I would like is to have the quickfix window displayed only if there are errors (and automatically closed if there are none):
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
But with the latter settings, the quickfix window is never shown, even if the parser detects errors (verified by manually running the command).