GeezerVison is showing github.com — IDEA-180965: Add support for IntelliJ formatter · Issue #200 · diffplug/spotless
IDEA-180965: Add support for IntelliJ formatter #200DescriptionThe 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!). Reacted by Tomas R, Feng Yu, Ruth, mdbarr73, Arnaldo Trujillo Falcón, Eric Sirianni, Alex Stark, Mikołaj Kondratek, Andrei Sfat, Jonathan Bluett-Duncan and 42 more Activitynedtwigg commented on Feb 8, 2018 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. changed the title [-][QUESTION] Is there any plan to support IntelliJ generated code style for Java?[/-] [+]Add support for IntelliJ formatter[/+] on Feb 8, 2018fabriziocucci commented on Feb 12, 2018 Reacted by Jonathan Bluett-Duncan, Matthias Balke, bootstraponline, LQiang79, Ajibola Aiyedogbon, Volodymyr Mykhailov, Valerij Dobler, c0nstexpr and t-chab changed the title [-]Add support for IntelliJ formatter[/-] [+]IDEA-180965: Add support for IntelliJ formatter[/+] on Feb 13, 2018leonard84 commented on Sep 14, 2018 Reacted by Brice Dutheil, Volodymyr Mykhailov and Ivan Luzyanin nedtwigg commented on Jun 3, 2020 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. Reacted by Vishal Nehra, Michael Leonhard and DanielPinoGL anandbhaskaran commented on Jun 8, 2020 It would be awesome if this come into reality! Reacted by Alexandre Guidin, geosmart, Yevhen Sukhomud, Peter Abeles, DimiT, iury souza, Henrik Nårstad, Angelo Rosenfelder, borram, Cemal and 3 more lfgcampos commented on Jan 6, 2021 Long shot but, any news about it? Reacted by Yonatan Karp-Rudin, Santiago Ferrer Deheza, Pavel Efros, milowedo, SiwyDym, Hakanai and Andrew Dey sbilello commented on Sep 30, 2021 jbduncan commented on Oct 2, 2021 @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. :) nedtwigg commented on Jun 8, 2023
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. lipiridi commented on Aug 12, 2023 IlyasYOY commented on Nov 2, 2023 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. nedtwigg commented on Nov 9, 2023 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. Reacted by Daniel Kraus and Ilya Ilyinykh IlyasYOY commented on Jan 16, 2024 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! nedtwigg commented on Jan 23, 2024 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. Reacted by Daniel Kraus, Ilya Ilyinykh and Clif Reeder Reacted by Ilya Ilyinykh IlyasYOY commented on Jan 23, 2024 Thanks for the advice! Really appreciate it!
I've just opened a Draft PR.
#2020 CC007 commented on Dec 6, 2024 Any info on getting this to work with maven? Spotless applier is a nice first attempt, but is too slow for my use-case. zlsmith86 commented on Feb 10, 2025 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!! simschla commented on Feb 21, 2025 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. Reacted by CC007, Lucas Campos, Daniel Kraus and Nicolas Kosinski jimmyzzxhlh commented on Feb 28, 2025 @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. simschla commented on Jul 2, 2025 Reacted by Andrii Lomakin and Suresh Reacted by Andrii Lomakin, Daniel Kraus and Ilya Ilyinykh nedtwigg commented on Jul 7, 2025 Released in plugin-gradle 7.1.0 and plugin-maven 2.45.0. Reacted by Ilya Ilyinykh, Suresh, Lucas Campos and Ronald Dehuysser
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|