ragurney / spotless-intellij-gradle

An IntelliJ plugin to allow running the Spotless gradle task from within the IDE.
MIT License
38 stars 14 forks source link

Add a `Reformat Code with Spotless` Action on Save Setting #8

Open ragurney opened 2 years ago

ragurney commented 2 years ago

This entails:

simonbasle commented 2 years ago

Since IntelliJ 2021.2 Jetbrains added support for Actions on Save under Preferences/Settings | Tools | Actions on Save. I wonder if plugins can contribute to that list of actions 🤔

ragurney commented 2 years ago

I'll have to look into it! I'm still stuck on v2021.1 at work unfortunately so I would like to make something that works for at least that version as well

ln-12 commented 2 years ago

Maybe this plugin might be helpful to look at: https://github.com/dubreuia/intellij-plugin-save-actions

melissachang commented 2 years ago

I was able to use File Watchers to run ./gradlew spotlessApply on save. Need to install File Watchers plugin. You can run any command. Note - Needs to be configured for every repo.

image

ragurney commented 2 years ago

Thanks @ln-12 and @melissachang! Yes there are a couple plugins you can use in concert with this plugin to get format on save -- save actions is one I've been currently using. I would love to make this a bundled feature in this plugin though. I'm currently quite busy getting ready to move across the country but will try to get to implementing this in the near future.

oraum commented 2 years ago

There are extensionpoints (ActionOnSave and ActionOnSaveInfoProvider) which can be used PlatformExtensionPoints

ragurney commented 2 years ago

Thanks @oraum! I've been dealing with a crosss-country move so haven't had time to invest into this yet. I'd be happy to accept a PR for this, or can likely work on it myself in the next month or so.

ErtugrulSener commented 6 months ago

Any updates on this topic? It is the main reason people use formatters, they want to see the formatted code.

And there is no plugin for intellij yet, using the OnActionSave extension point for spotless.

fokkoru commented 1 month ago

Any updates on this topic?