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
-      if ((fromIndex < 0) || (fromIndex >= _size) || (toIndex > size())
-          || (toIndex < fromIndex)) {
+      if (
+        (fromIndex < 0) || (fromIndex >= _size) || (toIndex > size())
+        || (toIndex < fromIndex)
+      ) {
This just seems counter to anything seen in the wild.
Eric K Richardson
@ekrich
We are very close with exception of the default wrapping the if conditions on the next line which looks very strange. https://github.com/scala-native/scala-native/pull/2315#issuecomment-851529817
Eric K Richardson
@ekrich
@kitbellew Should I put in a feature request or issue where this can be discussed? I sure would like to be able to complete the transition for version 3. We are very close.
2 replies
Eric K Richardson
@ekrich
@kitbellew Thanks you for your hard work on scalafmt. As I say in the feature request scalameta/scalafmt#2573, we are pretty excited to upgrade and to be ready for Scala 3 as well. cc @olafurpg
Eric K Richardson
@ekrich

I tried out the new version - was trying snapshot too and the change reduced the lines in the diff by over 1000. This looks like we get the 4 spaces as well as the 2 spaces via line continuation due to wrapping.

indent.ctrlSite = 4
danglingParentheses.ctrlSite = false
       if (host != null) {
-        if (host.indexOf(':') != -1 && host.indexOf(']') == -1 && host.indexOf(
-              '[') == -1) {
+        if (host.indexOf(':') != -1 && host
+              .indexOf(']') == -1 && host.indexOf('[') == -1) {
           hostVar = "[" + host + "]"

Most if the time it is just 4 but in some weird wrap cases it becomes 6. I think purposely wrapping can fix it. And it does.

        if (host.indexOf(':') != -1 &&
            host.indexOf(']') == -1 &&
            host.indexOf('[') == -1) {
          hostVar = "[" + host + "]"
        }

Very cool - pretty sure with a few changes to code we will be able to upgrade - thanks so much.

4 replies
Eric K Richardson
@ekrich
Here is an example:
       if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
-          (ch >= '0' && ch <= '9') || legal.indexOf(ch) > -1)) {
+            (ch >= '0' && ch <= '9') || legal.indexOf(ch) > -1)) {
3 replies
Eric K Richardson
@ekrich
I must be doing something wrong here - it wraps the example.
@@ -50,11 +49,8 @@
   /** Returns this value bit-shifted right by the specified number of bits,
-   *         filling the new left bits with zeroes.
-   * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}}
-   * @example
-   * {{{
-   * 4294967275 >>> 3 == 536870909
-   * // in binary: 
-   * 11111111 11111111 11111111 11101011 >>> 3 ==
-   * 00011111 11111111 11111111 11111101
-   * }}}
+   *  filling the new left bits with zeroes.
+   *  @example
+   *    {{{21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010}}}
+   *  @example
+   *    {{{ 4294967275 >>> 3 == 536870909 // in binary: 11111111 11111111
+   *    11111111 11101011 >>> 3 == 00011111 11111111 11111111 11111101 }}}
    */
3 replies
charego
@charego

Hi everybody. I have a long function with two parameter groups:

private def myLongFunctionName(param1: Option[String], param2: Seq[Int])(f: Long => Boolean): Seq[String] = {
  ...
}

Is it possible to configure scalafmt to prefer breaking on the first parameter group?

private def myLongFunctionName(
  param1: Option[String],
  param2: Seq[Int]
)(f: Long => Boolean): Seq[String] = {
  ...
}
2 replies
Saskia Gennrich
@pektinasen
Hello, is there a way to align the <- and = in a for comprehension.
like this:
    for {
      aLongName <- Future(1)
      short      = aLongName + 1
      _         <- println(short))
    } yield ()
Saskia Gennrich
@pektinasen
I was playing around with {code = "<-", owner = "Term.ForYield"}, in align tokens, but have to admit I don't really understand how align.tokens and owner works.
4 replies
Eric K Richardson
@ekrich
@kitbellew I just wanted to let you know that I was able to work around any formats where it was not obvious one the indent by just doing some intentional wrapping. I put the opening ( in a long if condition on a new line therefore making the first indent 4 and then the next 6 for example. Just waiting on some reviews but it looks like the upgrade for Scala Native will happen - I really like some of the new defaults - very easy to read - we have on 4 non-defaults and a few other misc things. I am super excited. Super great work you and others have been doing! :rocket:
Albert Meltzer
@kitbellew
glad you're finally at the finish line
Wim Verreydt
@wimve

Hi, it seems that sbt-scalafmt is no longer available on maven central? https://repo1.maven.org/maven2/org/scalameta/sbt-scalafmt/2.4.2/
It is still in the search index though (probably explaining the geen maven badge on the installation documentation page) https://search.maven.org/artifact/org.scalameta/sbt-scalafmt/2.4.2/jar

What repository should I use to import this?

Wim Verreydt
@wimve
Tnx for the info! In the end, it tuned out that I was running into an SBT issue https://github.com/sbt/sbt/issues/5263/. The fmt plugin import was configured correctly after all but the exception made it look like it was searching in the wrong place.
Felix Bruckmeier
@felixbr

Hi,

Is Scala3 using already supported?

I've tried to replace implicit with using and the compiler is happy but scalafmt (3.0.0-RC5) isn't:

private def fetchEntry(
  vertical: Vertical
)(using db: DBConnections) = ...

// OR

private def fetchEntry(
  vertical: Vertical
)(using DBConnections) = ...

In both cases I get:

error:   : expected but identifier found
)(using db: DBConnections) =
        ^:

If you need more information I can also open an issue but I thought it may be a known problem (or me being dumb) 🙂

Fabio Labella
@SystemFw
@felixbr try runner.dialect = scala3
Felix Bruckmeier
@felixbr
@SystemFw Thanks, that does the trick 👍
Eric K Richardson
@ekrich
WIll using {{{ and }}} keep scalafmt from messing with html? If so, will the html still render ok?
1 reply
Tag '@throws' must be followed by a symbol name
5 replies
Seems like the current wrapping cause scaladoc errors?
Eric K Richardson
@ekrich
I just put in an issue for the second problem as the first is a known issue. scalameta/scalafmt#2609
Eric K Richardson
@ekrich
Does runner.dialect work on cross projects with Scala 2 and 3 code?
Albert Meltzer
@kitbellew
no. you need to use fileOverride
Eric K Richardson
@ekrich
Matthew de Detrich
@mdedetrich

So I have a question, I am trying to make

preset = default
align.preset = most

Work with sbt's := operator (in the same way it works with the standard = where it vertically aligns it)

I am trying to use align.tokens.add to achieve this, i.e.
align.tokens.add = [
  {code = ":=", owner = "(Enumerator.Val|Defn.(Va(l|r)|Def|Type))"}
]
However nothing seems to be working
i.e. I am getting
ThisBuild / scalaVersion := "2.13.6"
ThisBuild / version := "0.1.0-SNAPSHOT"
Instead of
ThisBuild / scalaVersion := "2.13.6"
ThisBuild / version      := "0.1.0-SNAPSHOT"
This is my current .scalafmt.conf
version = 2.7.5
preset = default
align.preset = most
maxColumn = 120
project.git = false
align.tokens.add = [
  {code = ":=", owner = "(Enumerator.Val|Defn.(Va(l|r)|Def|Type))"}
]
align.openParenDefnSite = true
align.openParenCallSite = true
align.arrowEnumeratorGenerator = true
align.tokenCategory {
  Equals = Assign
  LeftArrow = Assign
}
danglingParentheses.preset = true
rewrite.rules = [RedundantBraces, RedundantParens]
Also does align.tokenCategory even do anything anymore?
4 replies
Matthew de Detrich
@mdedetrich
(I think its safe to remove this?)
Matthew de Detrich
@mdedetrich
Note that I am using scalafmt command line tool to format the project (i.e. running scalafmt in the root project), specifically https://aur.archlinux.org/packages/scalafmt-native-bin
trauts
@trauts:matrix.org
[m]

I'm trying to figure out which scalafmt rule is causing a linebreak to be inserted. I have the following two lines formatted the way I want them:
a.b.c.d()
.send()

but scalafmt is inserting a newline:
a.b.c
.d()
.send()

I've looked at the various configs for 'chain' and 'newline' and 'dot' and haven't figured out which rule is causing this. Any ideas?

the closest rule I've seen is optIn.breakChainOnFirstMethodDot but that doesn't seem to be it
vonchav
@voonchav_gitlab
Hi, 3.0.0-RC6 is out but I'm getting this error: [error] failed to download v=3.0.0-RC6
2 replies
Matthew de Detrich
@mdedetrich
Does anyone know if there is a native graalvm scalafmt-cli build for debian/ubuntu (i.e. similar to https://aur.archlinux.org/packages/scalafmt-native-bin)
3 replies
fanf42
@fanf42:matrix.org
[m]

Hello, sorry if it's a well know case, I'm new to scalafmt and didn't find info in doc. I would like to align the : in class definition, ie in place of aligning the type definition like the exemple in https://scalameta.org/scalafmt/docs/configuration.html#aligntokens, I would like to have

case class Foo(
  firstParam : Int,
  secondParam: String,
  thirdParam : Boolean
)

Is it possible ?

Albert Meltzer
@kitbellew
not currently
fanf42
@fanf42:matrix.org
[m]
ok thanks, too bad. It seems that I really have special tastes in vertical alignement and line break :)
(I also like my commas in front, valigned)
fanf42
@fanf42:matrix.org
[m]
perhaps a way to v-align comma at end of line? I don't find a way with the AST explorer, though
Albert Meltzer
@kitbellew
there was a parameter, something about poor man, that puts commas at the beginning of the line
the formatter can only align tokens which normally have a preceding space