0

I have a call that I would like to look like this:

newTimeRangeList(
  MonthRanges.Y2021.Jan, MonthRanges.Y2021.Feb, MonthRanges.Y2021.Mar, MonthRanges.Y2021.Apr,
  MonthRanges.Y2021.May, MonthRanges.Y2021.Jun, MonthRanges.Y2021.Jul, MonthRanges.Y2021.Aug,
  MonthRanges.Y2021.Sep, MonthRanges.Y2021.Oct, MonthRanges.Y2021.Nov, MonthRanges.Y2021.Dec
)

This is how I am trying to format it manually. I do not expect formatter to come up with exactly this formatting but I want it to stop moving arguments to next line if those are not exceeding the line length limit.

This is longer than a code folding threshold we try to keep (120 chars) but this is so long, that I don't want to have this with every argument on its own line. Right now this gets reformatted to

  newTimeRangeList(
    MonthRanges.Y2021.Jan,
    MonthRanges.Y2021.Feb,
    MonthRanges.Y2021.Mar,
    MonthRanges.Y2021.Apr,
    MonthRanges.Y2021.May,
    MonthRanges.Y2021.Jun,
    MonthRanges.Y2021.Jul,
    MonthRanges.Y2021.Aug,
    MonthRanges.Y2021.Sep,
    MonthRanges.Y2021.Oct,
    MonthRanges.Y2021.Nov,
    MonthRanges.Y2021.Dec
  )

My scalafmt:

version = 3.7.3
docstrings.style = Asterisk
runner.dialect = scala213source3
maxColumn = 120
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
rewrite.rules = [SortImports, RedundantBraces, RedundantParens, SortModifiers]
rewrite.redundantBraces.ifElseExpressions = false
rewrite.redundantBraces.generalExpressions = false
align = none
align.openParenDefnSite = false
align.openParenCallSite = false
align.tokens = []
optIn = {
  configStyleArguments = false
}
danglingParentheses.preset = false
danglingParentheses.callSite = true
rewrite.trailingCommas.style = keep
rewrite.trailingCommas.allowFolding = false
newlines.implicitParamListModifierForce = [after]
newlines.source=keep

Any advice on how where to look to get it working as described?

googled for a solution, experimented with various scalafmt params with no success

Wojciech
  • 1
  • 1
  • 1
    Something like https://scalameta.org/scalafmt/docs/configuration.html#-format-off ? – Mateusz Kubuszok Jun 19 '23 at 18:58
  • This would work, but it completely disables formatting in this section, doesn't it? I would still want indentations to be fixed or redundant whitespaces removed. I just don't want formatter to change line breaks... – Wojciech Jun 20 '23 at 09:07
  • Try it out first. IME it would change the indentation of this code _as a whole_ (comments including), but NOT change how its broken up internally and how you put white characters between words. – Mateusz Kubuszok Jun 20 '23 at 18:53

0 Answers0