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

IntelliJ plugin doesn't respect max line length setting. #351

Closed
pardom opened this issue Sep 13, 2022 · 9 comments
Closed

IntelliJ plugin doesn't respect max line length setting. #351

pardom opened this issue Sep 13, 2022 · 9 comments

Comments

@pardom
Copy link

pardom commented Sep 13, 2022

The IntelliJ plugin does not provide an option to consume max_line_length as FormattingOptions.maxWidth in UiFormatter. Thus we cannot synchronize the IDE with the overridden setting in our build script:

spotless {
    kotlin {
        ktfmt("0.40").kotlinlangStyle().configure { optionsConfiguration ->
            optionsConfiguration.setMaxWidth(120)
        }
    }
}

KtfmtConfigurable.form should provide an option to respect the Hard wrap at setting in Preferences > Editor > Code Style or max_line_length option in .editorconfig.

@twomoose
Copy link

Definitely interested to see if this is something that would be considered. The discrepancy between IDE and linter is one of the main issues my team has with ktlint (our current style tool). We're considering ktfmt to replace it but I can't convince others to change our max line width to 100 (as required by ktfmt). Spotless gets around this but then we have the issue of the IDE plugin clashing with build script tooling.

@runenielsen
Copy link

This would be very useful.

@hick209
Copy link
Contributor

hick209 commented Jun 5, 2024

I'm quite confident this is fixed in the latest version. Please reopen if otherwise

@hick209 hick209 closed this as completed Jun 5, 2024
@mateherber-jt
Copy link

@hick209 I'm not sure how I can make the IntelliJ plugin to respect the max line width setting set by spotless or ktfmt-gradle.

@hick209
Copy link
Contributor

hick209 commented Jun 10, 2024

@mateherber-jt, oh so the issue persist even at 0.50? Interesting...
Long shot from my end, as I don't really know much about how Spotless and IJ formatting works, but have you tried using .editorconfig? I wonder if that's the missing piece of the puzzle

@hick209 hick209 reopened this Jun 10, 2024
@greyhairredbear
Copy link
Contributor

As far as I understand from working on the plugin and looking into the ktfmt step for spotless, both use ktfmt as a direct dependency, but configure it in two different locations (IJ settings vs gradle file).

I think the easiest way to implement this would be allowing to set that value directly in the config form - if that is something that should be configurable. Not sure how much effort it would require to implement reading the max line length value from an .editorconfig file or from the IJ code style settings. Also, I'm unsure if that would actually be sensible. The less places you have to go to configure ktfmt, the better.

@leourbina7r
Copy link

I'm running into this same issue. It seems like the Intellij plugin uses 100 for max_line_limit regardless of the .editorconfig.

@rock3r
Copy link
Contributor

rock3r commented Aug 15, 2024

Fixed in #503

@hick209
Copy link
Contributor

hick209 commented Aug 23, 2024

Should be fixed by #503

@hick209 hick209 closed this as completed Aug 23, 2024
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

8 participants