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
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
Eric K Richardson
@ekrich
@fanf42 Just as a datapoint, we went away from extra alignment in the lastest scalafmt update in Scala Native. We found that alignment increases the diff with only minor changes. For example: changing the above to secondParams: List[String], would adjust the lines above and below.
fanf42
@fanf42:matrix.org
[m]
@ekrich: shouldn't it be a decision of the user? If we like well aligned tokens and are happy with w=1 for ex? (rationnal: the diff is transitional, the resulting source code readability remains)
but thanks for the data point
(so one datapoint: I don't care for large diff, and I'm a bit psychopathic about valign. I also do understand that I'm in a tiny group, and so it's ok that scalafmt dev allocate their resources otherwise than to please me ;) Someday, I will have time to contribute to one more project...)
Eric K Richardson
@ekrich
It is up to you but for the most part the defaults are good and alignment over time creates extra churn that is all. Originally, scalafmt was pretty opinionated but has become very flexible - "that battle was lost" to quote the creator of scalafmt. My personal opinion is that most of formatting is just personal preference and consistency from repo to repo is nice but honestly just using scalafmt makes one less thing to think about which is its greatest benefit regardless of the settings.
Lots of people like the vertical alignment :smile:
3 replies
fanf42
@fanf42:matrix.org
[m]
interesting. Thanks for that feedback
Eric K Richardson
@ekrich
Mostly, software is about having fun, so whatever makes you happy - do that first. Exploring and learning are fun.
Yuriy Yarosh
@yuriy-yarosh

So, I'm using scalafmt with Scala3 right now and my imports are being rewritten from

import cats.effect.*
import cats.syntax.all.*
import org.http4s.blaze.server.*
import org.http4s.implicits.*
import org.http4s.server.*

import scala.annotation.internal.*

to

import cats.effect
import cats.syntax.all
import org.http4s.blaze.server
import org.http4s.implicits
import org.http4s.server

import scala.annotation.internal

How to make scalafmt leave .* suffix ?

I'm ok with rewritting ._ to .* though.

using default config

version = "3.0.0-RC6"
runner.dialect = scala3
preset = default
6 replies
Fabrizio Colonna
@ColOfAbRiX
Hi! Is there a way I can use scalafmt to have such formatting on the implicit parameters?
class MyService(
  param1: String,
  param2: String)(
  implicit
  param3: String,
  param4: String
) {
  ...
}
Albert Meltzer
@kitbellew
@ColOfAbRiX yes
Fabrizio Colonna
@ColOfAbRiX
ok :) I asked because I played a lot with newlines.implicit* and danglingParentheses but I can't make it work. Best I could do was to have the )( on the left of the implicit. Could you tell me what configuration should I use?
2 replies
Bill Frasure
@swoogles
Hey all, is there a timeline for getting scalafmt-dynamic_3 published for Scala 3?
If I'm browsing Maven correctly, it looks like the library is able to parse/format Scala 3 code, but can only be used from a Scala 2.13 project
Tomasz Godzik
@tgodzik
@swoogles there is no timeline at all, no plans currently for it as it would require a lot of work in the parser. And the parser uses a lot of macros, which are not supported in Scala 3
but you can still use 2.13 libraries from Scala 3
Tomasz Godzik
@tgodzik
maybe we could actually release scalafmt-dynamic itself, but it should work correctly when specifying 2.13 version explicitely
Bill Frasure
@swoogles
Thanks @tgodzik , just using the 2.13 lib is good enough for my purposes :)
Mariusz Wojakowski
@mariusz89016
hi there ;) I have one question about selectChains: there are docs about this config (https://scalameta.org/scalafmt/docs/configuration.html#newlinesselectchains) but IIUC it's unreleased. Is it possible that someone can publish that version? Many thanks! :)
Awethon
@Awethon

Hi! Can I somehow turn off formatting of unapply matching in my code?
Newlines take too much space.

I've tried binPack.unsafeCallSite = true and it seems that this parameter helps but I also need newlines.implicitParamListModifierPrefer in my config. Scalafmt can't run with both of them (yet?)

//before
x match {
  case MyCaseClass(_, _, _, _, _) => ??? //more than maxColumn
}

//after
x match {
  case MyCaseClass(
      _,
      _,
      _,
      _,
      _
    ) => ???
}
1 reply
Jack Koenig
@jackkoenig
Is there a way to add custom "keywords" in particular for the rule: spaces.afterKeywordBeforeParen
In my DSL we have when which is analogous to if and it'd be nice to space it the same way
Albert Meltzer
@kitbellew
@jackkoenig no
Jack Koenig
@jackkoenig
Thanks for your response!
Megan Wachs
@mwachs5
I am configuring scalafmt from within vscode... I know that I can use the scalafmt.configFilePath setting of VS Code to pick a particular configuration file, but in my vscode project I am dealing with several scala projects from different sources (open source libraries where I am also developing the source). Am I correct that in vscode, for a given workspace, you can only pick one scalafmt.configFilePath for anything you may be editing from within that vscode session? This could be problematic since if I am working on both library and user code at the same time, I would have to keep manually switching the scalafmt.configFilePath ... or is there another way? Can I set up vscode to use the most "local" .scalafmt.config for any particular file?
Eric K Richardson
@ekrich
The .scalafmt.conf in the root of each repo should be used so I would try not to set anything special in VSCode.
Assuming you have a window open for each project, but if using Metals that is probably what you are doing.
©︎ureれも:=ネ=>℃🐳
@curelemonade2_twitter

i try use scalafmt in dotty.
so failed format type lambdas syntax,

scala version: 3.0.1
scalafmt version : 3.0.0-RC6

format succes code:
abstract class Repository[F[_]: ({ type L[F[_]] = MonadCancel[F, Throwable] })#L,] {}
format failed code:
abstract class Repository[F[_]: [G[_]] =>> MonadCancel[G, Throwable]] {}

this code should be eqivalent. but failed.

little masked
[error] (******** / Compile / scalafmt) invariant failed:
[error] when verifying parentCheckOk.&&(org.scalameta.`package`.debug(this, parentPrefix, destination))
[error] found that parentCheckOk is false
[error] where TypeLambdaImpl = [G[_]] =>> MonadCancel[G, Throwable]
[error] where destination = cbounds
[error] where parentCheckOk = false
[error] where parentPrefix = Type.Param
[error] where this = [G[_]] =>> MonadCancel[G, Throwable]: **/**/***.scala
[error] Total time: 0 s, co

What should I fix?

4 replies
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