-
Notifications
You must be signed in to change notification settings - Fork 29
/
.scalafmt.conf
59 lines (49 loc) · 2.36 KB
/
.scalafmt.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// skip version 3.8.2 seems to make a lot of questionable formatting choices
// skip version 3.8.3, still a lot of questionable formatting
version = 3.8.4-RC3
// alignment is cute. i think it helps readability overall, but sometimes it produces silly results. consider restructuring code in those cases
align.preset = more
// 120 is chosen mostly because it seems to be a length at which the automatic wrapping very rarely bothers me.
// use manual linebreaks to emphasize the structure of your code.
maxColumn = 120
newlines.source = keep
// trailing commas are nice, because they are systematic – copy and reorder lines without worries.
// at the same time, a lot of code does not change often, so the additional commas are just noise.
// use good judgement
rewrite.trailingCommas.style = keep
// new control syntax (i.e., if ... then ... else) is just nicer
// varargs, imports, and wildcards no longer overload _ for everything
rewrite.scala3.convertToNewSyntax = true
// docstrings are the scaladoc comments (using /** */)
// single line folding reduces empty lines.
// wrapping is disabled because I do not believe in forcing word-wrap for flow text – use good judgement
docstrings.oneline = fold
docstrings.wrap = no
// one line per import just produces insanely long headers, though it is more convenient for modifications.
// unsure on what is best here, but for now, I read files more often than I have to edit their imports.
importSelectors = singleLine
// the following cause operands on separate lines to have the same indentation
// naming is based on the default being indentation, and these “enable” no indentation
// https://scalameta.org/scalafmt/docs/configuration.html#indentoperator
indentOperator.exemptScope = all
indentOperator.includeRegex = "^.*=$"
indentOperator.excludeRegex = "^$"
// scala 2, scala 3, and sbt all use slightly different variants on scala syntax
// this defaults to scala 3 syntax, but has some well-known exceptions
runner.dialect = scala3
fileOverride {
"glob:**/scala-2/**" {
runner.dialect = scala213
}
"glob:**/*.sbt" {
runner.dialect = sbt1
}
// project files are sbt projects, sbt always uses scala 2.12
"glob:**/project/*.scala" {
runner.dialect = scala212source3
}
// ensure that scala files in source are scala3 even if they are in a folder called "project"
"glob:**/src/*/scala/**/*.scala" {
runner.dialect = scala3
}
}