Questions tagged [scalafmt]

Questions about Scalafmt, a Scala Formatter

Scalafmt, a Scala Formatter - https://scalameta.org/scalafmt/

35 questions
2
votes
0 answers

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

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…
Donald Duck
  • 476
  • 3
  • 12
2
votes
1 answer

Run scalafmtCheck in an sbt assembly

I would like to run a scalafmtCheck in sbt assembly. I tried to add: (compile in Compile) := ((compile in Compile) dependsOn scalafmtCheck).value I got that error : [error] References to undefined settings: [error] [error] submissions /…
Yassine
  • 123
  • 3
2
votes
0 answers

Scalafmt config for breaking line on ~> operator

I want add an option to my .scalafmt.conf that would break lines exceeding maxColumn length on operator ~> (edge operator from akka-streams). Does anyone know if this is even an option and if yes, how to achieve it? Thanks!
2
votes
1 answer

How to change tab width in scalafmt

I'm using VS code with metal scala extension and cannot get my code to format properly. I want to have 8 spaces tab width for everything. This is my .scalafmt.conf version = "2.0.0-RC4" maxColumn = 80 continuationIndent.callSite =…
aganm
  • 1,245
  • 1
  • 11
  • 30
1
vote
1 answer

How can I run `scalafmt` on a specific file?

I know if I do sbt scalafmt it will run it on the entire project. How can I do this for a specific file?
maahd
  • 672
  • 2
  • 9
  • 30
1
vote
0 answers

Make scalafmt keep infix expression on one line and break line before match case pattern and body

Inside a match expression Scalafmt is giving me: case Some(thing) => s ++ myMethodName(Some(my.other.method(argument))) What I want is this: case Some(thing) => s ++ myMethodName(Some(my.other.method(argument))) Or, if the line is too long…
Adam Mackler
  • 1,980
  • 1
  • 18
  • 32
1
vote
1 answer

Using scala format, how to exclude view files from playframework

My .scalafmt.conf file has the following: project.excludeFilters = [ "glob:**.html" ] When I edit a playframework twirl view file, it formats the file and it screws up the format and causes issues e.g. puts a space after @ and breaks the…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
1
vote
2 answers

scalafmt: Getting meaningful error messages

I am using 'scalafmt' command to ensure that I've no formatting errors in my Scala code. It keeps failing with this error message: Looking for unformatted files... (98.35 %, 238 / 242) error: --test failed Those are the last two lines. There's no…
DilTeam
  • 2,551
  • 9
  • 42
  • 69
1
vote
1 answer

Indentation 4 spaces is not working in scalafmt.config in VS Code

I am trying to setup scalafmt.config, such that it formats my code. All the features I am using -- such as align.preset = more, align.openParenDefnSite = false etc. -- seem to work perfectly. However, I have an issue with indentation. I want to set…
1
vote
2 answers

Scala format is causing issues when saving my main.js file in play

original: Scala formatted: It is adding a space where…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
1
vote
1 answer

How to invoke plugin from command line (sbt beginner)?

Following https://scalameta.org/scalafmt/docs/installation.html I'm trying to reformat my Scala code via command line. How to execute the scalafmt command ? Loading sbt from the project can I invoke scalafmt ? Using below returns error…
blue-sky
  • 51,962
  • 152
  • 427
  • 752
0
votes
0 answers

How to setup scalafmt so it respects custom formatting of multiline method calls

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,…
Wojciech
  • 1
  • 1
0
votes
1 answer

scalafmt to check only modified files

sbt scalafmtCheckAll checks the format of all files in the repo, how to check only the format of the modified files. And whats the difference between sbt scalafmtCheckAll and sbt scalafmtCheck?
ehsun7b
  • 4,796
  • 14
  • 59
  • 98
0
votes
1 answer

scalafmt download error while using nexus

I want to use Scalafmt in corporate network ( on a windows machine) using Nexus. I get below error if i run scalafmt [error] failed to resolve Scalafmt version '2.4.6': X:\ProjectA\.scalafmt.conf [error] (Compile / scalafmt) failed to resolve…
KK2486
  • 353
  • 2
  • 3
  • 13
0
votes
1 answer

SBT Formatter Plugin Using Common Config File

I have the following piece of code: package my.package import sbt._ import Keys._ object OpenElectronsScalaFmtPlugin extends AutoPlugin { override def trigger = allRequirements override def requires = plugins.JvmPlugin override def…
joesan
  • 13,963
  • 27
  • 95
  • 232