pulsar-code-format Made for Pulsar!

A pluggable code formatting package

savetheclocktower

2

0

0.0.2

MIT

GitHub

This package consumes the following services:

pulsar-code-format

A pluggable code formatting package for Pulsar. Relies on other packages to provide code-formatting strategies for various languages.

Designed to work with IDE packages in particular — packages whose names start with pulsar-ide- — but can support any code formatter.

Usage

Commands

code-format:format-code

Formats a file or selection. When the selection is empty, attempts to format the whole file; otherwise formats only what is selected.

Mapped to Cmd-Shift-C on macOS; Ctrl-Shift-C on Windows and Linux.

code-format:list-providers-for-current-editor

Lists how many of each sort of code formatter are active in the current editor, then shows a list of all packages that claim to provide one of the code-format services.

No keybinding; invoke it from the command palette.

Config

Avoiding conflicts with other packages

There are a number of ways that existing Pulsar packages attempt to lint/format a file on save. To use JavaScript as an example: you might already be using linter-eslint-node or prettier-atom.

For this reason, format-on-save behavior is disabled by default. You may want to enable it on a project-by-project basis; information about how to do that is included below.

Still, this package tries to be robust even in strange situations. Consider:

After all, data integrity is more important than code formatting.

Changing settings on a per-project basis

Code formatting conventions and toolchains often vary from project to project, so the settings in this package might need to vary on a per-project basis as well. A package like atomic-management can help you manage this complexity by defining project-specific settings.

For instance, you can disable this package’s format-on-save in projects where it isn’t necessary by adding the following config override to .atom/config.cson within your project:

"*":
  "pulsar-code-format":
    "formatOnSave": false

You can also, for example, disable ESLint in projects where you want a code-format.onSave provider to be in charge:

"*":
  "linter":
    "disabledProviders": [
      "ESLint (Node)"
    ],
  "pulsar-code-format":
    "formatOnSave": true

Services

This package consumes the full suite of code-format services that are provided by many IDE packages:

code-format.file

Formats an entire file.

code-format.range

Formats an arbitrary range of a file.

code-format.onSave

Automatically formats a file when saving.

code-format.onType

Automatically formats a file as you type.