Giter VIP home page Giter VIP logo

gayanper / vscode-spotless-gradle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from badsyntax/vscode-spotless-gradle

0.0 1.0 0.0 2.35 MB

A VS Code extension to lint & format your source files using Spotless & Gradle.

Home Page: https://marketplace.visualstudio.com/items?itemName=richardwillis.vscode-spotless-gradle

License: MIT License

JavaScript 1.24% C++ 0.03% Python 0.02% C 0.02% Objective-C 0.02% Java 0.72% Groovy 0.19% TypeScript 97.66% CSS 0.03% Objective-C++ 0.02% Less 0.03% SCSS 0.03%

vscode-spotless-gradle's Introduction

Spotless Gradle

Marketplace Version Visual Studio Marketplace Installs Build & Publish CodeQL GitHub bug issues

A VS Code extension to lint & format your code using Spotless (via Gradle).

Spotless Gradle Screencast

Features

  • 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

Requirements

Usage

Before using this extension, ensure you've configured Spotless correctly in your Gradle build file. (Run ./gradlew spotlessDiagnose to prepare & validate Spotless.)

Enabling Spotless

Spotless formatting & diagnostics are disabled by default. Change the settings to adjust this behavior:

{
  "[java]": {
    "spotlessGradle.format.enable": true,
    "spotlessGradle.diagnostics.enable": true
  }
}

Formatting

Format on save:

{
  "[java]": {
    "spotlessGradle.format.enable": true,
    "editor.codeActionsOnSave": {
      "source.fixAll.spotlessGradle": true
    }
  }
}

If there are multiple formatters for a language type, set Spotless to be the default:

{
  "[java]": {
    "spotlessGradle.format.enable": true,
    "editor.defaultFormatter": "richardwillis.vscode-spotless-gradle"
  }
}

Disable other formatters to improve the performance, for example:

{
  "[java]": {
    "spotlessGradle.format.enable": true,
    "files.trimTrailingWhitespace": false
  }
}

Typical Usage

As Spotless formatting is not a global feature, you should enable Spotless on a per-project basis, which is achieved by adding a .vscode/settings.json file to the root of the project

Enable for specific languages:

{
  "java.format.enabled": false,
  "[java]": {
    "files.trimTrailingWhitespace": false,
    "spotlessGradle.diagnostics.enable": true,
    "spotlessGradle.format.enable": true,
    "editor.defaultFormatter": "richardwillis.vscode-spotless-gradle",
    "editor.codeActionsOnSave": {
      "source.fixAll.spotlessGradle": true
    }
  },
  "[gradle]": {
    "files.trimTrailingWhitespace": false,
    "spotlessGradle.diagnostics.enable": true,
    "spotlessGradle.format.enable": true,
    "editor.defaultFormatter": "richardwillis.vscode-spotless-gradle",
    "editor.codeActionsOnSave": {
      "source.fixAll.spotlessGradle": true
    }
  }
}

Enable for all languages:

{
  "java.format.enabled": false,
  "files.trimTrailingWhitespace": false,
  "spotlessGradle.diagnostics.enable": true,
  "spotlessGradle.format.enable": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.spotlessGradle": true
  },
  "[java]": {
    "editor.defaultFormatter": "richardwillis.vscode-spotless-gradle"
  },
  "[gradle]": {
    "editor.defaultFormatter": "richardwillis.vscode-spotless-gradle"
  }
}

How it Works

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 for Java extension.

๐Ÿ‘‰ Architecture Overview

Troubleshooting

View logs by selecting Spotless Gradle and/or Gradle for Java in the output panel.

Support

Credits

Release Notes

See CHANGELOG.md.

License

See LICENSE.md.

vscode-spotless-gradle's People

Contributors

badsyntax avatar dependabot-preview[bot] avatar dependabot[bot] avatar forestaa avatar snyk-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.