ktfmt icon indicating copy to clipboard operation
ktfmt copied to clipboard

Canonical .editorconfig

Open sgrimm opened this issue 4 years ago • 11 comments

This is kind of the opposite of #45 -- it'd be convenient to have a complete .editorconfig based on the plugin's current formatting rules, including editor-specific config properties for IntelliJ and any other editors people care to contribute.

Obviously this doesn't have to be generated by the plugin; it could be a hand-maintained file in the plugin source.

sgrimm avatar Dec 29 '20 20:12 sgrimm

Do you mean emit an .editorconfig from the plugin? or store one in the plugin that matches the plugin's config?

cgrushko avatar Dec 30 '20 07:12 cgrushko

Maintaining it as a standalone file people can download may be easier than making the plugin emit it on the fly, but either way would be useful.

Basically the idea is to make it easy to include editor settings in a project that uses ktfmt, such that the editor gets as close as possible to ktfmt's rules and ktfmt needs to make fewer changes. That's likely to be less error-prone than trying to tell people which editor settings to change manually.

sgrimm avatar Dec 31 '20 00:12 sgrimm

I assume the target audience is users using an IDE other than IntelliJ, since there's a ktfmt plugin for IntelliJ?

cgrushko avatar Dec 31 '20 08:12 cgrushko

The target audience I had in mind is actually IntelliJ users. To be clear, this is definitely a low-priority thing, but I'd want this for a few reasons:

  • My experience is that there's often one person on a team who ends up not running ktfmt before committing code for whatever reason, so having the editor produce mostly-ktfmt-style code to begin with means that the subsequent cleanup commit won't churn the file's blame history as much.
  • While I'm editing code, it's nice when the new code I'm typing looks similar to the existing ktfmt-formatted code. Otherwise I find myself hitting the Reformat hotkey pretty often to make everything line up.
  • It will serve as a kind of machine-readable documentation of ktfmt's formatting rules.

sgrimm avatar Jan 04 '21 17:01 sgrimm

Got it, thanks for clarifying! It sounds like it's possible to hand-write the file, or maybe export it from IntelliJ after tweaking its formatter?

On Mon, Jan 4, 2021 at 7:51 PM Steven Grimm [email protected] wrote:

The target audience I had in mind is actually IntelliJ users. To be clear, this is definitely a low-priority thing, but I'd want this for a few reasons:

  • My experience is that there's often one person on a team who ends up not running ktfmt before committing code for whatever reason, so having the editor produce mostly-ktfmt-style code to begin with means that the subsequent cleanup commit won't churn the file's blame history as much.
  • While I'm editing code, it's nice when the new code I'm typing looks similar to the existing ktfmt-formatted code. Otherwise I find myself hitting the Reformat hotkey pretty often to make everything line up.
  • It will serve as a kind of machine-readable documentation of ktfmt's formatting rules.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebookincubator/ktfmt/issues/158#issuecomment-754119645, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPH6YJW5I3D6FRZEFUWFH3SYH5ZZANCNFSM4VNR6JZQ .

cgrushko avatar Jan 04 '21 20:01 cgrushko

Here's a hand-tweaked export of my IntelliJ settings; it isn't too far off, I think, but I am not confident I've gotten everything right (certainly not confident enough to want to submit it as a PR, but if you like, I can do that.)

editorconfig.txt

sgrimm avatar Jan 04 '21 20:01 sgrimm

  1. A PR sounds great, even if it's not perfect, especially if there's a way to add this as a comment in the file.
  2. Is this for the default style or dropbox style?
  3. Should we name the file .editorconfig-ktfmt.txt or something like that? I want to emphasize that it's not used for the ktfmt project itself, but instead be downloaded and used in other projects. Maybe put it in a subdirectory? editorconfigs? but then it's less discoverable. Anyway, I'm open to ideas :)

On Mon, Jan 4, 2021 at 10:59 PM Steven Grimm [email protected] wrote:

Here's a hand-tweaked export of my IntelliJ settings; it isn't too far off, I think, but I am not confident I've gotten everything right (certainly not confident enough to want to submit it as a PR, but if you like, I can do that.)

editorconfig.txt https://github.com/facebookincubator/ktfmt/files/5766761/editorconfig.txt

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebookincubator/ktfmt/issues/158#issuecomment-754215347, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPH6YKKO4TKBCTFHBBTQC3SYIT3DANCNFSM4VNR6JZQ .

cgrushko avatar Jan 04 '21 21:01 cgrushko

Before closing this issue, should be great to add .editorconfig for all styles (Google and Kotlinlang).

Personally, instead of having only one file with comments to change from one style to another, I think should be better to have 4 files:

  • .editorconfig-default
  • .editorconfig-dropbox
  • .editorconfig-google-internal
  • .editorconfig-kotlinlang

JavierSegoviaCordoba avatar Feb 28 '21 08:02 JavierSegoviaCordoba

@sgrimm, could you work on what @JavierSegoviaCordoba proposed? I think that is a good idea.

@JavierSegoviaCordoba, if you feel adventurous and want to take a stab at this, I'd be happy to help ship it.

hick209 avatar Sep 15 '23 16:09 hick209

I should have time to have a crack at that this weekend.

sgrimm avatar Sep 15 '23 18:09 sgrimm

@sgrimm feel free to submit a PR when you have something

hick209 avatar May 03 '24 12:05 hick209

I found .editorconfig files for all code styles in https://github.com/facebook/ktfmt/tree/main/docs/editorconfig. Looks like this issue is done already?

darioseidl avatar Jun 19 '24 10:06 darioseidl

Looks like we do, we just need to clean up the dropbox one, let me do that

hick209 avatar Jun 19 '24 11:06 hick209