Nova

Extensions


Readme

Prettier for Nova

Code formatting using Prettier, right in Nova.

  • Formats on save (can be changed per project), or using Editor > Prettier > Format (⌥⇧F).
  • Supports all languages supported by Prettier: json, html, javascript, jsx, flow, typescript, vue, angular, css, less, scss, graphql, markdown, yaml, and plugins.
  • Supports standard Prettier configuration, and .prettierignore files.
  • Uses the Prettier and any plugins installed in your project (or built-in Prettier if you don't have any).

Using plugins

If you want to use Prettier plugins just install them, as well as Prettier, in your project.

Ignoring files

You can disable format on save for remote documents, documents without Prettier configuration file, or specific syntaxes in the extension preferences. You can also use Prettier's built-in exclusion feature by adding a .prettierignore file to the root of your project. Note: adding it anywhere else won't work.

Using a different version of Prettier

Just install the Prettier version you want (1.15.0 or higher) in the root folder of your project. If you already have it open in Nova you'll need to reopen your project after installing or updating Prettier for the extension to start the new one.

You can also explicitly pick an installation of Prettier (or prettier-eslint) by setting the Prettier module path in either the extension or project settings.

Using Prettier forks or prettier-eslint

You should be able to use any fork of Prettier that uses the same API, as well as prettier-eslint by explicitly setting the Prettier module path in either the extension or project settings.

Working with remote files

Most features are supported for remote files. However Prettier configuration and .prettierignore files are not. The default configuration set in the extension or project preferences will be used instead.


Changelog

2.6.0 - 2023-05-01

Added

  • Try formatting based on the syntax selected in Nova if Prettier can't determine the parser
  • Add support for formatting unsaved TSX and HTML (ERB) files

2.5.1 - 2023-04-17

Fixed

  • Fixes extension crashing when opening a file outside a workspace, or a remote file

2.5.0 - 2023-04-16

Added

  • Added support for finding Prettier installed through yarn and pnpm, etc. (only if node_modules is used)
  • Look for Prettier installations in the project's parent folder before falling back to the bundled Prettier

Fixed

  • Fixes prettier not being able to find plugins installed in the project folder

2.4.0 - 2023-04-10

Added

  • Changes to Prettier configuration in .prettierrc and package.json are now applied automatically

Changed

  • Updated bundled Prettier to 2.8.7
  • Updated bundled Prettier PHP plugin to 0.19.4

Fixed

  • Fixes Format with Prettier following format on save Ignore documents without Prettier configuration file configuration value
  • Fixes a possible error when restarting the Prettier process

2.3.0 - 2021-05-19

Added

  • Added global and project settings to override the Prettier module path
  • Added (experimental) support for prettier-eslint

Changed

  • Errors occurring while loading the Prettier module will now be logged with message and stack trace

2.2.2 - 2021-05-10

Changed

  • Revert to keeping cursor position in the extension

2.2.1 - 2021-02-21

Changed

  • Use Nova's new built-in way of keeping the cursor position/selection after formatting

2.2.0 - 2021-02-04

Added

  • Added Save Without Formatting command

Changed

  • Loading Prettier may be retried once after a small delay instead of immediately showing an error
  • Updated bundled Prettier to 2.2.1
  • Updated bundled Prettier PHP plugin to 0.16.1

2.1.0 - 2020-11-25

Changed

  • Updated bundled Prettier PHP plugin to 0.16.0
  • Updated bundled Prettier to 2.2.0

Fixed

  • Fixes project Prettier not getting found when using npm v7.0.0

2.0.0 - 2020-11-03

Added

  • Added Format selection command
  • All selections/cursors are now maintained after formatting
  • A warning is now shown if a document uses an unsupported syntax when formatting manually

Changed

  • (Breaking) Removed compatibility mode
  • Renamed Format with Prettier to Format and moved it into a submenu
  • Nova will now wait for formatting before saving instead of saving twice
  • Formatting a file while the extension is installing Prettier will be delayed instead of getting ignored entirely
  • Disabling debug logging now also disables logging about finding Prettier

Fixed

  • Fixes project Prettier not getting found in some cases

1.8.2 - 2020-10-26

Fixed

  • Fixes last line of code getting duplicated in some cases
  • Fixes position of column indicator offset by -1
  • Fixes a possible error when trying to check Prettier version
  • Fixes (PHP) syntax errors without a column indicator causing an error
  • Fixes (Twig) syntax errors with a double column indicator causing an error

1.8.1 - 2020-10-23

Added

  • Support syntax errors thrown by prettier-plugin-twig-melody

1.8.0 - 2020-10-18

Added

  • Added preferences to set default Prettier configuration globally and per-project.
  • Added preference (global and per-project) to ignore files for which no Prettier configuration file can be found when formatting on save.
  • Added preference (global and per-project) to ignore remote files when formatting on save.
  • Added preference to disable debug logging (errors are always logged).

Changed

  • Added an extra warning about future compatibility mode removal

Fixed

  • Fixes extension failing to parse NPM output and failing to start when no project Prettier is installed.

1.7.1- 2020-10-09

Fixed

  • Actually fixes parser overrides in .prettierrc file getting ignored.

1.7.0 - 2020-10-08

Changed

  • Only use Prettier available in the project if it's a direct project dependency.
  • Take .editorconfig into account when determining formatting configuration.
  • The Format with Prettier command now ignores the .prettierignore file.

Fixed

  • Fixes parser overrides in .prettierrc file getting ignored.
  • Fixes formatting an unsaved file outside of a workspace causing an error.
  • Fixes document text getting mixed up if changes are made during formatting.

1.6.1 - 2020-10-05

Added

  • Added global setting to disable Format on save for specific syntaxes.
  • Included PHP plugin with bundled Prettier.
  • More events are logged to the extension console.

Changed

  • Plugin support is now enabled by default, but can be disabled when errors occur.
  • Selected text now remains selected after formatting (doesn't support multiple selections / cursors).
  • Folded code will now remain folded unless formatting changes it.
  • Improved formatting speed.
  • The Format with Prettier command is now available for all syntaxes, so it works with plugins.
  • Show syntax errors from PHP plugin inline.
  • Don't show error when trying to format a file that has no parser available.

Fixed

  • Fixes an error trying to log errors occurring while looking up configuration.

1.5.2 - 2020-10-03

Changed

  • Show notification about any unhandled errors during formatting.

Fixed

  • Fixes syntax errors preventing formatting no longer getting reported.
  • Fixes issues on older macOS releases.

1.5.1 - 2020-09-27

Changed

  • When formatting on save, automatically save the file again if Nova thought formatting took too long and saved the unformatted version.

Fixed

  • Fixes unnecessary document updates when it's already properly formatted.

1.5.0 - 2020-09-26

Added

  • Support for Prettier plugins (requires enabling Run Prettier in a separate process (experimental)).

Changed

  • Improved performance when formatting large files (requires enabling Run Prettier in a separate process (experimental)).
  • Stop formatting PHP, unless the PHP plugin is used.

1.4.0 - 2020-09-25

Added

  • Set a default keyboard shortcut for Format with Prettier command: ⌥⇧F.
  • Added a global Format on save preference that can be overridden by project preferences.
  • Support formatting of HTML in PHP files.

Changed

  • Fall back to bundled Prettier when loading the project's Prettier installation fails.

Fixed

  • Fixes files opened after disabling formatting on save getting formatted on save.

1.3.0 - 2020-09-21

Added

  • Support formatting of files in non-project windows.
  • Support working on the Prettier repository.
  • Automatically update the bundled installation of Prettier if the extension includes a new version.

Changed

  • (Breaking) Updated bundled Prettier to 2.1.2.

1.2.1 - 2020-09-17

Added

  • Support formatting of new files that have never been saved.
  • Include CSS in supported syntaxes.

Changed

  • Don't require editor focus for the Format with Prettier to be available.
  • Log non-syntax errors from Prettier to the extension console properly.
  • Include stack trace with errors logged in the extension console.

1.2.0 - 2020-08-17

Added

  • Added a warning with help when Prettier (and NPM) can't be found.

1.1.0 - 2020-06-15

Added

  • Use Prettier installed in the project's node_modules. If none is available the extension falls back to the bundled Prettier.
  • Automatically find and load parsers provided by Prettier.

1.0.0 - 2020-06-12

Added

  • Use .prettierignore to determine which files to format (.prettierignore needs to be in the project root).
  • Added a warning when an error occurs while looking up the Prettier configuration for a file.

Changed

  • (Breaking) Updated to Prettier 2.0.5.

0.2.0 - 2020-02-29

Added

  • Don't include prettier in extension, but install when activating.

0.1.0 - 2020-01-31

Added

  • Initial release.