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
nafg
@naftoligug:matrix.org
[m]
With -Xsource:3 and version = "3.0.0-RC6", at least in IntelliJ, the new as import rename syntax makes scalafmt fail
The error looks like
Scalafmt parse error (PlaidServerBase1.scala:210):
                    ; expected but => found
wait that's a weird message, what =>
oh sorry
Lots of different error messages depending on the selection etc.

8:09 PM    Scalafmt parse error (PlaidServerBase.scala:179):
                    } expected but identifier found

8:10 PM    Scalafmt parse error (PlaidServerBase.scala:179):
                    } expected but identifier found

8:13 PM    Scalafmt parse error (PlaidServerBase1.scala:179):
                    } expected but identifier found

8:14 PM    Scalafmt parse error (PlaidServerBase1.scala:210):
                    ; expected but identifier found

8:14 PM    Scalafmt parse error (PlaidServerBase1.scala:210):
                    ; expected but identifier found

8:14 PM    Scalafmt parse error (PlaidServerBase1.scala:210):
                    ; expected but => found

8:18 PM    Scalafmt parse error (PlaidServerBase1.scala:179):
                    } expected but identifier found
The import is on line 4, so those messages are far away from it, but changing it to => makes them go away
(That's from the IntelliJ event log)
nafg
@naftoligug:matrix.org
[m]
Weird, with Metals I get a more local error in the logs:
2021.08.03 20:22:09 ERROR scalafmt: /home/naftoli/dev/maaser/jvm/src/main/scala/maasertracker/server1/PlaidServerBase1.scala:4: error: } expected but identifier found
import com.plaid.client.response.{TransactionsGetResponse, Account as PlaidAccount}
                                                                   ^
nafg
@naftoligug:matrix.org
[m]
@kitbellew: Thanks! Setting the dialect to Scala213Source3 fixed it.
Bill Frasure
@swoogles

I have been experimenting with the awesome rewrite.scala3.insertEndMarkerMinLines config, and was wondering-
Is there any plan for an inverse operation?
Eg. rewrite.scala3.removeEndMarkerMinLines
So if a scope came in below that amount, and it already had an endmarker, the endmarker would be removed?

I'm finding it to be a common case that:

  • a function is long at some point
  • I execute scalafmt and get the endmarker
  • I later decompose the function, and it falls below the threshold set by insertEndMarkerMinLines
  • The endmarker remains
Tomasz Godzik
@tgodzik
We haven't thought about it, but that should possibly be doable, best to send in a feature request
12 replies
Dmitrii Naumenko
@unkarjedy

What do you think about removing dedicated setting for a significant indentation indent.significant and just using indent.main?
https://scalameta.org/scalafmt/docs/configuration.html#indentsignificant

It feels like braces presence shouldn't affect the indentation size.

E.g. it's not clear why adding additional line to a one-liner method should the indentation

version = 3.0.0-RC6
runner.dialect = scala3
indent.main=2
indent.significant=4
2 replies
Dmitrii Naumenko
@unkarjedy
image.png
Bill Frasure
@swoogles
@kitbellew Where should the documentation for Markdown formatting live?
Inside the includePaths Configuration section? It's sort've appropriate there, since that's what you need to alter to enable it, but it's also a bit unique in that you have to surround code with '''scala mdoc''', so it's not just plain Scala code.
1 reply
Megan Wachs
@mwachs5

hi folks, please direct me to the right forum if this is not the right place to ask... I am trying to write a rule that will align the = sign when calling something with a lot of parameters:

val foo = func (
  a = bar,
  bb = baz,
  ccc = cow
)

would become:

val foo = func (
  a   = bar,
  bb  = baz,
  ccc = cow
)

I tried

align.tokens.add = [
 ...
  {
    code = "=",
    owner = "Param"
  },

which seemed to have no effect... ideas?

Albert Meltzer
@kitbellew
Param (or, more correctly, Term.Param) is the type of parameter in function definition (so would work in def statements). you are talking about arguments to the function. you should use one of the tools mentioned in documentation (https://scalameta.org/scalafmt/docs/configuration.html#aligntokens), to figure out the parser type which contains these =.
Megan Wachs
@mwachs5
Ah, missed the "To find the owner part for a custom tree, look for its type prefix using ScalaFiddle Playgroud or AST Explorer." Thanks!
Bill Frasure
@swoogles

Hi all, scalafmt is currently giving me this function signature:

def perfectAnniversaryLodgingSafe(): ZIO[Has[
  System
], Nothing, Either[String, String]] =
  ???

Ideally, this would look like:

def perfectAnniversaryLodgingSafe()
  : ZIO[
      Has[System], 
      Nothing, 
      Either[String, String]
    ] =
  ???

But I would also settle for any variations that are less confusing than the current result.

This is my current config:

# This first config is the most relevant one I could find
newlines.beforeTypeBounds = unfold

version = 3.0.0-RC6
runner.dialect = scala3
maxColumn = 49
project.includePaths."+" = ["glob:**.md"]
verticalMultiline.arityThreshold = 0
optIn.configStyleArguments = true
comments.wrap = "standalone"
align.preset = more
comments.wrapStandaloneSlcAsSlc = true
newlines.source = unfold
newlines.forceBeforeMultilineAssign = any
newlines.topLevelStatementBlankLines = [
  {blanks {before = 0, after = 0, beforeEndMarker = 0}}
]
rewrite.rules = [SortModifiers, RedundantParens]
rewrite.scala3.removeOptionalBraces = true
rewrite.scala3.insertEndMarkerMinLines = 20

I've scanned the Config page pretty thoroughly and also searched for "Annotation", "Type Param", "Square bra", etc, but I can't find the silver bullet here.
Any suggestions?

2 replies
Megan Wachs
@mwachs5

I am trying to align // comments in case class definition, similar as described in this old fix (scalameta/scalafmt#1260).

case class Foo (
  val a: Int = 7, // an amazing int
  val bb: Boolean = false, // an amazing bool
)

I have alignment turned on for the : and = and it works, but it doesn't align the //. I am using align.more and added the :and = alignment tokens. I am using 3.0.0-RC6.

This is what I get:

case class Foo (
  val a : Int     = 7, // an amazing int
  val bb: Boolean = false, // an amazing bool
)

Is aligning the // something that should work given appropriate configuration? I tried using the AST explorers, but the // don't really show up in the AST, so not sure how to talk about them in this context.

8 replies
Albert Meltzer
@kitbellew
2 replies
Artsiom Miklushou
@mikla

Hi,
I have

version=3.0.0
runner.dialect = scala213

But scalafmt still replaces _ to * in imports and also => _ to as

Am I missing something or it is a bug? Because as I see in dialects
Scala213 dialect has these set to false

allowAsForImportRename 
allowStarWildcardImport
3 replies
Megan Wachs
@mwachs5
Is it expected that scalafmt will re-format long multi-line comments? E.g. re-breaking paragraph style text to make it wider? This was surprising to me, and I am concerned that some comments might get mangled. Is there a way to disable this? not seeing it looking at the docs/code/tests
6 replies
-/** Parameterizes the subsystem in terms of optional clock-crossings
-  *   that are insertable between some of the five traditional tilelink bus wrappers.
-  *   This class exists for backwards compatiblity reasons but could eventually be retired
-  *   in favor of manually filling in crossing types within each custom TLBusWrapperTopology.
+/** Parameterizes the subsystem in terms of optional clock-crossings that are insertable between some of the five traditional tilelink bus wrappers. This class
+  * exists for backwards compatiblity reasons but could eventually be retired in favor of manually filling in crossing types within each custom
+  * TLBusWrapperTopology.
   */
The above change is surprising to me. Is there a way to disable this in the conf rules?
Eric Peters
@er1c
Dumb question, how do you run scalafmtOnly inside an sbt shell? sbt:sbt-config-test-default> scalafmtOnly src/main/scala/default/HelloWorld.scala [error] Expected whitespace character [error] Expected '/' [error] scalafmtOnly src/main/scala/default/HelloWorld.scala [error]
never mind, I borked a config setting
Justin Reeves
@clutch-justin
okay this is weird, I added a sbt scalafmtCheck to CI, ran sbt scalafmt locally, commited all the changes, validated running sbt scalafmtCheck locally, then pushed...and scalafmtCheck failed in circleCI because it thinks one file isn't formatted
Eric K Richardson
@ekrich
Someone was saying IIRC that the plugin doesn't do the build files. Is the CI running the plugin or another scalafmt?
Justin Reeves
@clutch-justin
This isn't a build file, it's a random class in the middle of one of my projects. (it's not a random class, it's a specific one)
Eric K Richardson
@ekrich
Wow, weird.
Justin Reeves
@clutch-justin
is there verbose flag or something for why it failed?
Justin Reeves
@clutch-justin
ooh, I got it by changing the config
I changed align = more to align.preset = more
seriously, wtf
Justin Reeves
@clutch-justin
Does scalafmt change xml? Is it possible to omit *.xml or a directory?
Justin Reeves
@clutch-justin
Ah I think I found how to exlcude paths. https://scalameta.org/scalafmt/docs/configuration.html#project
Tomasz Godzik
@tgodzik
@clutch-justin scalafmt will not format xml, only the one contained in Scala files
crater2150
@crater2150:qwertyuiop.de
[m]
Hi, is it possible to disable vertical alignment for defs, without disabling it for vals? similar to the distinction made in newlines.forceBeforeMultilineAssign
crater2150
@crater2150:qwertyuiop.de
[m]
To answer my question from yesterday, this seems to do it:
align.tokens."+" = [
  { code = "=", owners=[{regex="Term.Param|Term.Assign"}] },
]
Hugo van Rijswijk
@hugo-vrijswijk
Is there an option I can use with scala213source3 that forces formatting to the new Scala 3 style? I noticed that it accepts new syntax, but doesn't write new formatting
Hugo van Rijswijk
@hugo-vrijswijk
Enabling rewrite.scala3.convertToNewSyntax almost works, but it also rewrites to Scala 3 vararg splices, which -Xsource:3 doesn't support
Albert Meltzer
@kitbellew
can you please submit a ticket in scalameta? that's where the dialect is defined, and enabled vararg splices
Hugo van Rijswijk
@hugo-vrijswijk
Isn't this a scalafmt thing, not scalameta? The scala213source3 dialect parses fine (and doesn't parse scala3 varargs, which is correct for 2.13 source3), but I want code to be reformatted to valid source3 syntax
3 replies
Tomasz Godzik
@tgodzik
@hugo-vrijswijk do Scala 3 vararg splice work with -Xsource:3 ? I should have been added with scala/scala#9584
heksesang
@heksenlied:matrix.org
[m]
Scala 3 varargs work fine with -Xsource:3def f(items: String*) and def g(items: Seq[String]) = f(items*)are perfectly valid with the option enabled.
heksesang
@heksenlied:matrix.org
[m]
But the question is about an option to make scalafmt rewrite Scala 2 syntax that is valid with Scala213Source3 dialect to Scala 3 syntax that is also valid with Scala213Source3 dialect. I am confused to why this should be related to the scalameta dialect?
3 replies
Adrian
@adrian-salajan
hello, i have an issue with scalafmt not seeing/formatting sources under src/it/scala, i have set project.includeFilters = [".*\\.scala$"]
Adrian
@adrian-salajan
i think i was missing
  .settings(
    inConfig(IntegrationTest)(ScalafmtPlugin.scalafmtConfigSettings)
  )
heksesang
@heksenlied:matrix.org
[m]
Ah, I see. Then it makes sense.