Previously, I played with a way of piping output from SBT into a file that would be truncated on each compile session: https://gist.github.com/nkpart/5923908 . After that, I used cfile to load up the errors in that file.
However, as is so often the case, it turns out most of the plumbing is already there in SBT and VIM and a great solution is trivial.
When SBT runs, it logs each tasks' output into target/streams/<task>
. We can use the output stream from compile as the input to cfile
, without any of that haskell scripting nonsense!
:cfile ./target/streams/compile/compile/\$global/out
The only other part you need is a nice errorformat
value. This setting tells vim how to pull errors out of the parameter to cfile
. The one from Derek Wyatt's vim-scala project works:
set efm=%E\ %#[error]\ %f:%l:\ %m,%C\ %#[error]\ %p^,%-C%.%#,%Z,
\%W\ %#[warn]\ %f:%l:\ %m,%C\ %#[warn]\ %p^,%-C%.%#,%Z,
\%-G%.%#
The only downside with this method is that the SBT log file contains ANSI color codes. To turn them off, invoke SBT without colors:
$ sbt -Dsbt.log.noformat=true
Boom!
target/streams/compile/compileIncremental/$global/streams/out