scalafmt: How to disable indentation for trailing single-line comments

237 Views Asked by At

I am doing migration scalafmt "2.0.1" => "3.6.1". It is a huge legacy repo and I'd like to keep code changes caused by new formatting rules to the minimum.

I have one case, which I cannot find a configuration setting as a counter-measure. Trailing single-line comments got indented as well, which undesirable.

-val v1: String = "text1" // comment1
-val v2: String = "text2_longer" // comment2
+val v1: String = "text1"         // comment1 <-- indented
+val v2: String = "text2_longer"  // comment2 <-- indented

I have setting align.preset = more

I have found following https://scalameta.org/scalafmt/docs/configuration.html#aligntokens , which says The special code // is used for single-line comments.

So I added

align.tokens.add = [
  { code = "//", owner = ".*" }
]

and it doesn't seem to work.

0

There are 0 best solutions below