A VS Code extension to lint & format your code using Spotless (via Gradle).
- Provides diagnostics to show invalid formatting (with quick fixes)
- Provides a Spotless fixAll code action (
Format on Save
) - Provides a Spotless formatter (
Format Document
)
Supports all languages that Spotless supports.
Before using this extension, ensure you've configured Spotless correctly in your Gradle build file. (Run ./gradlew spotlessDiagnose
to prepare & validate Spotless.)
Spotless formatting & diagnostics are disabled by default. Change the settings to adjust this behaviour:
{
"[java]": {
"spotlessGradle.format.enable": true,
"spotlessGradle.diagnostics.enable": true
}
}
{
"[java]": {
"editor.codeActionsOnSave": {
"source.fixAll.spotlessGradle": true
}
}
}
If there are multiple formatters for a language type, set Spotless to be the default:
{
"[java]": {
"editor.defaultFormatter": "richardwillis.vscode-spotless-gradle"
}
}
Disable other formatters to improve the performance, for example:
{
"[java]": {
"files.trimTrailingWhitespace": false
}
}
This extension runs the spotlessApply
Gradle task on the focused file using the Spotless IDE hook feature. Untitled/Unsaved files are ignored.
The vscode => Spotless interface is provided by the Gradle Tasks extension.
View logs by selecting Spotless Gradle
and/or Gradle Tasks
in the output panel.
- ๐ Submit a bug report
- ๐ Submit a feature request
- Thanks to Ned Twigg for adapting Spotless for better IDE integration
- Thanks to all the Spotless contributors
See CHANGELOG.md.
See LICENSE.md.