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
Rex Termandae
@rexad
@poslegm thanks will try
Siddarth
@siddarthkanted
Is it possible to configure scalafmt using .idea folder? So that IntelliJ scalafmt plugin gets automatically installed when code is imported in IDE.
Russell Teabeault
@rteabeault

Hello all. I have intellij 2019.2 and the following .scalafmt.conf file

version = 2.2.2
maxColumn = 100
includeNoParensInSelectChains = true

However, intellij popup error says Failed to read /Users/someuser/workspace/someproject/.scalafmt.conf. Invalid fields: includeNoParensInSelectChains
Any ideas?

Mikhail Chugunkov
@poslegm
@rteabeault your config works good for me. What scalafmt version is presented in File | Settings | Editor | Code Style | Scala?
Russell Teabeault
@rteabeault
@poslegm It shows 2.2.2. It is a Twitter version of intellij so I am suspecting our dev tooling team has done something to circumvent the normal scalafmt. I have opened a ticket with them to figure it out. Thanks!
Zoë Frances Weil
@wanderlustzoe
hey, how do I disable this format?
def foo = Bar(
 ...
)
any help appreciated! :sunflower:
instead of the above, i would like:
def foo = Bar(x =>
 ...
)
Mikhail Chugunkov
@poslegm

@wanderlustzoe I didn't understand first code sample. if it something like

def foo = Bar(
  x =>
 ...
)

then we have open PR scalameta/scalafmt#1551 for your request

Pär Wenåker
@parwen68
Hi, Anyone know how well scalafmt default settings are aligned the guidelines here https://docs.scala-lang.org/style/index.html?
Paul Cleary
@pauljamescleary
qq, is there anyway to make the search state exploded a warning instead of an error? I am trying to update from 1.x to latest of scalafmt
Eric K Richardson
@ekrich
It is not stopping the format is it?
Paul Cleary
@pauljamescleary
no, it doesn't stop the formatting, but it does report as error instead of warn
Eric K Richardson
@ekrich
That is a change I noticed too. There is a --quiet option and one to send std err to std out but not seeing much else.
przemyslaw wierzbicki
@pshemass
I'm trying to migrate from Intellij to scalafmt and I cannot find a way to configure scalafmt to newline after class/trait/object name to achieve something like below.
object A
  extends B
    with C
    with D  {

...
}
scalavision
@scalavision

Hi all, is there a way to create a scalafmt intance without using the classLoader?

val scalafmt = Scalafmt.create(this.getClass.getClassLoader)

I have a small project that generates scala code as text. I try to format it with scalafmt with scalafmt.format method, running the program in a sbt loop (save - compile -run).

The getClassLoader together with sbt creates a memory leak it seems. From googling, this seems to be a very bad bug that its not easy to get rid of ....

Minghao Liu
@molikto
@olafurpg hello, I am looking into applying a automate layouting algorithm to a structural/projectional editor, do you think the algorithm in rfmt a fit? It paper itself is a nice read, but I cannot find any demo/usage of that package.
Ólafur Páll Geirsson
@olafurpg
@molikto I would use something like https://github.com/typelevel/paiges instead of rfmt
the "wadler's prettier printer" seems to work nicely
Minghao Liu
@molikto
mind elaborate why? rfmt seems to be a newer work, and in your thesis I think you think it is a good algorithm
Ólafur Páll Geirsson
@olafurpg
@molikto I don't know much how rfmt has worked out in practice, the algorithm sounds great in the paper
the wadler pretty printer algorithm is used in prettier/refmt (reasonml)/paiges/...
I have used paiges and it's a great library
Minghao Liu
@molikto
@olafurpg according to this blog post, https://jyp.github.io/posts/towards-the-prettiest-printer.html Wadler's pretty printer doesn't have <-> combinator, but I am fine with this
Daniel Bimschas
@danbim

Hello everyone :). Is there a way to NOT have newlines for single case-statements as e.g. in:

configValues.toList.traverse { case (k, v) => /*…*/ }

Scalafmt currently always gives me sth. like this:

configValues.toList
  .traverse {
    case (k, v) => /*..*/
  }

Couldn’t find anything in the documentation.

Martijn Hoekstra
@martijnhoekstra
isn't that just a matter of max line length?
Daniel Bimschas
@danbim
no, line length is 180 and the statement is < 50 cols.
Yogesh Gupta
@incorrectusername

hi,
I'm trying to add scalafmt in existing project.
i only want to run scalafmt on changed lines(not complete file). how can i do this?

i tried scalafmt --mode diff and scalafmt --mode changed but they are formatting the complete file.
P.S: I want to add scalafmt in pre-commit hook.

Ólafur Páll Geirsson
@olafurpg
@incorrectusername there's no option to format changed lines, scalafmt only operates on complete files
Ólafur Páll Geirsson
@olafurpg
Manuel Cueto
@manuelcueto
Hi all! started looking into ScalaFmt yesterday and i'm looking forward to contribute. Have started with #1506 but i'm a bit stuck when trying to add an indent on a new line. (I'm still finding my way through the code.) Ideally i want to add a new line and then 2 spaces (or a tab) and i managed to get the NewLine but the following Split of Space (i assume that's what i need) it's not doing what i expected
Jason Pickens
@steinybot
Hi. I can’t seem to get scalafmt to format implicits like in the example here https://scalameta.org/scalafmt/docs/configuration.html#verticalmultilinenewlinebeforeimplicitkw

I have:

verticalMultiline.atDefnSite = true
verticalMultiline.newlineAfterOpenParen = true
verticalMultiline.newlineAfterImplicitKW = true

but I can’t get the newline before the parenthesis that close the implicit parameter list

Oh wait a second… it works on methods but not on the class
Jason Pickens
@steinybot

So this works for a method:

def format(
    code: String,
    age: Int
  )(
    implicit ev: Parser,
    c: Context
  ): String

Is it possible to get this for a class?

class Format(
    code: String,
    age: Int
  )(
    implicit ev: Parser,
    c: Context
  ) extends Foo {

Instead I get this:

class Format(
    code: String,
    age: Int
  )(
    implicit ev: Parser,
    c: Context)
    extends Foo

Which looks strange

Gavin Bisesi
@Daenyth
I have a question about config
I was on 1.5.1 and I'm upgrading to 2.3.0
and I have a lot of diff that
  • adds a newline after object X { before the first declaration in the object
  • indents newline-trailing type annotations more than before
example
 object Snapshot {
+
   implicit val circeEncoderSnapshot
-    : circe.Encoder[Snapshot] = deriveEncoder[Snapshot]
+      : circe.Encoder[Snapshot] = deriveEncoder[Snapshot]
(the real names are longer but the pattern repeats throughout the codebase)
git diff --shortstat
 1278 files changed, 32562 insertions(+), 20440 deletions(-)
my configs:
// scalafmt 1.5.1


style = default

maxColumn = 80
continuationIndent.callSite = 2
continuationIndent.defnSite = 4
align = some
align.arrowEnumeratorGenerator = false
align.openParenCallSite = true
align.tokens = [caseArrow]
assumeStandardLibraryStripMargin = false
docstrings = ScalaDoc
newlines.alwaysBeforeTopLevelStatements = true
newlines.sometimesBeforeColonInMethodReturnType = true
binPack.parentConstructors = true
lineEndings = unix
includeCurlyBraceInSelectChains = true
optIn.breakChainOnFirstMethodDot = true
optIn.annotationNewlines = true
newlines.penalizeSingleSelectMultiArgList = true
binPack.literalArgumentLists = true
runner.optimizer.forceConfigStyleOnOffset = 150
rewriteTokens = {"⇒":"=>","←":"<-"}
rewrite.rules = [RedundantBraces, PreferCurlyFors]
I've made minimal changes to that config so far (only trailingCommas = preserve I think)
I've been looking at the config docs and diving into ScalafmtConfig and related but I can't figure it out yet how to prevent these diffs
Gavin Bisesi
@Daenyth
it looks like the annotation one is maybe #1336 ?
I don't disagree with the change but if someone runs scalafmt on the whole codebase it's going to be a bad time..
maybe I can leave it to trickle through commits as people touch files?
Gavin Bisesi
@Daenyth
edition doesn't seem to help so far.. let me try a 2018 value
still doesn't prevent it