镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

IDEA-180965: Add support for IntelliJ formatter #200

Closed

Description

@fabriziocucci

The line wrapping options that can be configured with IntelliJ seem to be a little bit more flexible than the one available in Eclipse (e.g. lambda-related preferences).

The closest thing I've found to format Java sources using an IntelliJ code style is its command line formatter. Although that still requires having the full binaries of IntelliJ (but I hope to be wrong!).

Activity

  1. nedtwigg commented on Feb 8, 2018

    @nedtwigg
    Member

    Happy to merge a PR for this, but currently nobody is working on it.

    You can use a custom step do this, there's an example of how to do this (and a description of its shortcomings) in #119.

  2. changed the title [-][QUESTION] Is there any plan to support IntelliJ generated code style for Java?[/-] [+]Add support for IntelliJ formatter[/+] on Feb 8, 2018
  3. fabriziocucci commented on Feb 12, 2018

    @fabriziocucci
    Author

    Commented interesting issue on the IntelliJ issue tracker related to this enhancement:

    https://youtrack.jetbrains.com/issue/IDEA-180965

  4. changed the title [-]Add support for IntelliJ formatter[/-] [+]IDEA-180965: Add support for IntelliJ formatter[/+] on Feb 13, 2018
  5. deleted a comment from fabriziocucci on Jul 24, 2018
  6. deleted a comment from fabriziocucci on Jul 24, 2018
  7. leonard84 commented on Sep 14, 2018

    @leonard84

    Also: Provide standalone formatter or API https://youtrack.jetbrains.com/issue/IDEABKL-7685

  8. nedtwigg commented on Jun 3, 2020

    @nedtwigg
    Member

    If you don't care about using the IntelliJ formatter specifically, but rather just the IntelliJ IDE to autoformat in a way that agrees with Spotless, another path forward would be to make a plugin for IntelliJ that calls out to the spotless IDE hook. For example, here's a plugin for VSCode.

  9. anandbhaskaran commented on Jun 8, 2020

    @anandbhaskaran

    It would be awesome if this come into reality!

  10. lfgcampos commented on Jan 6, 2021

    @lfgcampos

    Long shot but, any news about it?

  11. sbilello commented on Sep 30, 2021

    @sbilello

    If we want to use the intellij java code style with spotless. What's the recommended approach? https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml

  12. jbduncan commented on Oct 2, 2021

    @jbduncan
    Member

    @sbilello Spotless doesn't support the IntelliJ formatter yet. The way to get Google-style Java formatting is to use this instruction:

    spotless {
      java {
        googleJavaFormat().reflowLongStrings()
      }
    }

    It uses google-java-format, which is a successor to the IntelliJ XML file you linked, so I recommend google-java-format over it. :)

  13. 11 remaining items

  14. nedtwigg commented on Jun 8, 2023

    @nedtwigg
    Member

    Is there any particular reason that Spotless Maven lacks parity with Spotless Gradle

    Nope, we just got PR's from Gradle users, that's all.

  15. lipiridi commented on Aug 12, 2023

    @lipiridi

    @ragurney @lutovich @tonjohn @nedtwigg
    Hi! I've been developed a plugin that supports maven based on @ragurney's plugin (for which special thanks to him) and added some new features.
    https://plugins.jetbrains.com/plugin/22455-spotless-applier
    https://github.com/lipiridi/spotless-applier

  16. IlyasYOY commented on Nov 2, 2023

    @IlyasYOY
    Contributor

    Hello! Any updates on the issue?

    I found docs: Format files from the command line | IntelliJ IDEA Documentation.

    I use this API myself to format code using neovim:

    vim.keymap.set("n", "<leader>oC", ":!idea format -s ~/idea.xml -r %<CR>edit<CR>")

    I'd be glad to try to implement the feature if maintainers think it's possible.

    PS. I tested this on Linux & MacOS. There some caveats:

    • Some IDEA builds have this formatter builtin AFAIU. The version from Jetbrains Tools Box didn't seem to work.
    • MacOS version did formatting asynchronously. This is a problem. Version installed in Manjaro works synchronously with concise logs .

    Anyway considering all above, I'd gave a try to the feature. I'd add this as experimental due to unstable API of the IDE.

  17. nedtwigg commented on Nov 9, 2023

    @nedtwigg
    Member

    A PR for this would be very welcome. ForeignExe might be the easiest way to implement it. It's okay if it only works on some platforms, so long as it works for the platform you use. Future PR's can always add support for missing platforms.

  18. IlyasYOY commented on Jan 16, 2024

    @IlyasYOY
    Contributor

    Thanks for your hint @nedtwigg

    I created the *Step class a few days ago. It works fine on my macos machine. I faced a problem testing it on CI, there is no IDEA binary & simple installation from brew might require tweaking.

    I saw your PR #672. Maybe I'm missing something but I don't have any good ideas on running IDEA in test on every machine (CI at least). I can come up with a solution but maybe the team has an appropriate solution for the problem.

    Contribution guide helped a lot, thanks!

  19. nedtwigg commented on Jan 23, 2024

    @nedtwigg
    Member

    Amazing! IdeaStep has been implemented, after half a decade in the desert!

    Note the following:

    • in PR Add support for gofmt #2001
    • gradle/special-tests.gradle
    • testlib/src/main/java/com/diffplug/spotless/tag/GofmtTest.java
    • note that all tests have @GofmtTest from the tag above

    In this way, the tests are always compiled, even though they aren't run.

    Of all these "special" tests, the only ones which get run on CI right now are the npm tests. It would be better if they all ran, but it would be worse if the steps didn't exist at all.

    The important thing is that if someone wants to develop the step further, they aren't starting from scratch - they have tests, they just need to setup their local machine to have foreign exe in question.

  20. added a commit that references this issue on Jan 23, 2024
  21. IlyasYOY commented on Jan 23, 2024

    @IlyasYOY
    Contributor

    Thanks for the advice! Really appreciate it!

    I've just opened a Draft PR.
    #2020

  22. CC007 commented on Dec 6, 2024

    @CC007

    Any info on getting this to work with maven? Spotless applier is a nice first attempt, but is too slow for my use-case.

  23. zlsmith86 commented on Feb 10, 2025

    @zlsmith86

    I am excited about this feature!! I hope it makes it to main sometime! On a new project i ended up using the eclipse formatter because of the customizability, but most of us use IntelliJ so this would be a huge win!!

  24. simschla commented on Feb 21, 2025

    @simschla
    Contributor

    I'm working on this (based on #2020) because I would love to have it too. Can't make any promises on the timeline, though.

  25. jimmyzzxhlh commented on Feb 28, 2025

    @jimmyzzxhlh

    @simschla Thank you! Our team is looking into creating a pre-commit hook using Intellij style, so far only Spotless with Intellij formatter seems to be a promising solution.

  26. simschla commented on Jul 2, 2025

    @simschla
    Contributor

    Resolved in #2535

  27. nedtwigg commented on Jul 7, 2025

    @nedtwigg
    Member

    Released in plugin-gradle 7.1.0 and plugin-maven 2.45.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions