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
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 :)
Eric K Richardson
@ekrich
Any thoughts of a Scala Native version?
Kasper Kondzielski
@ghostbuster91
Hi folks,
Maybe I should've ask it here instead of raising a gh issue. Anyway, does anybody knows how to do things described here: scalameta/scalafmt#2348 ?
Ioan Luca
@ioanluca
Hi everyone! Me and my team want to use scalatfmt within in intellij. We've got latest versions of intellij, so the Scala plugin comes with Scalafmt formatting as an option. However, Intellij attempts to download the scalafmt jars from the public internet and the firewall in our org doesn't allow that. We do have scalafmt within our internal maven repository though. Is there any way we can point the Scala plugin to use a local scalafmt jar, or tell it what maven repo to download it from? Thanks
Raitis Veinbahs
@siers
I want to develop a new rule. How do I start? How do I load the correct environment to import and try out scala.meta's parsers in the REPL? How do I run only a single rule's *.stats/test files?
5 replies
Oron Port
@soronpo

For my DSL in Scala I have a code that looks like this

  val addr    = DFBits(10) <> OUT
  val data_rd = DFBits(16) <> IN
  val data_wr = DFBits(16) <> OUT

Is there a way I can automatically align it at = and <> ?

Raitis Veinbahs
@siers
contributing.md doesn't explain how to start a new rule.
Eric K Richardson
@ekrich
I think you can add <> to the align. Not sure if that would help.
Oron Port
@soronpo
I'm pretty sure I've tried that already.
Eric K Richardson
@ekrich
For the equals you have more or most?
Does DFBits get bigger and smaller?
Oron Port
@soronpo
I'll post another example code
@df final class SMA extends DFDesign {
  val clk         = DFBit      <> IN
  val rst         = DFBit      <> IN
  val x           = DFUInt(16) <> IN  init 0
  val y           = DFUInt(16) <> OUT
  val x_prev1     = DFUInt(16) <> VAR init 0
  val x_prev2     = DFUInt(16) <> VAR init 0
  val x_prev3     = DFUInt(16) <> VAR init 0
  val s1          = DFUInt(17) <> VAR init 0
  val s1_pipe1    = DFUInt(17) <> VAR init 0
  val s2          = DFUInt(17) <> VAR init 0
  val sum         = DFUInt(18) <> VAR init 0
  val x_prev1_sig = DFUInt(16) <> VAR
  val x_prev2_sig = DFUInt(16) <> VAR
  val s1_sig      = DFUInt(17) <> VAR
  s1              := x.resize(17) + x_prev1
  s2              := x_prev2.resize(17) + x_prev3
  sum             := s1_pipe1.resize(18) + s2
  x_prev1_sig     := x_prev1
  x_prev2_sig     := x_prev2
  s1_sig          := s1
  ifdf(rst === 0) {
    x_prev1       := 0
    x_prev2       := 0
    x_prev3       := 0
    s1_pipe1      := 0
  }
  .elseifdf(clk.rising()) {
    x_prev1       := x
    x_prev2       := x_prev1_sig
    x_prev3       := x_prev2_sig
    s1_pipe1      := s1_sig
  }
  y               := (sum >> 2).resize(16)
}
2 replies
Oron Port
@soronpo
Maybe I have something very specific and Scalafmt is too general.
So essentially I have two alignment points.
The first is common to =, :=, and <> (not displayed here) and the second <> (that comes after =)
Or alternatively, is there a way I can stop scalafmt from being applied to specific patterns of code, so it won't delete my manual alignment?
Eric K Richardson
@ekrich
There is an ignore to wrap a code block.
Oron Port
@soronpo
Thanks. I searched for "ignore", "preserve" and couldn't find it.
I would have loved a way to apply this automatically for certain patterns, but I guess my problem is too specific.
Eric K Richardson
@ekrich
You can ignore like this.
// format: off
val identity = Array(1, 0, 0,
                     0, 1, 0,
                     0, 0, 1)
// format: on
Raitis Veinbahs
@siers

If I would like to convert

object {
  val a = 1
}

to

object {

  val a = 1

}

and vice-versa, depending on the configuration, should I patch some existing reformatters or make a new one in scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/?

2 replies
Raitis Veinbahs
@siers
I see that tree.structure doesn't have whitespace in it, so it must be an operation on the token array?
Philip Whitehouse
@philipwhiuk
Hi. Does anyone know why scalameta/sbt-scalafmt and lucidsoftware/neo-sbt-scalafmt both exist?
Josh Soref
@jsoref
is scalafmt the thing that generates diffs like this?
--- /github/workspace/something/foo.scala
+++ /github/workspace/something/foo.scala-formatted
@@ -1541,3 +1541,6 @@
       ),
-      thing(someLongItem, dateLikeItem = LocalDateTime.of(2020, JANUARY, 15,12,0)),
+      thing(
+        someLongItem,
+        dateLikeItem = LocalDateTime.of(2020, JANUARY, 15,12,0)),
+      ),
       thing(item, dateLikeItem = LocalDateTime.of(2020, JANUARY, 15, 12, 0))
1 reply
Markus Appel
@markusa380

Our current configuration formats like this:

  val live: List[
      String with String with List[String] with List[String] with List[String] with List[String] with List[String] with String with String with List[
          String
      ] with String
  ] =
    ???

(Of course this is just a replacement for the actual type signature)

I'd like scalafmt to prefer breaking on with instead of [, how can I do that?

Alex Klibisz
@alexklibisz

Hi, wondering if there is a setting that will remove curly brackets from single-line methods?
For example:

Take this

def foo(x: Int): Int = { 
  x + 1
}

And automatically convert to this:

def foo(x: Int): Int = 
  x + 1
Eric K Richardson
@ekrich
@tgodzik / @olafurpg We could try a Scala Native now. I was blocked because Scala Native removed all of the java.time code from the core. I ported the library from Scala Native and now am using that to support sconfig which requires some java.time support. I left a note on the issue. scalameta/scalafmt#1172
I see you saw it. @tgodzik
Tomasz Godzik
@tgodzik
yeah, we were looking at what exactly we need and one of those is scalameta
we need to add Scala native support back
Eric K Richardson
@ekrich

I see the fast parse dependency is older with a comment, the version 1.0.1 is not on maven. The newest version 2.3.1 is supported on 2.12 and 2.13.

Ported config quite some time ago for this but we never quite made it to the finish line. 20 releases later now. The 4th release was the first with 0.3.9 Scala Native support. Hoping sconfig will work ok - not many users.

Sourcecode is the same version.