dprint / dprint-vscode

Visual Studio Code extension for formatting code with dprint.
MIT License
60 stars 11 forks source link

dprint - Visual Studio Code Extension

Visual Studio Code formatting extension for dprint—a pluggable and configurable code formatting platform.

Install

  1. Install dprint's CLI
  2. Install extension via Visual Studio Marketplace

Setup

  1. Run dprint init in the root directory of your repository to create a dprint configuration file.
  2. Set the default formatter in your vscode settings and consider turning on "format on save":
    {
     "editor.defaultFormatter": "dprint.dprint",
     "editor.formatOnSave": true,
     // or specify per language, for example
     "[javascript]": {
       "editor.defaultFormatter": "dprint.dprint",
       "editor.formatOnSave": true
     }
    }

Features

Formats code in the editor using dprint.

Plugins are currently resolved based on the dprint configuration file in the current workspace folder.

Requirements

You must have dprint installed globally on the path.

Follow the instructions here: Install

Extension Settings

{
  // By default it will use `dprint` found on the path,
  // but use this when you want to specify a custom location.
  // Include the executable name (ex. on windows "C:\\some-dir\\dprint.exe")
  "dprint.path": "/home/david/otherPath/dprint",
  // Change this to `true` to get verbose logging
  "dprint.verbose": false,
  // Change this to `true` to enable the experimental lsp (requires dprint 0.45+)
  "dprint.experimentalLsp": false
}

Known Issues

Developing and Testing Locally

  1. npm install
  2. Go to "Run and debug" in VS code and run the "Run Extension" task.

Release Notes

0.16.3

0.16.2

0.16.1

0.16.0

0.15.1

0.15.0

0.14.0

0.13.6

0.13.5

0.13.4

0.13.3

0.13.2

0.13.1

0.13.0

0.12.1

0.12.0

0.11.0

0.10.0

0.9.0

0.8.0

0.7.0

0.6.0

0.5.0

0.4.0

0.3.0

0.2.0

Formatting is faster due to using a long-running background process for formatting.

0.1.6

0.1.3-0.1.5

Updates based on latest dprint CLI.

0.1.2

Fix error text.

0.1.1

Auto-dismiss syntax error notifications.

0.1.0

Initial release.