atom-community / atom-ide-code-format

Code formatting for Atom-IDE
https://atom.io/packages/atom-ide-code-format
Other
4 stars 3 forks source link
atom atom-ide atom-package beautify formatting prettier

Code Format

Usage

Code Format

Developer Service API

Code Format also provides APIs to:

You can enable format-on-save using plain range/file providers from the atom-ide-code-format's settings

Provide code format Atom services by adding one or more of these to your package.json: (Only the ones that you want to use; you don't need all of them!)

"providedServices": {
  "code-format.range": {
    "versions": {
      "0.1.0": "provideRangeCodeFormat"
    }
  },
  "code-format.file": {
    "versions": {
      "0.1.0": "provideFileCodeFormat"
    }
  },
  "code-format.onType": {
    "versions": {
      "0.1.0": "provideOnTypeCodeFormat"
    }
  },
  "code-format.onSave": {
    "versions": {
      "0.1.0": "provideOnSaveCodeFormat"
    }
  }
}

Then, in your package entry point:

export function provideRangeCodeFormat(): RangeCodeFormatProvider {}
export function provideFileCodeFormat(): FileCodeFormatProvider {}
export function provideOnTypeCodeFormat(): OnTypeCodeFormatProvider {}
export function provideOnSaveCodeFormat(): OnSaveCodeFormatProvider {}

The various provider types are described in atom-ide-code-format/lib/types.js.