Open guizmaii opened 3 years ago
This behavior is controlled by the importsOrder
option. Setting it to SymbolsFirst
should produce the desired result.
BTW, Scala 3 support is still experimental and only available in master. Are you using some master snapshot version?
It solves the problem but creates another one:
IntelliJ organises these imports like this:
import io.circe.syntax.*
import io.circe.{Encoder, Json}
while with importsOrder
set to SymbolsFirst
, OrganizeImports
organize them this way:
import io.circe.{Encoder, Json}
import io.circe.syntax.*
Are you using some master snapshot version?
No, I'm using the latest published one.
Huh, interesting. Could you please share your IntelliJ configuration relevant to import organization? Specifically:
I suspect you are using the Scalastyle flavor? IIRC, Scalastyle uses a complicated sorting rule that I never quite understand...
Editor / Code Style / Scala / Formatter: Are you using "IntelliJ" or "Scalafmt"
@guizmaii, could you please also share your .scalafmt.conf
?
Here it is:
version = "2.7.5"
maxColumn = 140
align.preset = most
align.multiline = false
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
docstrings = JavaDoc
lineEndings = preserve
includeCurlyBraceInSelectChains = false
danglingParentheses.preset = true
optIn.annotationNewlines = true
newlines.alwaysBeforeMultilineDef = false
trailingCommas = preserve
rewrite.rules = [RedundantBraces]
rewrite.redundantBraces.generalExpressions = false
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}
@guizmaii, what I can confirm is that OrganizeImports
does not handle the Scala 3 *
wildcard properly when sorting imports. What OrganizeImports
does when SymbolsFirst
is used is to replace underscores and braces with \u0001
and \u0002
followed by a normal lexicographical sorting. The *
wildcard is not handled yet.
But I haven't figured out how exactly the result you hit was produced. Need some more time for this.
To add to this, removeUnused
doesn't work for imports that are specified using the *
wildcard.
Hi,
IntelliJ organises the imports this way:
while
OrganizeImports
organises them this way:Here's my scalafix config concerning
OrganizeImports
:I feel that IntelliJ is right on this one. What do you thing?