Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Intellij built-in code formatter #8

Closed
mlthlschr opened this issue Oct 19, 2020 · 5 comments
Closed

Use Intellij built-in code formatter #8

mlthlschr opened this issue Oct 19, 2020 · 5 comments
Assignees
Milestone

Comments

@mlthlschr
Copy link

mlthlschr commented Oct 19, 2020

It would be great to integrate the plugin with the built-in code formatter (CTRL-ALT-L). This would not only be easier regarding the shortcut, but would also give the possibility of checking "reformat code" when commiting code and reformat it automatically.

As an example, the plugin of prettier in the world of javascript is capable of doing so.

@mlthlschr mlthlschr changed the title Using Intellij inbuilt code formatter Use Intellij built-in code formatter Oct 19, 2020
@nbadal nbadal added this to the 0.5.0 milestone Oct 19, 2020
@nbadal
Copy link
Owner

nbadal commented Oct 19, 2020

Good idea! And thanks for the example link!
I'll take a look at the viability of this for the next update (0.4.0 is being submitted today) :)

@nbadal nbadal self-assigned this Oct 19, 2020
@nbadal
Copy link
Owner

nbadal commented Oct 19, 2020

Implemented here 😁
a8f08eb

Be wary though, even with "Reformat" during a commit, not all ktlint rules are auto-fixed by the tool itself. Some need to be manually fixed, such as no-wildcard-imports for example

@mlthlschr
Copy link
Author

Wow, that was quick! :-D Thanks for that, I am going to take a look at it.

The no-wildcard-imports issue goes a little bit deeper, right? I know that you can set this setting in the intellij code formatting options, maybe it is possible to trigger it somehow?

@nbadal
Copy link
Owner

nbadal commented Oct 20, 2020

Yeah for that one specifically there's a few IDE settings to turn off the wildcard threshold in Settings > Editor > Code Style > Kotlin > 'Imports' Tab

The command line utility for ktlint has a flag to set some IntelliJ settings, which might include that, but I'm holding off on implementing that part because they're talking about transitioning to an .editorconfig-based solution soon.

One improvement I might make as well is to turn off the "Format with ktlint" action for rules that are not auto-correctable.

@nbadal
Copy link
Owner

nbadal commented Oct 20, 2020

Closing since this particular issue is merged and ready for 0.5.0, but happy to continue the discussion 😁

@nbadal nbadal closed this as completed Oct 20, 2020
nbadal added a commit that referenced this issue Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants