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
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
    }
dieselmat
@dieselmat
hello, I've looked into the documentation and configuration a few times. But fail to see where I could disable the code formatting temporarily via sbt of the scalafmt.conf file. All I fount was // format: off. I'd like to temporarily disable formatting for a quick dev build. Anyone can point out a config for it?
unless this is turned on in your build, scalafmt shouldn't just reformat the code unprompted
dieselmat
@dieselmat
Thanks! Will try
Artem Nikiforov
@nikiforo

Hi,
By default(I suppose) scalafmt changes this

seqTuple2
  .map { case (a1, a2) =>
    ???
  }

to this

seqTuple2
  .map {
    case (a1, a2) =>
      ???
  }

I've tried to find the way how to turn this feature off couple of times, but with no results.
I've found term case arrows, but not sure if this is what I'm searching.
Can I disable this rewrite rule?

QP
@theqp
i think this is not related to case, but to blocks
Johan Grande
@nahoj

Hi all,
I'm trying to make scalafmt format consecutive parameter blocks (at defn site) in the same way, i.e. to avoid formatting such as:

class MyClass(aaaaaaa: Aaaaaaaaa,
              bbbbbbbbbbbbb: Bbbbbbbbbbbbbbb)
             (implicit ccccccc: Ccccccccc,
              dddddddddddd: Dddddddddddd) extends Eeeeeeee {}

to

class MyClass(aaaaaaa: Aaaaaaaaa, bbbbbbbbbbbbb: Bbbbbbbbbbbbbbb)(implicit
    ccccccc: Ccccccccc,
    dddddddddddd: Dddddddddddd)
    extends Eeeeeeee {}

here with

align.openParenDefnSite = true
danglingParentheses.defnSite = false

Is this at all possible?

Thai Dang Vu
@dxxvi

Hi All, this is a very basic configuration but I don't know how to do it

object Main extends App {
  println("hello")
  println("world")
}

What should I use in .scalafmt.conf so that there are 4 spaces before the println?

Eric K Richardson
@ekrich
In general, standard Scala formatting uses 2 space indention unlike Java. https://docs.scala-lang.org/style/indentation.html Here are the scalafmt docs: https://scalameta.org/scalafmt/docs/configuration.html You can search for indentation.
Gabriel Volpe
@gvolpe:matrix.org
[m]

Hi folks 👋

Question: is there a workaround to get scalafmt not failing when cross-compiling Scala 2.13.x and 3.0.x? Right now, it fails if I set scalafmtOnCompile := true. I would like to keep running it on Scala 2.12.x and shared code but not for files in the Scala 3.x directory. I tried setting format: off on my Scala 3 file but that didn't work.

I know that Scala 3 support is in progress so all I want is to skip Scala 3 files for now. Thanks!

Anton Sviridov
@keynmol

we did something like

project.excludeFilters = [
   ".*-scala-3.*"
]

in .scalafmt.conf to skip the folders with scala 3 sources (exact regex will need match what you have)

Gabriel Volpe
@gvolpe:matrix.org
[m]
Thanks, I'll give that a try!
hamnis
@hamnis:matrix.org
[m]
hello. I'm looking for an option to add scala-3 like parens to lambdas. is there one for that?
so
Some("foo").map( a => s"bar $a") adds parens around "a"
hamnis
@hamnis:matrix.org
[m]
or is that just when we have Some("foo").map{ (a) => s"bar $a"}
Igal Tabachnik
@hmemcpy
Hello. I was wondering if I could somehow exclude the default case _ => from having its => aligned when using align.tokens?
image.png
I have matches with long-ish ifs, and aligning the default case seems.... of
off*
Igal Tabachnik
@hmemcpy
Honestly would be happy if I could specify something like a Scalameta's term pattern, e.g.
{ code = "=>" owner = "Case" except = ["Case(Pat.Wildcard(), None, _)", "Case(_, Some(_), _)"] }
Would exclude wildcard case _ => as well as case clauses containing ifs.... just a thought :)
Igal Tabachnik
@hmemcpy
Oh, wait! I didn't realize it expects a regexp!
I may hack something yet :)