Skip to content

Automatically configure formatting for IntelliJ #53812

@pugnascotia

Description

@pugnascotia

Forked from #53747.

We could automatically configure IntelliJ to use the Eclipse formatter and our bundled format config. The downside of this is that it relies on the "Eclipse Code Formatter" plugin, though I also noticed a thing in IntelliJ about "Required Plugins", under "Build, Execution, Deployment". I tried adding the Eclipse plugin, and it created the file .idea/externalDependencies.xml with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ExternalDependencies">
    <plugin id="EclipseCodeFormatter" />
  </component>
</project>

Configuring the plugin created: .idea/eclipseCodeFormatter.xml with contents:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="EclipseCodeFormatterProjectSettings">
    <option name="projectSpecificProfile">
      <ProjectSpecificProfile>
        <option name="formatter" value="ECLIPSE" />
        <option name="pathToConfigFileJava" value="$PROJECT_DIR$/.eclipseformat.xml" />
        <option name="selectedJavaProfile" value="Elasticsearch" />
      </ProjectSpecificProfile>
    </option>
  </component>
</project>

It's also referenced in .idea/workspace.xml:

<project>
  <component name="PropertiesComponent">
    <property name="settings.editor.selected.configurable" value="EclipseFormatter" />

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions