Skip to content

Instantly share code, notes, and snippets.

@nkpart
Last active February 12, 2018 18:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nkpart/5945278 to your computer and use it in GitHub Desktop.
Save nkpart/5945278 to your computer and use it in GitHub Desktop.
Loading errors from SBT into a Vim Quickfix

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!

@SRGOM
Copy link

SRGOM commented Aug 21, 2016

target/streams/compile/compileIncremental/$global/streams/out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment