Skip to content

Commit 99de4ee

Browse files
committed
Setup for scalafmt
1 parent 80eafa9 commit 99de4ee

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ target/
77
/linker-interface/**/scalajs-logging-src-jars/
88
/node_modules/
99

10+
# scalafmt generated
11+
scripts/.coursier
12+
scripts/.scalafmt*
13+
1014
# IDE specific
1115
.cache
1216
.classpath

.scalafmt.conf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Overall we are trying to use default settings to the
2+
# maximum extent possible. Removing non-default
3+
# settings is preferred over adding especially as
4+
# the Scala language evolves and styles change.
5+
# Test upgrades: $ scripts/scalafmt --test 2> diff.txt
6+
version = 3.8.0
7+
docstrings.style = AsteriskSpace
8+
project.git = true
9+
project.excludePaths = [
10+
"glob:**/scalalib/**",
11+
"glob:**/project/**",
12+
"glob:**/test-suite/js/src/test/resources/SourceMapTestTemplate.scala"
13+
]
14+
15+
# Default runner.dialect is deprecated, so set explicitly
16+
runner.dialect = scala213source3
17+
18+
# new additions
19+
fileOverride {
20+
"glob:**/scala3/**" {
21+
runner.dialect = scala3
22+
}
23+
}
24+
25+
optIn.breakChainOnFirstMethodDot = false
26+
27+
# Preserve some overflow
28+
newlines.avoidForSimpleOverflow = [tooLong, punct, slc]
29+
30+
indent.callSite = 4
31+
indentOperator.exemptScope = aloneArgOrBody
32+
indentOperator.include = ".*"
33+
indentOperator.exclude = "^(?:&&|\\|\\||\\+)$"
34+
35+
newlines.source = keep
36+
37+
binPack.preset = true
38+
binPack.parentConstructors = keep
39+
binPack.unsafeCallSite = oneline
40+
binPack.literalsExclude = []
41+
binPack.literalsIncludeSimpleExpr = true
42+
43+
# Keep control sites more streamlined
44+
indent.ctrlSite = 4
45+
danglingParentheses.ctrlSite = false
46+
47+
rewriteTokens = {
48+
"⇒": "=>"
49+
"→": "->"
50+
"←": "<-"
51+
}
52+

scripts/scalafmt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
HERE="`dirname $0`"
6+
VERSION=$(sed -nre "s#\s*version[^0-9]+([0-9.]+)#\1#p" $HERE/../.scalafmt.conf)
7+
COURSIER="$HERE/.coursier"
8+
SCALAFMT="$HERE/.scalafmt-$VERSION"
9+
10+
if [ ! -f $COURSIER ]; then
11+
curl -L -o $COURSIER https://git.io/coursier-cli
12+
chmod +x $COURSIER
13+
fi
14+
15+
if [ ! -f $SCALAFMT ]; then
16+
$COURSIER bootstrap org.scalameta:scalafmt-cli_2.13:$VERSION -r sonatype:snapshots --main org.scalafmt.cli.Cli -o $SCALAFMT
17+
chmod +x $SCALAFMT
18+
fi
19+
20+
$SCALAFMT "$@"

0 commit comments

Comments
 (0)