by

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
Lawrence Wagerfield
@ljwagerfield

After updating from 2.5.0-RC3 to 2.5.0 using align.preset = most, I can't seem to understand the rules for vertical alignment on = after method bodies... it seems "if the method body contains a val or a for-comp then vertically align the method's ="?

  def foo: Int    = {
    val x = ???
    42
  }

  def bar: Int    = {
    for { x <- "hey" } yield x
    42
  }

  def fooBig: Int = {
    42
  }

  def fooBigger: Int = {
    42
  }

Not sure if this is as-intended (particularly as the behaviour is so wildly different from 2.5.0-RC3).

Albert Meltzer
@kitbellew
@ljwagerfield you should really read the release notes. see align.multiline.
Lawrence Wagerfield
@ljwagerfield

If this flag is set, when alignment is applied, multiline statements will not be excluded from search of tokens to align.

If multiline statements are not excluded when align.multiline=true, then why is fooBigger excluded in the example above?

Albert Meltzer
@kitbellew
bug. in fact, all of it is a bug. blank line should interrupt alignment.
Albert Meltzer
@kitbellew
@ljwagerfield #1943, will be part of 2.5.1 tomorrow
Lawrence Wagerfield
@ljwagerfield
:+1:
Shane Delmore
@ShaneDelmore
I’m seeing a change I haven’t figured out how to control yet going from scalafmt 2.4.2 to 2.5.1 where it now does what looks to me like a dangling bracket.
   val deleteSubscriptionsRequestInjection: ScroogeBufferInjection[
-    thrift.DeleteSubscriptionsRequest] = new ScroogeBufferInjection(
+    thrift.DeleteSubscriptionsRequest
+  ] = new ScroogeBufferInjection(
     thrift.DeleteSubscriptionsRequest
   )
Is there a setting I can control this with to prevent this particular change?
Shalki Shrivastava
@Shalsh23
I am trying to install the latest v2.5.1 of scalafmt using homebrew brew install --HEAD olafurpg/scalafmt/scalafmt. But that installs v2.3.2. I even did brew cleanup, upgrade, reinstall but that didn't help. Anyone has any idea how to resolve this?
Albert Meltzer
@kitbellew

I’m seeing a change I haven’t figured out how to control yet going from scalafmt 2.4.2 to 2.5.1 where it now does what looks to me like a dangling bracket.

   val deleteSubscriptionsRequestInjection: ScroogeBufferInjection[
-    thrift.DeleteSubscriptionsRequest] = new ScroogeBufferInjection(
+    thrift.DeleteSubscriptionsRequest
+  ] = new ScroogeBufferInjection(
     thrift.DeleteSubscriptionsRequest
   )

@ShaneDelmore can you create an issue and post your config there?

Shane Delmore
@ShaneDelmore
Sure, I can take it to github. Wasn’t sure it was an issue or if I was holding it wrong.
Ori Popowski
@oripwk
Hi people,
How can I tell sbt scalafmtCheckto also print the problematic lines and the respective warning for those lines?
I just want to print a report of everything which should be fixed in the source code.
Thanks :)
Ori Popowski
@oripwk
digging a bit deeper, I've found that the CLI tool command scalafmt --test does just that. However, I don't know how to do it in the sbt plugin
Shane Delmore
@ShaneDelmore
I don’t use sbt these days so this isn’t first hand, but docs say it’s scalafmtCheck https://scalameta.org/scalafmt/docs/installation.html#task-keys @oripwk
obszczymucha
@obszczymucha
Hi. I'm trying to use scalafmt as described in the installation section on the website with addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2") but I'm getting unresolved dependency errors for it. It seems version 2.3.2 cannot be found. I tried 2.3.4 as well and no joy.
obszczymucha
@obszczymucha
I'm getting unresolved dependency: org.scalameta#scalafmt-cli_2.12;2.4.3: not found
obszczymucha
@obszczymucha
When I use version 2.5.0 in my config I get unresolved dependency: io.get-coursier#interface;0.0.17: not found and unresolved dependency: com.github.scopt#scopt_2.12;3.7.1: not found. Please help.
Loránd Szakács
@lorandszakacs

folks, I have a problem I cant solve. There's significant difference between 2.4.2 and 2.5.1 in terms of alignment

Code in 2.4.2:

  case class CC(
    field1:              String,
    fieldInt:            Int,
    fieldWithLongerName: String,
  )

  val x = CC(
    field1              = "string",
    fieldInt            = 42,
    fieldWithLongerName = "longerString",
  )

Code in 2.5.1:

  case class CC(
    field1:              String,
    fieldInt:            Int,
    fieldWithLongerName: String,
  )

  val x = CC(
    field1 = "string",
    fieldInt = 42,
    fieldWithLongerName = "longerString",
  )

Basically, all code alignment at function call sites got ruined. And not sure how to fix it.

My conf looks like the following:

align = most
align.openParenCallSite = false
align.openParenDefnSite = false

align.tokens.add = [
  "<-"
  "="
  //used to align comments
  "//"
  //used for aligning type definition
  ":"
  //used when creating tuples
  {code = "->", owner = "Term.ApplyInfix"},
//elided, since these are SBT specific
]

Been using the same config since 1.5.1.

If anyone can point me to something I should try, I would greatly appreciate it

6 replies
Loránd Szakács
@lorandszakacs
and adding {code = "=", owner = "Term.Apply"}, the the tokens list does not fix the problem :'(
Anton Parkhomenko
@chuwy
Hello! Is there an option that would preserve this kind of arguments alignment:
def fun(foo: String,
        bar: Int,
        baz: Something)
1 reply
Lena Brüder
@lenalebt
Hey together, maybe I overread this, but does scalafmt have the possibility to right-align for tokens? Asking because this in sbt looks ugly:
  "com.beachape"                 %% "enumeratum-circe"            % "1.5.17",
  "com.rabbitmq"                 % "amqp-client"                  % "5.6.0",
I want this to look like this:
  "com.beachape"                 %% "enumeratum-circe"            % "1.5.17",
  "com.rabbitmq"                  % "amqp-client"                 % "5.6.0",
Lena Brüder
@lenalebt
ah, forget this, the new scalafmt 2.5.1 can do it - by default!
obszczymucha
@obszczymucha
Is anyone having problems setting up IntelliJ with scalafmt? No matter what version of scalafmt I have in .scalafmt.conf, IntelliJ fails to download it. The latest version of IntelliJ.
2 replies
Loránd Szakács
@lorandszakacs

Follow-up on my problem, @kitbellew . Can't seem to write code blocks in replies :sweat_smile:

Can I get the "<-" and "=" to align in for comprehensions? In 2.4.2 I managed to get this done :cry:

    for {
      _ <- IO("please move me")
      value = IO("value")
      _ <- IO("I meddle")
      pleaseMoveMe = 42

      imMoved = "dsflk;sdf"
      soAmI   = 42

      _          <- IO("yup, so is this")
      definitely <- IO("yey!")
    } yield ()

How do I get the <- to align with the = in that first code block?

My current config looks like the following:

align.tokens.add = [
  {code = "<-", owner = "Enumerator.Generator"}
  {code = "=", owner = "(Enumerator.Generator|Val|Defn.(Va(l|r)|Def|Type))|Term.Assign"}
]

And looking at https://github.com/scalameta/scalafmt/blob/master/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala#L113

The two token categories are already "grouped together" when align.most is selected :confused:

3 replies
CodingPenguin
@TheCodingPenguin
Hello, is there a known issue with downloading Scalafmt using Homebrew. My version is stuck at 2.3.2 and it doesn't upgrade or reinstalling still gets 2.3.2 ?
6 replies
Shalki Shrivastava
@Shalsh23

Hello, is there a known issue with downloading Scalafmt using Homebrew. My version is stuck at 2.3.2 and it doesn't upgrade or reinstalling still gets 2.3.2 ?

I am having the same issue.

sken
@sken77
hi
having problems with downloading 2.5.1 for 2.12
image.png
Gintaras
@gintarasm
Hi. Is there a big difference between scalafmt syle and the on in https://docs.scala-lang.org/style/ ?
1 reply
Alexandru Nedelcu
@alexandru

Hi all, I have this formatting problem:

scalacOptions ++= Seq(
    "-Ymacro-annotations"
    "-Wconf:any:warning-verbose",
  ),

That's some extra indentation I don't want for function calls. I want that to look like this:

scalacOptions ++= Seq(
  "-Ymacro-annotations"
  "-Wconf:any:warning-verbose",
)

What option controls this?

6 replies
Using latest version, 2.5.2
Niklas Vest
@vest.niklas_gitlab

Hello everyone! :) Setting up scalafmt for the company I am working at. I would like to know whether there is a rule that rewrites single-line parens .map and .filter calls etc. to lambdas with braces according to a "kotlin like" format:

.map { x => 
  // using x
}

If that is not possible at all, can I at least have

.map( x => 
  // using x
)

without completely avoiding to break the line after the opening parentheses of a method call? because if method invocations get large, we generally want

someMethod(
  arg1,
  arg2,
  // ..
)
19 replies
Kalin-Rudnicki
@Kalin-Rudnicki
Is there a better documentation for this anywhere? All I can find is main "Introduction" type one the website, and it doesnt seem to have any sort of conducive list of what all of the options are with descriptions
Kalin-Rudnicki
@Kalin-Rudnicki
"Introduction" one on the website*
Jameel Al-Aziz
@jalaziz

Hey all, I'm struggling with formatting options and was curios if it was possible to achieve this formatting:

case class Foo(
  a: Boolean,
  b: String,
  c: String,
  d: String,
) extends Bar with Baz

It seems like I can't force the closing parenthesis on a newline without also forcing the extends to be on a newline. It also seems like with is always forced on a new line for some reason.

My settings are as follows:

version = 2.5.2
preset = IntelliJ
optIn.configStyleArguments = true
continuationIndent.extendSite = 0
continuationIndent.withSiteRelativeToExtends = 0
maxColumn = 160
docstrings = ScalaDoc
assumeStandardLibraryStripMargin = true
align.preset = some
spaces.inImportCurlyBraces = true
verticalMultiline.excludeDanglingParens = ["class", "trait"]
danglingParentheses.exclude = ["class", "trait"]
rewrite.rules = [AvoidInfix, SortModifiers, PreferCurlyFors]
2 replies
Rob Norris
@tpolecat
Is there an easy way to format a scala.meta.Tree using scalafmt?
1 reply
I'm generating some code and thought it would be nice to tidy it up. It would also be nice to create comments but I get the sense that this isn't quite possible yet.
Mathieu Prevel
@mprevel
Hi,
I cannot see scalajs artifacts for scalafmt-core since version 2.0.0 https://mvnrepository.com/artifact/org.scalameta/scalafmt-core
Does scalajs support (I mean publish for use in scalajs code, not formatting scalajs sources) have been removed ?
2 replies
Patrick Skjennum
@Habitats

is there a rule that'll make

val longLineOfCode = new Thing(a,b,c)

become formatted like

val longLineofCode = new Thing(
  a, 
  b,
  c
)

instead of

val longLineOfCode = 
    new Thing(a,b,c)

?

2 replies
Bradley Peterson
@thebearmayor

I can't figure out what controls the formatting of partial functions with case. If I start with the whole function on one line, it stays that way.

List((1, 'a'), (2, 'b')).map { case (i, c) => i.toString + c.toString }

But if I have a break after =>, scalafmt moves the case to a new line. From:

  List((1, 'a'), (2, 'b')).map { case (i, c) => 
    i.toString + c.toString
  }

To:

  List((1, 'a'), (2, 'b')).map {
    case (i, c) =>
      i.toString + c.toString
  }

I would like to maintain the first formatting. Conf contains only version = 2.5.3.

2 replies
Alexandru Nedelcu
@alexandru
Is there a rule for forcing that once case statements have newlines, then all subsequent ones should have newlines as well?:
// OK (all one liners)
obj match {
  case Option1(_) => line1
  case Option2(_) => line2
  case Option3(_) => line3
  case Option4(_) => line4
}

// OK (all with newlines)
obj match {
  case Option1(_) => 
    line1
  case Option2(_) => 
    line2
  case Option3(_) => 
    line3
  case Option4(_) => 
    line4
}

// OK (top statements one-liners)
obj match {
  case Option1(_) => line1
  case Option2(_) => line2
  case Option3(_) => 
    line3
  case Option4(_) => 
    line4
}

// NOT OK, this offends me :-)
obj match {
  case Option1(_) => 
    line1
  case Option2(_) => 
    line2
  case Option3(_) => line3
  case Option4(_) => line4
}
QP
@theqp
is there an option which always does the first one or the second one?
Albert Meltzer
@kitbellew

is there an option which always does the first one or the second one?

@theqp try newlines.source = unfold

Daniel Spiewak
@djspiewak

getting the following error. am I missing something obvious?

[error] (testsJVM / Test / scalafmt) Type mismatch;
[error]   found    : Map[K, V] (value: {"style": "Asterisk", "oneline": "unfold"})
[error]   expected : org.scalafmt.config.Docstrings: /Users/daniel/Development/Scala/cats-mtl/.scalafmt.conf

config fragment (basically straight from the documentation):

docstrings {
  style = Asterisk
  oneline = unfold
}
3 replies
this is with 2.5.3. it kind of looks to me like the codecs aren't working correctly
nsram
@nsram_twitter
Newbie here. what is the setting to prevent scala formatter from wrapping single line defs that go beyond (say 80 columns). Ditto for printlns. thanks. Google came up with maxColumns but metals views that as invalid (if I edit the file under the .metals folder in the directory). Thanks
2 replies
Kalin-Rudnicki
@Kalin-Rudnicki
@ anyone who works on this, scalafmt just happily decides to remove my import a.b.{given _}
1 reply
Kalin-Rudnicki
@Kalin-Rudnicki
And is there not a comprehensive list of rules anywhere? I asked about this earlier and it was blatantly ignored
6 replies