Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 26 2017 22:35
    olafurpg synchronize #947
  • May 26 2017 22:23
    olafurpg synchronize #947
  • May 26 2017 22:22
    olafurpg synchronize #947
  • May 26 2017 22:20
    olafurpg opened #947
  • May 26 2017 22:07
    olafurpg commented #943
  • May 26 2017 21:53

    olafurpg on v1.0.0-RC1

    (compare)

  • May 26 2017 21:46

    olafurpg on master

    Upgrade to non-broken metaconfi… Merge pull request #946 from ol… (compare)

  • May 26 2017 21:46
    olafurpg closed #946
  • May 26 2017 21:25
    olafurpg opened #946
  • May 26 2017 14:44

    olafurpg on master

    documentation fix: binPackParen… Merge pull request #945 from na… (compare)

  • May 26 2017 14:44
    olafurpg closed #945
  • May 26 2017 14:43
    olafurpg commented #943
  • May 26 2017 14:39
    olafurpg commented #943
  • May 26 2017 14:03
    pjrt commented #943
  • May 26 2017 13:36
    pjrt commented #943
  • May 26 2017 13:12
    nadavwr opened #945
  • May 25 2017 22:57
    ScalaWilliam commented #943
  • May 25 2017 21:34
    pauldraper commented #890
  • May 25 2017 21:34
    pauldraper commented #890
  • May 25 2017 17:23
    olafurpg commented #943
Eric K Richardson
@ekrich
@mpilquist I agree, I don't mind small diffs on new versions as things move forward but I'm having a really hard time upgrading on Scala Native - I'm usually the one doing that upgrade. I wish that all the major Scala projects could use and agree on a standard format and use scalafmt as well.
Luka Jacobowitz
@LukaJCB
I 100% agree with @mpilquist here
Mikhail Filipchuk
@LiuVII
Hey guys!
Have this question which is related to an already solved issue: https://github.com/scalameta/scalafmt/issues/2137#issuecomment-706268257
Wonder if someone can provide guidance on why/how the indentation in scalafmt works for these cases
Or should I open a new issue for this?
kellen
@kellen
Happy friday; any chance we could get a new release of sbt-scalafmt? We'd like to start using scalafmt 2.7.x
4 replies
Michel Charpentier
@charpov_gitlab

What are the parameters that control the layout of Curried methods, as in def f(...)(...)? I'm not happy with the default behavior, which breaks line after the second opening parenthesis.

I see several questions along the same lines, but no answers. Is there any way to configure the behavior of scalafmt on methods/classes with multiple lists of arguments?

5 replies
Diego E. Alonso Blas
@diesalbla

Two questions...
1 - Is there a Q&A site for Scalafmt, about "which option does this"? This may be helful to unclutter gitter...
2 - Which option does this: control the minimum numbers of parameters in a method declaration (or class or any definition) before newlines are introduced, provided declaration still fits in column length...

E.g. so that the following

def dwarves(fili: Fili, kili: Kili): Ori =

Is not auto-formatted into the following:

def dwarves(
  fili: Fili,
  kili: Kili
): Ori =
Diego E. Alonso Blas
@diesalbla
Found it...
optIn.configStyleArguments = false
runner.optimizer.forceConfigStyleMinArgCount = 3
Raitis Veinbahs
@siers
This message was deleted
Raitis Veinbahs
@siers
I put a println in scalafmt-core/shared/src/main/scala/org/scalafmt/Scalafmt.scala, format methods, but they don't seem to be getting called even though scalafmt-dynamic in ScalafmtReflect is dynamically loading it and seemingly calling format on it...
8 replies
Raitis Veinbahs
@siers
I was planning to try running Scalafmt.format and see how the tree that it is getting looks like by printing it, but I absolutely cannot get anything to work...
Raitis Veinbahs
@siers
I was running it with cli/run
Maxime Kjaer
@MaximeKjaer

Hey all,

I've opened a PR to add scalafmt to Scala.js: scala-js/scala-js#4260. However, I think I may have encountered a bug when reformatting the codebase, whereby a file's contents got deleted as a result of the reformat. I have a hunch of what may have happened, but I'm not quite certain about it, so I wanted to ask here if this makes any sense.

I added a top-level script (in this commit https://github.com/scala-js/scala-js/pull/4260/commits/95dbd1fc548d6c8737f71b8e855661fe7d57e4cb) that executes scalafmt for each subproject, on multiple threads. However, when I ran the top-level scalafmtAll, the contents of a file got deleted, which is unexpected. Now, Scala.js has many subprojects, many of which have overlapping file sets. My thinking is that two separate scalafmt threads may have overwritten each other's results. Is this possible at all? If so, would it be possible to change the implementation so that scalafmt always gets a lock on a file before writing it? Or should I not be using scalafmt as a top-level script like that in the first place?

3 replies
Mykhailo Osypov
@mosyp

Hi, how am I able to format code like this:

def func(a: Int)
                  (implicit b: Int): Int = ???

because the default one is:

def func(a: Int)(implicit 
    b: Int
): Int = ???

I've tried to use optIn.configStyleArguments = false but didn't worked for me.
Or, is there any possible way to turn off function definition formatting?

1 reply
Sean Romocki
@sromocki
Hello all,
I'm trying to use the Scala plugin (updated to latest version) in IntelliJ 2020.2.3 which comes with scalafmt and I'm seeing the below error.
12:02 PM    Can not resolve scalafmt version 2.6.2:
                 An error occurred during downloading:
                 unresolved dependency: org.scalameta#scalafmt-cli_2.12;2.6.2: not found
                     unresolved dependency: org.scala-lang#scala-reflect;2.12.8: not found
At one point I had the old deprecated Scalafmt plugin installed but I have uninstalled it (not sure if some lingering caching related to that plugin is what's causing this issue)
I get this error no matter what version of scalafmt I change it to
Pathikrit Bhowmick
@pathikrit
Is scalafmt the right tool to also format resources? Use case: we check in .csv files under src/test/resources which contain test cases. We would like to keep this CSV files sorted.
Georgi Krastev
@joroKr21

Hi, sorry if this has been asked before but it's really hard to search for. Is there a way to configure select chains like this:

1.to(5).map { x =>
  val y =  x + 1
  y * y
}.filter(_ % 2 == 0)

as opposed to:

1.to(5).map { x =>
  val y =  x + 1
  y * y
}
.filter(_ % 2 == 0)

I really dislike the dangling code after a closing curly brace but I couldn't find a way to configure it the way I want

2 replies
rnd4222
@rnd4222_gitlab
Would be cool to be able to disable all formatting and then selectively opt-in for some rules
James Yoo
@jamesyoo_gitlab
Hi folks! Is there a scalafmt setting for enforcing parens around one arg lambdas? e.g.
xs.map { x: T =>
    foo(x)                 // should fail to lint
}

and instead get

xs.map { (x: T) =>
    foo(x)                 // fine
}

I've looked in the docs and issues on GitHub and couldn't find a discussion on this. This is for prepping a codebase to migrate to Scala 3

Matt Hicks
@darkfrog26

is there any way to make Scalafmt remove aligned types? Like:

class Foo(
  one:     Bar,
  another: Baz
)

so that it formats:

class Foo(
  one: Bar,
  another: Baz
)
after running formatting it seems to retain that
Eric K Richardson
@ekrich
Align=more or most are the settings - not sure if that is what you are asking.
Matt Hicks
@darkfrog26
I set alignment:
align = none
align.openParenCallSite = true
align.openParenDefnSite = true
align.stripMargin = true
1 reply
it doesn't appear to remove the spaces in formatting
I want an aggressive reformatting, but scalafmt seems pretty passive
Matt Hicks
@darkfrog26
Ah, nevermind. It was because I wasn't setting the version on Scalafmt, so IntelliJ was formatting with version 1.5.1 by default.
Explicitly setting the version to 2.7.5 fixed it
Matt Hicks
@darkfrog26

is there any way to get:

def foo(
  one: Int,
  two: Int
)

to be formatted as:

def foo(one: Int,
        two: Int)
Eric K Richardson
@ekrich
Let me look scala native uses that one
I think it is in these.
# changed 1.6 or after
align.openParenCallSite = true
align.openParenDefnSite = true
# avoid wrapping parens on new line
danglingParentheses.defnSite = false
danglingParentheses.callSite = false
Sean Romocki
@sromocki
I'm still not able to use scalafmt in IntelliJ and I'm not sure what else to try to get it to work. Seeing
11:34 AM    Can not resolve scalafmt version 2.7.5:
                    An error occurred during downloading:
                    unresolved dependency: org.scalameta#scalafmt-cli_2.12;2.7.5: not found
                    unresolved dependency: org.scala-lang#scala-reflect;2.12.8: not found
6 replies
QP
@theqp
hi

instead of this

  def foo =
    1
      .tap { s =>
        s.toString
      } tap { s =>
      s.toString
    }

I want

  def foo =
    1
      .tap { s =>
        s.toString
      } tap { s =>
        s.toString
      }
4 replies
what should I change in the config?
QP
@theqp
I have found a solution: not mixing infix and dot notation
  def foo2 =
    1 tap { s =>
      s.toString
    } tap { s =>
      s.toString
    }
Philipp Dörfler
@phdoerfler
Hi! I want to use scalafmt on code I generated. My program is currently running on scastie, so I can't have a configuration file. Is there an alternative to scalafmt.format that I can call without a path to a config file? Where can I find the API docs? Thanks!
4 replies
Jason Pickens
@steinybot

Can someone please explain how newlines.topLevelStatementsMinBreaks works? I don’t really understand it. I think I get what the docs say but it doesn’t seem to work how I expect so my interpretation must be wrong. I tried:

newlines {
  topLevelStatements = [before]
  topLevelStatementsMinBreaks = 1
}

And expected a newline before every top level statement but it doesn’t do that. What I actually want is a newline before and after every top level def but I don’t know how to do that.

4 replies
Eric K Richardson
@ekrich
For the most part scalafmt doesn't mess with your blank lines. Those tend to be easy to change and review easily. What are you trying to achieve?
Jason Pickens
@steinybot
I want it to insert new lines before top level defs
Eric K Richardson
@ekrich
I don't see any rewrite rules for that sort of thing.
Jason Pickens
@steinybot
That’s with:
newlines.topLevelStatements = [before,after]
newlines.topLevelStatementsMinBreaks = 0
It does it for all top level statements though which is worse. I’ll just put them in manually, it’s not too bad.
Eric K Richardson
@ekrich
Sorry, I haven't used it before - it seems a bit strange to me too when clicking on before/after.
rc4m
@rc4m
Hi! Is there a way to align the = with the <- in for comprehensions? align.preset=more seems to only align <- with <- and = with =.
rc4m
@rc4m
Found my answer on Discord.
QP
@theqp
hi
scalafmt currently formats like this
    x match {
      case (
            "xxxxxxxxxxxxxxxxxxxxxx" | "xxxxxxxxxxxxxxx" | "xxxxxxxxxxxxxxx" |
            "xxxxxxxxxxxxxxx" | "xxxxxxxxxxxxx"
          ) =>
        y
    }
i want it to look like this
  def loadRow3(): Unit =
    x match {
      case (
            "xxxxxxxxxxxxxxxxxxxxxx"
              | "xxxxxxxxxxxxxxx"
              | "xxxxxxxxxxxxxxx"
              | "xxxxxxxxxxxxxxx"
              | "xxxxxxxxxxxxx"
          ) =>
        y
    }