16
16
# limitations under the License.
17
17
#
18
18
19
- # See https://scalameta.org/scalafmt/docs/configuration.html for details,
20
- # mostly done by trial and error. But I guess this formatting is "good enough"
19
+ # See https://scalameta.org/scalafmt/docs/configuration.html for details
21
20
#
21
+ # https://github.com/scalameta/scalafmt/releases
22
+ version = 3.0 .0 -RC6
22
23
23
- # https://github.com/scalameta/scalafmt/releases
24
- version = 2.7 .5
25
-
26
- project {
27
- # if you don't specify that files ending in .scala .sbt with $,
28
- # .scalafmt.conf is included in the formatting attempt
29
- includeFilters = [
30
- ".*.\\ .scala$"
31
- ".*\\ ..sbt$"
32
- ]
24
+ fileOverride {
25
+ "glob:**/src/main/scala/**" {
26
+ runner.dialect = scala213source3
27
+ }
28
+ "glob:**/src/test/scala/**" {
29
+ runner.dialect = scala213source3
30
+ }
31
+ "glob:**/src/main/scala-2/**" {
32
+ runner.dialect = scala213source3
33
+ }
34
+ "glob:**/src/test/scala-2/**" {
35
+ runner.dialect = scala213source3
36
+ }
37
+ "glob:**/src/main/scala-3/**" {
38
+ runner.dialect = scala3
39
+ }
40
+ "glob:**/src/test/scala-3/**" {
41
+ runner.dialect = scala3
42
+ }
43
+ "glob:**/project/*.scala" {
44
+ runner.dialect = scala212
45
+ }
46
+ "glob:**/*.sbt" {
47
+ runner.dialect = Sbt1
48
+ }
33
49
}
34
50
35
51
maxColumn = 120
36
52
37
- # Note. Only for the truest vertical aligners. This is a new option,
38
- # feel free to open PR enabling more crazy vertical alignment here.
39
- # Expect changes.
40
53
align = most
41
54
align.openParenCallSite = false
42
55
align.openParenDefnSite = false
43
56
align.multiline = true
57
+ align.tokens."+" = [
44
58
45
- align.tokens.add = [
46
-
47
- {code = "<-" , owner = "Enumerator.Generator" }
48
- // Everything before the Term.Assign was the default regex. To find the
49
- // default value, look through the code here:
50
- // https://github.com/scalameta/scalafmt/blob/master/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala
51
- {code = "=" , owner = "(Enumerator.Generator|Val|Defn.(Va(l|r)|Def|Type))|Term.Assign" }
59
+ {code = "<-" , owner = "Enumerator.Generator" },
52
60
53
- // used to align comments
54
- "//"
61
+ # Everything before the Term.Assign was the default regex. To find the
62
+ # default value, look through the code here:
63
+ # https://github.com/scalameta/scalafmt/blob/master/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala
64
+ {code = "=" , owner = "(Enumerator.Generator|Val|Defn.(Va(l|r)|Def|Type))|Term.Assign|Param" },
55
65
56
- // used for aligning type definition
57
- ":"
58
-
59
- // used when creating tuples
60
- {code = "->" , owner = "Term.ApplyInfix" },
66
+ "//" , # used to align comments
67
+ ":" , # used for aligning type definition
68
+ {code = "->" , owner = "Term.ApplyInfix" }, # used to align tuples 1 -> 2
61
69
62
70
// sbt specific
63
71
{code = "%" , owner = "Term.ApplyInfix" },
64
- {code = "%%" , owner = "Term.ApplyInfix" }
65
- {code = "%%%" , owner = "Term.ApplyInfix" }
66
- {code = ":=" , owner = "Term.ApplyInfix" }
67
- {code = "withSources" , owner = "Term.ApplyInfix" }
72
+ {code = "%%" , owner = "Term.ApplyInfix" },
73
+ {code = "%%%" , owner = "Term.ApplyInfix" },
74
+ {code = ":=" , owner = "Term.ApplyInfix" },
75
+ {code = "withSources" , owner = "Term.ApplyInfix" },
68
76
"extends"
69
77
]
70
78
79
+ # ##############################################################################
80
+
71
81
continuationIndent {
72
82
callSite = 2
73
83
defnSite = 2
@@ -76,12 +86,16 @@ continuationIndent {
76
86
withSiteRelativeToExtends = 0
77
87
}
78
88
89
+ # ##############################################################################
90
+
79
91
verticalMultiline.atDefnSite = false
80
92
verticalMultiline.newlineAfterOpenParen = true
81
93
verticalMultiline.arityThreshold = 3
82
94
95
+ # ##############################################################################
96
+
83
97
newlines {
84
- alwaysBeforeTopLevelStatements = true
98
+ topLevelStatements = [ before ]
85
99
sometimesBeforeColonInMethodReturnType = true
86
100
penalizeSingleSelectMultiArgList = false
87
101
alwaysBeforeElseAfterCurlyIf = true
@@ -91,30 +105,35 @@ newlines {
91
105
afterCurlyLambda = squash
92
106
}
93
107
108
+ # ##############################################################################
109
+
94
110
spaces {
95
111
afterKeywordBeforeParen = true
96
112
}
97
113
114
+ # ##############################################################################
115
+
98
116
binPack {
99
117
parentConstructors = true
100
118
literalArgumentLists = true
101
119
literalsMinArgCount = 5
102
120
}
103
121
122
+ # ##############################################################################
104
123
105
124
optIn {
106
125
breaksInsideChains = false
107
- // preserves existing newlines in . chain calls.
108
- // See: optIn.breakChainOnFirstMethodDot = true
126
+ # preserves existing newlines in . chain calls.
127
+ # See: optIn.breakChainOnFirstMethodDot = true
109
128
breakChainOnFirstMethodDot = true
110
129
blankLineBeforeDocstring = true
111
130
}
112
131
132
+ # ##############################################################################
133
+
113
134
rewrite {
114
135
rules = [
115
- SortImports
116
136
SortModifiers
117
- # if your for has more than one single <- then it gets transformed into a multit-line curly brace one
118
137
PreferCurlyFors
119
138
AvoidInfix
120
139
RedundantBraces
@@ -127,40 +146,21 @@ rewrite.redundantBraces.methodBodies = true
127
146
rewrite.redundantBraces.includeUnitMethods = false
128
147
rewrite.redundantBraces.stringInterpolation = true
129
148
rewrite.redundantBraces.parensForOneLineApply = true
149
+ rewrite.neverInfix.excludeFilters = [withSources ]
130
150
131
- # we only really want to disable infix notation
132
- # for map and flatMap and the like, because it
133
- # kills IDE performance and type inference
134
- rewrite.neverInfix.excludeFilters = [
135
- until
136
- to
137
- by
138
- eq
139
- ne
140
- "should.*"
141
- "contain.*"
142
- "must.*"
143
- in
144
- be
145
- of # behaviour of ("X")
146
- taggedAs
147
- thrownBy
148
- synchronized
149
- have
150
- when
151
- size
152
- theSameElementsAs
153
- withSources
154
- ]
151
+ # ##############################################################################
155
152
156
153
preset = default
157
154
danglingParentheses.preset = true
158
155
156
+ # ##############################################################################
157
+
159
158
assumeStandardLibraryStripMargin = true
160
159
includeNoParensInSelectChains = false
161
160
includeCurlyBraceInSelectChains = true
162
161
trailingCommas = multiple
163
162
163
+ # ##############################################################################
164
164
165
165
runner {
166
166
optimizer {
@@ -171,4 +171,4 @@ runner {
171
171
# minimum number of func arguments before config-style (look at top of file) is enabled
172
172
forceConfigStyleMinArgCount = 2
173
173
}
174
- }
174
+ }
0 commit comments