<@U015SPKL744> would you be interested if I contri...
# ktfmt
s
@Nivaldo H Bondança would you be interested if I contributed a "custom" style setting for the IJ plugin, to set the few parameters available? This way one could align the style to @gammax's Gradle plugin.
c
Why does the gradle plugin have those settings? I think not having settings is a great plus of ktfmt
👍 1
s
I honestly appreciate having two settings (indent and line size) and two flags (maintain trailing commas and remove unised imports)
n
What do you mean by "custom" here? If just expose the configurations that we already have in the formatter, then that should be fine. If creating a new style, then I'd want to understand more about what you mean
s
I mean adding an item to the combobox that says "custom" and lets you set: • Indent size [number] • Continuation Indent [number] • Manage trailing commas [checkbox] • Remove unused imports [checkbox] All existing stuff, that is exposed by the Gradle plugin too 🙂
g
If just expose the configurations that we already have in the formatter, then that should be fine.
That’s what the Gradle plugin does basically
So I’m fine with it as the API surface of ktfmt is unchanged
s
Yeah I have no intention to add or change anything in the core module, only expose what's there already
n
Sounds like a great idea to me as well!
Thank you so much for all your contributions, @seb 😃
👍 1
s
Happy to help 🙂
❤️ 2
Hopefully it makes it into 0.52
@gammax you have probably seen some of that logic in Detekt already. Turns out tooling has recurring problems 🙂
g
Such a small world 😂
😄 1
n
@seb do you happen to know if there's a good way to share those IJ configurations with other people?
If not possible, then we're actually inclined to reject the proposal as this would not really help on the goal to reduce bikeshedding discussions since one person could have a particular configuration while another would have something different (in the same repo)
s
You just need to not ignore .idea/ktfmt.xml
🤔 1
n
That's actually not too bad. Not ideal since this tends to be an ignored file for most
.gitignore
configs that basically ignore everything under
.idea
, but at least it is not hard to do like some other configs that live in other places. TBH we were going to reject it with a similar message that I wrote here, but since you shared that this can be shared a bit more easily than I expected, I am reconsidering it now with the team
s
Thanks :) And yes in general people tend to ignore the idea folder, but several files in there should not actually be... It's one of my crusades 😁
Oh another thing you could do is to have your own config file that all plugins/cli can read. The plus is that the IDE and build plugins configs won't get out of sync, the cons is that you need to maintain the logic to handle that file (and, you have a config file, which... dunno, feels weird)
Ktlint piggybacks editorconfig, which is another solution
But then you'd need proprietary extensions to manage the two Boolean config flags
c
I think that nicely shows that a really simple added feature can introduce a cascade of complexity.
👍 1
s
Well, the main takeaway here is that you can get 95% of the way there by simply not ignoring .idea/ktfmt.xml — but if you want the extra 5%, you explode complexity
And to be clear, I am against exploding complexity for that last 5%, but very much in favor of being able to set up the IDE plugin the same way as the Gradle one
c
One thing that would be great is if the gradle and idea plugin read the same config. So maybe it should be only in .editorconfig and no config in the gradle file and also not in .idea.
👍 1
s
Leaving to the team to decide how best to proceed on that. Not a call I can make 🙂 I agree it'd be nice, but then you also need to make sure the CLI also picks it up
g
And yes in general people tend to ignore the idea folder, but several files in there should not actually be... It’s one of my crusades
Agree. Ignoring the whole
.idea
is an antipattern
❤️ 1
n
One thing that would be great is if the gradle and idea plugin read the same config.
This seems like it would be an awesome change
If we go that route, we should try to kick other configurations out though, to make sure there's a single and simple source of truth. Maybe even failing ktfmt if there's an attempt to have multiple source of truths, like
.editorconfig
that does not match with input CLI params or something like that
👍 1
💯 2