-
Notifications
You must be signed in to change notification settings - Fork 885
IntelliJ Plugin - Formatting non-Java files #363
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
Comments
google-java-format doesn't have any idea how to format XML, YAML, or any other files, so there's no way it could be doing that. You must be using IntelliJ's built-in code formatter for those. Can you better describe what you're doing and what's happening that you don't expect? |
The built-in formatter is being used, this may be more of an issue with using the recommended configuration file for import ordering found on the readme: https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml I've reviewed the impacted file type configurations, and can isolate this to the following after comparing manually with IntelliJ's "Default" IDE settings: |
Ah, yeah, I see what you're saying. The important thing is to modify your Settings→Editor→Code Style→Java→Import Layout to look like this: The rest of that file unimportant, and telling people to import the entire thing is definitely not ideal. I'll see if I can think of something better. |
@plumpy Wouldn't you also want to set the threshold for star imports to a high enough value that it won't ever be reached, and possibly also empty the list of packages to always star-import? (from memory, don't have my IntelliJ at hand right now) |
@seadub I don't think anybody has raised this yet, but the google-java-format plugin for IntelliJ is actually different to the XML file that you linked in your most recent message. The XML file is used to configure IntelliJ's built-in formatter; by comparison the plugin delegates to google-java-format, which is a separate project that Googlers started because IntelliJ's formatter isn't quite powerful enough to allow code to be formatted according to the Google Java Style Guide - the XML file is just an approximation. :) |
@seadub was referencing the instructions, however, which do tell you to import that XML file. This is because google-java-format isn't fully capable of managing your imports. (For example, the style guide forbids wildcard imports, but since google-java-format only knows about a single file at a time, it can't resolve wildcard imports into fully-qualified imports.) And yes, as @tbroyer mentioned, if you don't import the file, you also need to set the import counts to 999 (thanks for the reminder!): |
@jbduncan I did notice that distinction after @plumpy provided some feedback. |
PR here: google/styleguide#447 |
IntelliJ Version 2018.3
google-java-format IntelliJ Plugin version 1.7.0.1
Trying to isolate code formatting changes to Java classes. The indentation seems to impact all files, including XML, YAML, and more.
Can we isolate this configuration to only Java files?
The text was updated successfully, but these errors were encountered: