aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/scalafmt-example/.scalafmt.conf11
-rw-r--r--examples/scalafmt-example/build/build.scala9
-rw-r--r--examples/scalafmt-example/src/Main.scala12
3 files changed, 22 insertions, 10 deletions
diff --git a/examples/scalafmt-example/.scalafmt.conf b/examples/scalafmt-example/.scalafmt.conf
new file mode 100644
index 0000000..4fc0088
--- /dev/null
+++ b/examples/scalafmt-example/.scalafmt.conf
@@ -0,0 +1,11 @@
+style: defaultWithAlign
+danglingParentheses: true
+
+spaces {
+ inImportCurlyBraces: true
+}
+
+rewriteTokens {
+ "->": "→"
+ "=>": "⇒"
+}
diff --git a/examples/scalafmt-example/build/build.scala b/examples/scalafmt-example/build/build.scala
index b8a819b..4f5545e 100644
--- a/examples/scalafmt-example/build/build.scala
+++ b/examples/scalafmt-example/build/build.scala
@@ -1,5 +1,4 @@
import cbt._
-import org.scalafmt.ScalafmtStyle
class Build(val context: Context) extends BaseBuild with Scalafmt {
override def compile = {
@@ -7,8 +6,6 @@ class Build(val context: Context) extends BaseBuild with Scalafmt {
super.compile
}
- override def scalafmtConfig: ScalafmtStyle = ScalafmtStyle.defaultWithAlign
-
def breakFormatting = {
import java.nio.file._
import java.nio.charset.Charset
@@ -17,7 +14,11 @@ class Build(val context: Context) extends BaseBuild with Scalafmt {
sourceFiles foreach { file =>
val path = file.toPath
val fileLines = Files.readAllLines(path, utf8).asScala
- val brokenLines = fileLines map (_.dropWhile(_ == ' '))
+ val brokenLines = fileLines map (l =>
+ l.dropWhile(_ == ' ')
+ .replaceAll("⇒", "=>")
+ .replaceAll("→", "->")
+ )
Files.write(path, brokenLines.asJava, utf8)
}
System.err.println("Done breaking formatting")
diff --git a/examples/scalafmt-example/src/Main.scala b/examples/scalafmt-example/src/Main.scala
index 595cede..465e27a 100644
--- a/examples/scalafmt-example/src/Main.scala
+++ b/examples/scalafmt-example/src/Main.scala
@@ -1,16 +1,16 @@
-import scala.concurrent.{Await, Future}
+import scala.concurrent.{ Await, Future }
import scala.concurrent.duration._
object Main extends App {
println("fooo")
val futureRes = Await.result(Future.successful(1), 5.seconds)
List(1, 2, 4, 5, 6) match {
- case h :: _ => println("not empty list")
- case Nil => println("empty list")
+ case h :: _ ⇒ println("not empty list")
+ case Nil ⇒ println("empty list")
}
- List(1 -> 2, 2 -> 3, 3 -> 4) match {
- case (1, 2) :: _ => 90 -> 1
- case (22, 44) :: _ => 1 -> 150
+ List(1 → 2, 2 → 3, 3 → 4) match {
+ case (1, 2) :: _ ⇒ 90 → 1
+ case (22, 44) :: _ ⇒ 1 → 150
}
}