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
jaacko-torus
@jaacko-torus
I might have missed it, but is there a way to indent using the tab character instead of spaces?
1 reply
ex0ns
@ex0ns

I'm having some issue upgrading to 3.3.0, the alignment

       case iaEx: IllegalArgumentException => errorFuture[Seq[User]](IllegalArgument(iaEx.getMessage))
-      case e: Exception                   => errorFuture[Seq[User]](UnexpectedError(s"Unexpected error: ${e.getMessage}"))
+      case e: Exception => errorFuture[Seq[User]](UnexpectedError(s"Unexpected error: ${e.getMessage}"))

It's not aligned on the arrow anymore =>and I don't know what changed

5 replies
LUC DUZAN
@strokyl
Hello everybody, is there a way to forbide X with Y and replace it by X & Y (new scala 3 syntax for intersection type)
Peng Cheng
@tribbloid

My VSCode extension doesn't do parsing.

Instead it just show the error message : ""identifier expected but import found" scalameta"

Like the below screenshot

Screenshot from 2022-01-29 02-30-31.png
what's the problem?
Peng Cheng
@tribbloid
found the problem: scalameta/metals#2595
Prateek Asthana
@prateeka

how do i ensure block-comment line-breaks are respected? For example, below original code:

  /**
    * General description:
    * 1. point 1
    * 2. point 2
    */

after formatting becomes

  /** General description:
    *   1. point 1 2. point 2
    */

instead, i would like to continue having line-breaks like the original code.

my scalafmt.conf is:

runner.dialect = scala3
version=3.4.0

i am using Intellij 2021.3.1

3 replies
Martin Allaire
@mallaire77

Hello, is there a way to always apply new line on any def/val, like

val test = Test("Hello World")

to

val test =
  Test("Hello World")
1 reply
Anne
@AnneThor
Hello! I am wondering what the effect of setting runner.dialect=scala213 is in comparison to scala212 or scala211, does this mean basically to parse everything as scala 2.13 and flag anything incompatible? What would the real differences be in terms of formatting?
Matthew de Detrich
@mdedetrich
Does anyone know what happened with the unindentTopLevelOperators that was removed in Scalafmt 3.0 and if there is an equivalent setting?
Albert Meltzer
@kitbellew
@mdedetrich it was mentioned on the releases page
Matthew de Detrich
@mdedetrich
@kitbellew Can you provide the text? I tried looking for it and couldn't find a mention of it at https://github.com/scalameta/scalafmt/releases/tag/v3.0.0 or in the changelog https://scalameta.org/scalafmt/docs/changelog.html
2 replies

Or is

newlines.topLevelStatementBlankLines meant to be the replacement?

Matthew de Detrich
@mdedetrich
(and if so do you know the specific settings for newlines.topLevelStatementBlankLines which is equivalent to the old unindentTopLevelOperators)
Oliver Schrenk
@oschrenk

How would I force rewrite if/else blocks to always have braces?

# original
if(cond)
  foo()
else
  bar()

# formatted
if(cond) {
  foo()
} else {
  bar()
}

If found scalameta/scalafmt#1463 but it was closed in Oct 2020.

Albert Meltzer
@kitbellew
@oschrenk it's described in the documentation
desophos
@desophos
Hi, is it possible to force a line break after the open brace and before the close brace of a for comprehension with newlines.source = fold? Example: https://gist.github.com/desophos/19d53e9019ca78bb5adc01ac660f0f1c
2 replies
I couldn't find any mention of this in the documentation or github issues
Steve Jones
@sjfloat
I clobbered my version of scalafmt (and scala and scalac) with coursier and it's not obvious how to get back to 2.13.1
Maybe it's more of a coursier question. Is there a better channel for that?
Giovanni Sciavicco
@Benevole_gitlab

What's the deal with single newlines being all over the place in case of i.e. method definitions (not sure what's the proper expression in scalafmt language)???

This makes the code look like shotgun edited and IMHO not exactly too readable. This creates confusion when a .scala file has more than one method. See this:

    alignment = Pos.CenterRight

    style = borderStyle

  def createProgressPanel(): Node = new HBox(6):

    val slider = new Slider()

    val progressIndicator: ProgressIndicator = new ProgressIndicator():
Albert Meltzer
@kitbellew
@Benevole_gitlab if you believe there's a problem, please submit an issue on GitHub, with all the necessary information requested
tpetillot
@tpetillot

Hi folks!
Any configuration to prevent following formatting:

/*
 *   1. xxxxxxxxxxxxxxxxxxxxxxx
 *   2. yyyyyyyyyyyyyyyyyyyyyy
 *   3. zzzzzzzzzzzzzzzzzzzzzzzz
 */

// into

/*
 *   1. xxxxxxxxxxxxxxxxxxxxxxx 2.  yyyyyyyyyyyyyyyyyyyyyy 3. zzzzzzzzzzzzzzzzzzzzzzzz
 */

Thanks!

Oron Port
@soronpo
@tpetillot If you want enumeration, you need write
/*
 *   1. xxxxxxxxxxxxxxxxxxxxxxx
 *   1. yyyyyyyyyyyyyyyyyyyyyy
 *   1. zzzzzzzzzzzzzzzzzzzzzzzz
 */
Scaladoc should figure out the proper enum
I recently experienced this myself. Maybe there is a way to turn it off.
I must admit that I don't really like this. If we look at the code raw, then we see all bullets with the same number. This is highly annoying, IMO.
tpetillot
@tpetillot
Sad... I'll use it that way until fixed... thanks for the tip @soronpo
Albert Meltzer
@kitbellew
@tpetillot i will assume you used /** (and not /*). if you read https://docs.scala-lang.org/overviews/scaladoc/for-library-authors.html#other-formatting-notes, you will see that in scaladoc, you don't write actual numbers, you use a label to indicate what numbering/bulleting type should be used when this scaladoc is output. scaladoc is a markup language, not intended for reading in .scala but when it's output as .html.
if you wish to write arbitrary text in code, then either use /* or set docstrings.wrap = no.
Alex Cameron
@ac27182

Our team uses the scalikejdbc library quite heavily, and as a team we would like to preserve the existing style of the queries we write.

However we cannot find the right configuration keys to toggle which would give us more flexibility with the method chaining in the scalafmt configuration

Does anyone in this channel have any suggestions?

Below is an example of the style we would like to maintain, and what we want to avoid

// existing style
select
  .from(Table1 as t1)
  .innerJoin(Table2 as t2).on(sqls.eq(t2.someKey, t1.someKey))
  .innerJoin(Table3 as t3).on(sqls.eq(t3.someKey, t2.someKey))
  .where(???)
...
// what we wish to avoid
select
  .from(Table1 as t1)
  .innerJoin(Table2 as t2)
  .on(sqls.eq(t2.someKey, t1.someKey))
  .innerJoin(Table3 as t3)
  .on(sqls.eq(t3.someKey, t2.someKey))
  .where(???)
...
Albert Meltzer
@kitbellew
@ac27182 try source keep
Alex Cameron
@ac27182
@kitbellew I'll check it out thank you
Roberto Leibman
@rleibman
I'm seeing this error on a scala3 project (i.e. using runner.dialect = scala3):
[error] org.scalafmt.dynamic.ScalafmtDynamicError$ScalafmtInterfaceMethodDeprecated: Method Scalafmt.withRespectVersion is deprecated
[error]     at org.scalafmt.dynamic.ScalafmtDynamic.withRespectVersion(ScalafmtDynamic.scala:62)
2 replies
Giovanni Sciavicco
@Benevole_gitlab
Any suggestion on what's going on as I'm using scalafmt with IntelliJ and since few days the scalafmt behaves "eagerly" and formats strings by removing any white spaces on the fly as I start typing new text on comments or on actual code. And this takes place even if I set // format:off. Similarly autosuggestions are not beign picked as I type and choose a suggestion with Tab key. I had to switch scalafmt off on IntelliJ and problem solved, but not a real solution here. Anybody else sen this?
3 replies
Prateek Asthana
@prateeka
i want to have all the imports at the top instead of being close to the point of use. Any pros or cons about either of the approaches? And if at the top sounds good, what is the scalafmt configuration to achieve this?
Odomontois
@Odomontois

is there any possibility not to break derives section if it's short enough i.e

    @SnakeCase case class Document(
        @Rename("documentId") id: UUID,
        issueDate: Instant,
        @Embed author: Person,
    ) derives Config,
          ConfiguredDecoder

to be kept as

    @SnakeCase case class Document(
        @Rename("documentId") id: UUID,
        issueDate: Instant,
        @Embed author: Person,
    ) derives Config, ConfiguredDecoder
Chuong Ngo
@cngo-github
Hi all. I am looking to disable scalafmt for an individual line. I tried adding the comment // scalafmt:ok but running sbt runLinter still pops the error. What am I doing wrong?

The error is error: ] expected but double constant found. The code in question is

type RefinedDouble = Double Refined Interval.Closed[-5, 5]

It looks like the - in -5 is the problem.

Adrian
@adrian-salajan
hello, whenever I run scalafmt, the trailing white space of a team mate get removed but I can't find any config property to deal with trailing whitespaces - what am I missing ?
Stacy Curl
@stacycurl
Hello, does scalafmt have an ast that can be used to generate code ?
Albert Meltzer
@kitbellew
@stacycurl you can use the same parser which is underlying the formatter, scalameta
Stacy Curl
@stacycurl
Thanks
davidvirgilnaranjo
@davidvirgilnaranjo

Hello,

I am trying to modify the behaviour of my current scalafmt. This is the piece of code I have:

                else if (
                  req.getAccountType == "very long stringggggggggggggggggggggggg"
                  && wallet == ""very long stringggggggggggggggggggggggg""
                )
3 replies
Is it possible to put the first condition in the same line of the if(

I have another question:
In intellij enterprise edition the formatter works when I select all the file and click in Code/reformat code
But if I select one for example this line:

  case class AAA(a: String, b: String, c: String, d: String)

If I try to reformat this line selecting it and clicking on Code/Reformat Code, it is not doing anything.

2 replies
Cédric Chantepie
@cchantep

Hi, I have some trouble with fileOverride seemingly not working. scalafmtAll raised an error on Scala 3 test sources, showing it uses the default dialect Scala213Source3 whereas according fileOverride in configuration, the scala3 dialect should be applied.

...
[error] org.scalafmt.sbt.ScalafmtSbtReporter$ScalafmtSbtError: scalafmt: /home/runner/work/anorm/anorm/core/src/test/scala-3/TestUtils.scala:7: error: [dialect scala213source3] ; expected but : found
...

Testing the glob expression in bash, the file mentioned in the error is matching :

$ shopt -s globstar

$ ls **/src/*/scala-3/**/*.scala | grep TestUtils
core/src/test/scala-3/TestUtils.scala

Any hint?
Or I will create an issue.

1 reply
davidvirgilnaranjo
@davidvirgilnaranjo

Hello community,

I have a question related a case class:

  case class Balance(
    walletType: String,
    currency: String,
    amount: BigDecimal,
    available: BigDecimal)

I would like this case class to be formatted multiline when it is super long that it exceeds the max columns, but in case it can fit in one line to stay in one line. Is it possible?

5 replies
kailashk24
@kailashk24

Dear Community members, can any one please guide me how to solve below issue ?

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1000m; support was removed in 8.0
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 1.8.0_171)
[info] loading settings for project ABC_project from plugins.sbt ...
[info] loading project definition from H:\ABC_Project\project
[info] loading settings for project root from build.sbt ...
[info] set current project to ABC_project (in build file:/H:/ABC_project/)
[info] Formatting 51 Scala sources...
[error] failed to download v=3.5.9: H:\ABC_Project\.scalafmt.conf
[error] (ABC_project / Compile / scalafmt) failed to download v=3.5.9: H:\ABC_Project\.scalafmt.conf
[error] Total time: 13 s, completed 17-Aug-2022 16:09:57

Versions used

SBT --> 1.6.2 v
Scala --> 2.12.14