Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexarchambault/822a8e04026fafde5d8d3b849c30fbcb to your computer and use it in GitHub Desktop.
Save alexarchambault/822a8e04026fafde5d8d3b849c30fbcb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
curl -L -o coursier https://github.com/alexarchambault/coursier/raw/v1.0.0-M15-1/coursier
chmod +x coursier
./coursier bootstrap com.geirsson:scalafmt-cli_2.11:0.6.2 --main org.scalafmt.cli.Cli -o scalafmt
cat > Foo.scala << EOF
import scala.annotation.tailrec
object Foo {
def sum(from: Int, until: Int) = {
@tailrec
def helper(from: Int, acc: Int): Int =
if (from >= until)
acc
else
helper(from + 1, acc + from)
helper(from, until, 0)
}
}
EOF
cat > .scalafmt.conf << EOF
newlines.alwaysBeforeTopLevelStatements = true
EOF
# Adds a new line between @tailrec and def helper(...)
./scalafmt -i -f .
# Typically getting
# .../Foo.scala:9: expected start of definition
# def helper(from: Int, acc: Int): Int =
# ^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment