Bring some color to your Scala compiler

Only last week, Chris wrote about what's new in Scala Clippy, which included highlighting diffs in type mismatch errors.

This week (in version 0.5.0), we are introducing another color-related feature: syntax highlighting in the Scala compiler output!

Here's how it looks in practice:

Much nicer than the all-same-color default, isn't it?

But what is Clippy?

Clippy is a Scala compiler plugin which enriches compilation errors with advice. The advice database is community-maintained. Take a look at the website to find out more!

How can I use it?

The easiest way to use Clippy is through an SBT plugin. You can enable Clippy globally by first adding the following to ~/.sbt/0.13/plugins/build.sbt:

addSbtPlugin("com.softwaremill.clippy" % "plugin-sbt" % "0.5.0")

Color-related features are currently disabled by default. To enable them, edit ~/.sbt/0.13/build.sbt and add:

import com.softwaremill.clippy.ClippySbtPlugin._
clippyColorsEnabled := true

Clippy can be also used directly as a compiler plugin, and configured via compiler plugin options (without SBT). See the readme for details.

Custom colors

As for the question you are probably asking yourselves right now - yes, you can customize the colors that Clippy uses for syntax highlighting. For example, to customize the color of literals, in ~/.sbt/0.13/build.sbt add:

clippyColorLiteral := Some(ClippyColor.Magenta)


The syntax highlighting is copied from Ammonite and also uses open-source libraries by Li Haoyi - thanks for the great work!

scala times
Enjoying some Scala news?

Subscribe to our free weekly Scala Times newspaper delivered straight to you inbox.