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
heksesang
@heksenlied:matrix.org
[m]
Can I specify snapshot versions in the .scalafmt.conf file, or do I have to do something else to make it work with snapshots? Didn't really understand the instructions on the site in regards to snapshot versions last time I looked at it.
Tomasz Godzik
@tgodzik
This might actually work via Metals
I think you would need to add cpoursier repositories setting
export COURSIER_REPOSITORIES="ivy2Local|central|sonatype:snapshot" or in Metals setting
if used in metals settings it should be avialable when Metals tries to download the specific version
Tomasz Godzik
@tgodzik
seems it doesn't work :/
and use the created binary to run scalafmt
afterwards it should be cached lcoally so MEtals would be able to pick that up
Bill Frasure
@swoogles
Hey all, I've got a project where markdown files include fenced Scala snippets.
Is there any sort of standard approach for applying scalafmt to those snippets and altering them in-line?
Or is that not a proper use case for scalafmt, and it's really intended for .scala files only?
heksesang
@heksenlied:matrix.org
[m]
For Scala 3 files it seems that a line break is being forced before the extends part of each case in enum-definitions.
2 replies
Tomasz Godzik
@tgodzik
@heksenlied:matrix.org do you have an example? I would like to confirm it with the recent fixes
We'll release RC2 most likely this week
heksesang
@heksenlied:matrix.org
[m]

Seems your sample file does exactly that:

case Mercury
      extends Planet(
        3.303e+23,
        2.4397e6
      )

instead of:

case Mercury extends Planet(
  3.303e+23,
  2.4397e6
)
Tomasz Godzik
@tgodzik
in the example it breaks it like that due to column limit
since the full definition will not fit within 40 character column limit, we break it into multiple lines. That's the same behaviour as for classes
heksesang
@heksenlied:matrix.org
[m]
Okay, so my example there cannot be achieved as it is now?
Tomasz Godzik
@tgodzik
from what I know, not currently, but there might be some setting that I have no idea about
Tomasz Godzik
@tgodzik
btw. I haven't noticed before, but this seems to be fixing your issue: scalameta/scalafmt#2452
@heksenlied:matrix.org
heksesang
@heksenlied:matrix.org
[m]
Nice, now we just need to get that merged and release a 3.0.0-RC2 soon. :D
Tomasz Godzik
@tgodzik
@/all new release is out! We've managed to fix a number of issues connected to Scala 3, there are new rewrite rules to help out turning your code into actual Scala 3 code and a bunch of other improvements. Please check it out and report any issues that pop up. If nothing major is reported we will most likely make the final 3.0.0.
Tomasz Godzik
@tgodzik
By turning your code into actual Scala 3 I meant removing deprecated syntax
heksesang
@heksenlied:matrix.org
[m]
I assume everyone understands that, because if it was understood as anything else it would mean that scalafmt is pure magic. :P
Bill Frasure
@swoogles
Re-asking-
Hey all, I've got a project where markdown files include fenced Scala snippets.
Is there any sort of standard approach for applying scalafmt to those snippets and altering them in-line?
Or is that not a proper use case for scalafmt, and it's really intended for .scala files only?
1 reply
Hugo van Rijswijk
@hugo-vrijswijk
Is there a (rewrite) rule to format import x.{Y}to import x.Y for single-item imports?
3 replies
I can't find one in the configuration. Would it be a welcome addition?
Tomasz Godzik
@tgodzik
@swoogles you could use mdoc in that case with a custom string modifier that would invoke scalafmt
I think scalafmt itself does soemthing similar
thoguh, more complciated than that
@hugo-vrijswijk RedundantBraces maybe ?
heksesang
@heksenlied:matrix.org
[m]

Currently I am seeing:

inline def summonConfigReaders[T <: Tuple]: List[ConfigReader[_]] =
  inline erasedValue[T] match {
    case _: (h *: t) =>
      inline erasedValue[h] match {
        case _: Tuple => deriveForTuple[h & Tuple] :: summonConfigReaders[t]
        case _ => summonInline[ConfigReader[h]] :: summonConfigReaders[t]
      }

    case _: EmptyTuple => Nil
  }

being corrected to:

inline def summonConfigReaders[T <: Tuple]: List[ConfigReader[_]] =
  inline erasedValue[T] match {
    case _: (h *: t) =>
        inline
      erasedValue[h] match {
        case _: Tuple => deriveForTuple[h & Tuple] :: summonConfigReaders[t]
        case _ => summonInline[ConfigReader[h]] :: summonConfigReaders[t]
      }

    case _: EmptyTuple => Nil
  }
With 3.0.0-RC2.
Ishan Shah
@nullptr7
Intellij attempts to download the scalafmt jars from the public internet and the firewall in our org doesn't allow that. We do have scalafmt within our internal maven repository though. Is there any way we can point the Scala plugin to use a local scalafmt jar, or tell it what maven repo to download it from? Thanks
Tomasz Godzik
@tgodzik
@heksenlied:matrix.org that's a known issue
Alexandru Nedelcu
@alexandru

Hi all,

Any ideas how to fix this formatting issue? (at .via)

Flow[(A, Ctx)].map {
  case (a, ctx) =>
    rn.unsafe.logger.infoWithContext(logMsg)
    (a, ctx)
}
  .via(self)
  .map {
    case (b, ctx) =>
      rn.unsafe.logger.infoWithContext(logMsg)
      (b, ctx)
  }

I want those method calls to be on the same level. Something like this would be acceptable:

Flow[(A, Ctx)]
  .map {
    case (a, ctx) =>
      rn.unsafe.logger.infoWithContext(logMsg)
      (a, ctx)
  }
  .via(self)
  .map {
    case (b, ctx) =>
      rn.unsafe.logger.infoWithContext(logMsg)
      (b, ctx)
  }

It's fine that Scalafmt wants that .map on the same line, except when I have method chaining like this.

1 reply
Could it preserve my newlines somehow?
Tomasz Godzik
@tgodzik
@alexandru maybe newlines.source=unfold would help? Though that can influence other places
Kirill Shelopugin
@Z1kkurat

Hi everyone! I suppose there's a setting that controls the vertical alignment of case classes' named fields during their instantiation so

MyCaseClass(
  a = xxx,
  abc = yyy
)

Turns into

MyCaseClass(
  a   = xxx,
  abc = yyy
)

But I couldn’t find one. align.preset = most doesn’t seem to do the trick.
Tried 2.7.1, 2.7.5 and 3.0.0-RC2
The whole config is

version = 3.0.0-RC2
align.preset = most
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
danglingParentheses.preset = true
indentOperator.preset = spray
maxColumn = 150
newlines.alwaysBeforeTopLevelStatements = true
project.excludeFilters = [".*\\.sbt"]
rewrite.rules = [RedundantParens, SortImports]
spaces.inImportCurlyBraces = false
unindentTopLevelOperators = true
Albert Meltzer
@kitbellew
Кирилл, the scalafmt configuration documentation section on align tokens contains a link to a widget which allows you to parse code using scalameta and find the tree which "owns" your desired alignment delimiter (and change the align.tokens setting appropriately). Try using it; it should be something like Term.Param or Ctor.Primary in your case.
nscarcella
@nscarcella
Hi everyone, I hope this is the right place to ask...
I'm trying the Scala 3.0.0 release and wanted to configure scalafmt in my working environment (VSCode + Metals), but the formatting action does not seem to have any effect. I updated the target scalafmt version to 3.0.0-RC2 and tried to manually run it from the console, but I see it throws errors when I use the new features (for example, defs in the package level), which makes me suspect I'm doing something wrong.
I'm not very familiar with Scala dev tools so if anybody could point me in the right direction I would be very grateful.
Tomasz Godzik
@tgodzik
@nscarcella what kinds of issues are you having? Formatting should work fine, the only problem might be that I haven't managed to be release Metals for 3.0.0 yet, but I am working on it today
nscarcella
@nscarcella

Hi @tgodzik, first time I saved VSCode offered me to create the .scalafmt.conf file (which makes me believe that the format action is getting trigger and tries to use scalfmt), but I tried a couple of settings and no rule seems to be aplied.
I updated the created .scalfmt.conf to this:

version = "3.0.0-RC2"
align.preset = more
maxColumn = 80

But saving or manually running the format document task seem to cause no effect.
I tried to manually run scalafmtfrom the console, but I get what looks like parsing errors that makes me suspect scalafmt is not supporting scala 3.0.0-RC3 version:

.../src/main/scala/fireworks/FireworksRunner.scala:18: error: expected start of definition
@main def run(): Unit =
      ^
.../src/test/scala/fireworks/FireworksSuite.scala:7: error: ; expected but , found
class FireworksSuite extends FunSuite, FireworksGenerators:
                                     ^
.../src/test/scala/fireworks/FireworksGenerators.scala:6: error: ; expected but : found
trait FireworksGenerators:
                         ^
.../src/main/scala/fireworks/Fireworks.scala:16: error: ; expected but : found
object Firework:
               ^

I thought that maybe scalafmt is failing the task and metals is just silently failing because of that.

Vadim Chelyshov
@dos65
@nscarcella you also need to add runner.dialect = scala3 in .scalafmt.conf
nscarcella
@nscarcella
@dos65 Aha! That was it! Thanks a lot!
nscarcella
@nscarcella
Aaand, of course there was a section explaining this in the documentation... I didn't want to dive into the rules until the setup was working so I completely missed the section. Should have been more thorough... Sorry and thanks again.
nscarcella
@nscarcella
Hey guys, small question: Is there a way to preserve more than one consecutive empty lines in the source? I've tried newlines.source = keep and it seems to maintain single empty lines, but whenever I try to add a two-line space between classes it drops one on them.
1 reply