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
felher
@felher
  val x = blar match {
    case a          =>
      ???
    case aaaaaaaaaa => ???
  }

  val x = blar match {
    case a          =>
      ???

    case aaaaaaaaaa => ???
  }
I think the first one is corerct, since multiline is enabled. But I would have expected second one to not align, since a blank line normally breaks alignment. Am I thinking wrong or is this a bug. And if it is the latter, should I create an issue for it?
Albert Meltzer
@kitbellew
not a bug. multiline ignores blank lines
felher
@felher
@kitbellew Oh, okay. Could I open a feature request for making that configurable?
2 replies
Michel Charpentier
@charpov

Hi, is there a comprehensive "reference" configuration file for scalafmt with all the available options and default values?

Did you ever get an answer on this? Or on your next question? Configurability is good, but it can become overwhelming. I'm trying to understand why try <exp> catch is broken with a newline before the catch. The documentation doesn't mention try/catch at all.

2 replies
Roman Janusz
@ghik
@charpov no, unfortunately I did not get any answers.
vito-c
@vito-c
anyone have any documentation on the FormatWriter.scala?
I'm trying to add elements to an Array[FormatLocation] and make sure all of the indenting is working
What's FormatLocation.shift do?
9 replies
Jack Koenig
@jackkoenig
I found this really out issue that represents my problem scalameta/scalafmt#337, closed with probably no solution but it's been a couple of years so I thought I'd ask to see if there's any solution these days
Jack Koenig
@jackkoenig
vito-c
@vito-c
How do you access the settings in the FormatWritter? Is there a way a way to get the number of lines from an Array of FormatLocations right now I'm just looping over them and counting .isNL
5 replies
Jason Pickens
@steinybot
Do the docs contain unreleased settings?
1 reply
For example afterCurlyLambdaParams and beforeCurlyLambdaParams do not seem to exist in 2.6.4. afterCurlyLambda does exist (which I see has been renamed).
Jason Pickens
@steinybot
I find the verticalMultiline settings really confusing. There seems to be a lot of overlap with the align and newline settings but they interact in strange ways. I’ve spent way too long fiddling with the settings to get it to be ok for now but I hope to put together an example to put on an issue.
dennis-vaccaro
@dennis-vaccaro
Hi, I'm working on moving from scalariform to scalafmt for a project. Is there anything to help find the equivalent scalafmt configuration for different scalariform checkers?
1 reply
Kirill Veselov
@smart-ass

Hi people! Can you please help me? I'd like to keep formatting for cases like this:

units.zip(results).foreach { case (unit, res) =>
  unit.contexts.foreach(handlePersistedContext(_, res))
}

I tried with newlines.alwaysBeforeCurlyBraceLambdaParams=false, but the new line is always added before the case block. Is there a way to keep case on the same line?
If I replace case (unit, res) => with x => than the lambda parameter remains on the same line. Scalafmt version 2.6.4.

3 replies
Martijn Hoekstra
@martijnhoekstra
This message was deleted
1 reply
Esenbaev Nursultan
@eanea
Hi everyone! Could you help please? Is there any option to describe following:
1 reply
final implicit def contextTSubContext[F[+_]: Applicative: Defer, X]

  (implicit lens: AppContext[AppEnv[F, *]] Contains X)

  : WithLocal[AppEnv[F, *], X] =

    WithLocal[AppEnv[F, *], AppContext[AppEnv[F, *]]].subcontext(lens)
so what i wanna - 1) something like newlineBeforeOpenParen
2) newline before ':' - return type
Esenbaev Nursultan
@eanea
found this - newlines.sometimesBeforeColonInMethodReturnType
what does it mean 'sometimes'?
Esenbaev Nursultan
@eanea
ideal for me is look like:
def name[Bounds]
(args list)
(implicit args)
: ReturnType = {body}
class Name
(fields)
(implicit args) {body}
Jason Pickens
@steinybot
Haha woops this is totally the wrong channel. Sorry.
Esenbaev Nursultan
@eanea
how hard to implement newlineBeforeOpenParen option after class and method definition?
wpoosanguansit
@wpoosanguansit

hi, i am trying to use scalafmt and i do have alignments working fine. however, how do i prevent calling objects to:

    val obj    = Obj(
      x,
      y 
    )

i just like to have it on one line like - val obj = Obj(x, y). thanks for your help.

2 replies
kellen
@kellen

howdy, I'm on 2.6.4 and have two questions:

(1) I sometimes would like to keep class construction w/ more compact (if not exactly binpacked) e.g.

val xxx = MyCaseClass(
  a, b, c, d, e, f, g,
  h, i, j, k, l, m, n, o,
  p, q, r, s, t, u, v
)

this because most parameters are just copies from input (and therefore not very interesting) and aligning vertically w/ newlines after each param is mostly noise and obscures the rest of the code. Is this possible?

(2) how can I get it to not add a newline after the opening curly brace in e.g.

       .collect { case validationRow: PostValidation[ArtistEntity] if validationRow.isValid =>
           val row = validationRow.get
           row.artist_gid -> ArtistUriAndName(row.artist_uri.data, row.metadata_artist.flatMap(_.name))
       }

Again, a newline w/ more indent is just more visual noise IMO

12 replies
Diego E. Alonso Blas
@diesalbla
:question: Regarding newlines around implicits, is there an option to restrict the newlining of the implicit parameter block, unless there are at least N params?
1 reply

So that

(implicit 
   fili: Fili, 
   kili: Kili
)

keeps rewritten to (implicit fili: Fili, kili: Kili)

Aaron Delaplane
@AaronDelaplane
@malikin Did you figure out how to align case class constructor arguments?
1 reply
Tushar Mathur
@tusharmath
I am new to sbt and am bit confused about why I need to run these commands separately in my project —
sbt scalafmt 
sbt test:scalafmt
and is there a way I can run one command to execute it completely on my project?
Eric K Richardson
@ekrich
Is that going to get Scala.js onboard? I think they were looking for packed structs as well as a few other things.
2 replies
Colt Frederickson
@coltfred

I've tried to look at the changelog, but can't seem to find which default changed to change the formatting from:

        signature <- Signature
            .fromBytes(signatureBytes.value)
            .toRight(InvalidSignature(sigString))

to

          signature <-
            Signature
              .fromBytes(signatureBytes.value)
              .toRight(InvalidSignature(sigString)

I let myself get way behind in this one repo and I'm going from 2.4.3 to 2.7.0. What's the best way to identify which rule default has changed?

6 replies
michealhill
@micheal-hill

Is is possible to have types aligned vertically? eg. Scalafmt currently gives me something like

case class Foo(
  a: Int,
  bb: String,
  ccc: Boolean,
  dddd: List[Int],
  eeeee: List[String],
)

But I'd like to have instead:

case class Foo(
  a:     Int,
  bb:    String,
  ccc:   Boolean,
  dddd:  List[Int],
  eeeee: List[String],
)

I could see a few references to something like this in github issues, but couldn't figure out how to do it (or even if my understanding of those issues is correct)

1 reply
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.
Dale Wijnand
@dwijnand
Hey. Does anyone know how to get scalafmt to not wrap here?
-    override def equals(other: Any) = other match {
-      case o: ClassDependencies => internal == o.internal && external == o.external
-      case _                    => false
-    }
+    override def equals(other: Any) =
+      other match {
+        case o: ClassDependencies => internal == o.internal && external == o.external
+        case _                    => false
+      }
I tried newlines.source=fold but it doesn't look like it's that.
Dale Wijnand
@dwijnand
Ah, sjrd hit the same, newlines.alwaysBeforeMultilineDef = false saves the day
2 replies
QP
@theqp
in intellij idea is there any way to set that always use the newest scalafmt?
1 reply
Denis Kostousov
@kostousov-ds

Hi all. Does anyone know how to align multiline implicit

implicit
      SLogga: SLogga[AppTask],
      Trace: Traca[AppTask],
      Sync: Sync[AppTask],
      Clock: Clock[AppTask],
      ContextShift: ContextShift[AppTask]

to

    implicit
    SLogga       : SLogga[AppTask],
    Trace        : Traca[AppTask],
    Sync         : Sync[AppTask],
    Clock        : Clock[AppTask],
    ContextShift : ContextShift[AppTask]
Pavel Lavreshin
@plavreshin

Hello all! Could you please advice how to keep constructors multiline args alingment with scalafmt.conf.

I am currently using following conf

project.git = true
version = 2.7.2

maxColumn = 120

preset=IntelliJ

align.preset = none
align.stripMargin = true
align.openParenCallSite = false
align.openParenDefnSite = true
align.tokens = []

and when scalafmt encounters class with multiline constructor args like

class CalculationEngine(askTimeout: FiniteDuration)
                       (sparkJobConfig: SparkJobConfiguration,
                        configOne: Configuration,
                        configTwo: Configuration,
                        provider: Provider,
                        sc: SparkContext) {

it tends to reformat it to

class CalculationEngine(askTimeout: FiniteDuration)(
  sparkJobConfig: SparkJobConfiguration,
  configOne: Configuration,
  configTwo: Configuration,
  provider: Provider,
  sc: SparkContext) {

Just curious if there is any way to preserve former formatting?

QP
@theqp
how to make scalafmt do not split after implicit?
        def merge(map1: Map[K, V], map2: Map[K, V])(implicit
            b: BoundedSemilattice[V]
        ): Map[K, V] =
          map1 |+| map2
Anton Sviridov
@keynmol
Has anyone seen scalafmt producing different formattings on different platforms? I'm on my third round of battling Travis CI running on ubuntu and complaining about the formatting done by the same scalafmt version running locally on OS X :D
Tomasz Godzik
@tgodzik
@keynmol could it be an issue with line endings?
Anton Sviridov
@keynmol
@tgodzik you may have been right, but I don't have a confirmation - After selecting "LF" twenty times on the file in VS code I did end up with same scalafmt result :) Not sure if it's just regular IT magic or line endings were actually broken