Skip to content

Instantly share code, notes, and snippets.

@klaeufer
Last active February 2, 2017 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klaeufer/8981fcdebc8573b06f3d611d049839d3 to your computer and use it in GitHub Desktop.
Save klaeufer/8981fcdebc8573b06f3d611d049839d3 to your computer and use it in GitHub Desktop.
sbt-scalariform local configuration files

Instructions

  • local.sbt goes in the project root
  • project-local.sbt goes in project/local.sbt
  • also add local.sbt to .gitignore

Purpose

Install sbt-scalariform in such a way that formatting taking place only on demand. This does not seem to work with a global plugin installation.

import scalariform.formatter.preferences._
import com.typesafe.sbt.SbtScalariform
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(CompactControlReadability, true)
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(PreserveDanglingCloseParenthesis, true)
.setPreference(PreserveSpaceBeforeArguments, true)
SbtScalariform.defaultScalariformSettings
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment