Skip to content

dprint/dprint-intellij

Repository files navigation

dprint-intellij-plugin

This plugin adds support for dprint, a flexible and extensible code formatter (dprint.dev). It is in active early development, please report bugs and feature requests to our github.

To use this plugin:

  • Install and configure dprint for your repository, dprint.dev/setup
  • Configure this plugin at Preferences -> Tools -> dprint.
    • Ensure Enable dprint is checked
    • To run dprint on save check Run dprint on save.
    • To enable overriding the default IntelliJ formatter check Default formatter override. If a file can be formatted via dprint, the default IntelliJ formatter will be overridden and dprint will be run in its place when using Option+Shift+Cmd+L on macOS or Alt+Shift+Ctrl+L on Windows and Linux.
    • To enable verbose logging from the underlying dprint daemon process check Verbose daemon logging
    • If your dprint.json config file isn't at the base of your project, provide the absolute path to your config in the Config file path field, otherwise it will be detected automatically.
    • If dprint isn't on your path or in node_modules, provide the absolute path to the dprint executable in the Executable path field, otherwise it will be detected automatically.
  • Use the "Reformat with dprint" action by using the "Find Action" popup (Cmd/Ctrl+Shift+A).
  • Output from the plugin will be displayed in the dprint tool window. This includes config errors and any syntax errors that may be stopping your file from being formatted.

This plugin uses a long-running process known as the editor-service. If you change your dprint.json file outside of IntelliJ or dprint is not formatting as expected, run the Restart dprint action or in Preferences -> Tools -> dprint click the Restart button. This will force the editor service to close down and restart.

Please report any issues with this Intellij plugin to the github repository.

Installation

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...


Development

This project is currently built using JDK 17. To install on a mac with homebrew run brew install java and set that be your project SDK.

Intellij Setup

  • Set up linting settings, run Gradle > Tasks > help > ktlintApplyToIdea. This sets up intellij with appropriate formatting settings.

Running

There are 3 default run configs set up

  • Run Plugin - This starts up an instance of Intellij Ultimate with the plugin installed and enabled.
  • Run Tests - This runs linting and tests.
  • Run Verifications - This verifies the plugin is publishable.

Depending on the version of IntellJ you are running for development, you will need to change the platformType property in grade.properties. It is IU for IntelliJ Ultimate and IC for IntelliJ Community.