-
Notifications
You must be signed in to change notification settings - Fork 22
Add preset styles, including one for IntelliJ IDEA 2020.3 #154
Conversation
826b8f1
to
7cd5c8a
Compare
Codecov Report
@@ Coverage Diff @@
## branch-0.5 #154 +/- ##
==============================================
+ Coverage 91.20% 91.63% +0.43%
==============================================
Files 4 4
Lines 250 263 +13
Branches 9 7 -2
==============================================
+ Hits 228 241 +13
Misses 22 22
Continue to review full report at Codecov.
|
@sideeffffect, based on our previous discussion, I made this PR to ensure both IntelliJ compatibility and backward compatibility. The I plan to have this in v0.5.0 if it looks good to you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job @liancheng! 👍
What do you think about making INTELLIJ_2020_3
the default style? I presume that you didn't make it the default because you don't want to break current scalafix-organize-imports
users (I'm one of them :) ). That is a respectable decision.
But my humble suggestion would be to be bold and change the default to INTELLIJ_2020_3
even though it's a breaking change. This plugin is still 0.x
, so you have license to do that. The migration story for current users would be fair, they would either reformat their code-base (a simple, automated task) or set their configuration to preset = OLD_STYLE
(or something like that). The benefit would be great: less configuration needed for scalafix-organize-imports
. Now I'm not only thinking about the current users, but also about the soon to be converts that are not users yet. My belief is that most people don't care what the import organization is, as long as it is in harmony with IntelliJ, which is the most used Scala IDE after all.
groupedImports = GroupedImports.Merge, | ||
groups = Seq( | ||
"*", | ||
"---", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what ---
means, but I assume you know what you're doing 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1606966
to
3591d80
Compare
@sideeffffect, thanks for the feedback! I thought about making
|
@liancheng I see your points 👍 Having @niktrop @pavelfatin Would it be thinkable that IntelliJ would change (again) the defaults, to be closer to that of |
Hi! Thanks for inviting us. We'd be happy to work together. Having a reasonable common default style is important not just for each particular tool, but for all Scala programmers. We agree that wildcard imports are problematic. We will update the style to coalesce neither import statements nor grouped imports into a wildcard. This will apply to newly added imports and won't affect already existing ones, at least but default. On your part, it would be great if you update the sorting of groups to match the IDEA's one :) There are probably more projects formatted in this style. Besides, there are arguments why that particular sorting order may make sense in general (https://blog.jetbrains.com/scala/2020/11/26/enhanced-package-prefixes/). All in all, deciding on the default style is not an easy task, many things should be taken into account, including: writing code, reading code, the possibility of automatic optimizations, interaction with VCS, existing projects, widely accepted variants, interaction with other language constructs, well-knows recommendations, possible downstream (butterfly) effects, etc. BTW, how about we invite ScalaCenter, so that we can collectively work out a "standard" import style, as a part of https://docs.scala-lang.org/style ? (Feel free to join https://gitter.im/JetBrains/intellij-scala so that we can discuss the details in a more interactive way.) |
Hey @sideeffffect and @pavelfatin, thanks for the feedback and sorry for the late reply, have been quite busy with daytime work recently. +1 for adjusting the default value of the Inviting ScalaCenter is also a great idea! Let me find some time to start a GitHub discussion thread here. I don't have a specific list of names to invite, though. Maybe @olafurpg and @mlachkar are willing to join and/or suggest candidates? |
We've asked about the best way to approach the task in Slack | intellij | ScalaCenter channel. |
@pavelfatin, cool, is it a public channel? Had a try but couldn't find it. |
@liancheng That's a private channel, sorry. But I've essentially just copy/pasted the above text. The point is that we've reached out to ScalaCenter :) |
This PR tries to address the backward-incompatible changes introduced in PR #143 and #146 by adding preset import organization styles. Now, users may configure
OrganizeImports
by choosing and overriding one of two preset styles using the newly introducedpreset
option. Two preset styles are available:DEFAULT
The default style:
INTELLIJ_2020_3
A style that is more consistent with the default configuration of the IntelliJ 2020.3 Scala import optimizer:
Users can override individual configurations to fine-tune the style, e.g.: