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

Applying to IDEA does not honour max line length #493

Closed
Artamus opened this issue Jun 18, 2019 · 6 comments
Closed

Applying to IDEA does not honour max line length #493

Artamus opened this issue Jun 18, 2019 · 6 comments

Comments

@Artamus
Copy link

Artamus commented Jun 18, 2019

Hi, when attempting to use ktlint with IntelliJ IDEA I am running into an issue with the formatter where the max_line_length does not apply within IDEA. This might be an issue with IDEAs editorconfig plugin as well, not sure in that regard.

Version

0.33.0

Code

None to provide, but it should yield the same result in any project.

Steps to reproduce

In the project .editorconfig file have the following snippet:

[*.kt]
max_line_length = 160

Install ktlint via homebrew. In the project folder run ktlint --apply-to-idea-project and apply the style. Now open the project in IntelliJ IDEA, open the Preferences menu and navigate to Editor -> Code Style -> Kotlin and pick the Wrapping and braces tab. In this tab, Hard wrap at setting should be 160 instead of the default of 120 (if I'm not misunderstanding).

Stack traces

None, as it doesn't crash.

Logs

After applying ktlint to IDEA project, the output I get is:

The following files are going to be updated:

	./.idea/codeStyles/codeStyleConfig.xml
	./.idea/codeStyles/Project.xml
	./.idea/inspectionProfiles/profiles_settings.xml
	./.idea/inspectionProfiles/ktlint.xml
	./.idea/workspace.xml

In my case, the EditorConfig plugin is also enabled in IDEA, which means that it could be an issue of this plugin not working correctly instead, I am not entirely sure if this setting should even be overwritten by the ktlint command.

Thanks for reading!

@Tapchicoma
Copy link
Collaborator

I think, the problem is in your .editorconfig. It should look this way:

[*.kt]
max_line_length=160

Note no spaces for max_line_length assignment.

@Artamus
Copy link
Author

Artamus commented Jun 20, 2019

Thank you for the reply!
Sadly, this did not work for me and moreover, https://editorconfig.org/ specifies the config file with spaces, so it should work even with spaces.

@sowmyav24
Copy link
Contributor

@Artamus I tried using the same steps. Couple of things

  • I restarted the IDE after applying the settings.
  • Hard wrap at setting was not visible in Kotlin, only the default setting of Hard wrap was present at 120 but still i could see the hard wrap indicator at position 160 in the files.

@Artamus
Copy link
Author

Artamus commented Jun 28, 2019

I forgot to specify in the original issue comment, but IDEA was closed whenever I ran these commands, so restarting is not an issue (and when I tried it with IDEA running, I also restarted it).

I don't understand the second part, my default setting for hard wrap is still at 120, but I had to manually put the Kotlin one to 160 for it to work (and then it DOES work in IDEA).

@Tapchicoma
Copy link
Collaborator

@romtsn
Copy link
Collaborator

romtsn commented Dec 2, 2020

Closing this as we are going to deprecate the current IDEA-integration in favor of integration via .editorconfig (#701)

@romtsn romtsn closed this as completed Dec 2, 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

4 participants