Nova

Extensions


Readme

Beautify for Nova

Beautify integrates JS-Beautify into Nova for formatting Javascript, Typescript, JSON, CSS, SCSS, LESS, HTML and XML.

Configuration

  • Formatting is based on the syntax mode of the editor
  • Indentation settings are inherited from the editor
  • Line endings are inherited from the open document
  • Other configuration options can be set as global preferences
  • Option to format selection or whole document as specific syntax
  • Option to format on save, settable per syntax in global preferences

Invoking

  • Via shortcut ⌥⇧F
  • Via menu Editor > Beautify > Format
  • Via command palette ⌘⇧P and then type Format
  • Via command palette ⌘⇧P and then type Format as JSON, Format as CSS, Format as ...
  • Automatically formats any selected text or the whole document if there was no selection

Additional syntaxes

Additional syntaxes provided by other Nova extension can be added upon request. Please create an issue at GitHub and provide the necessary information.

Please note that JS-Beautify is only made to format (and know about) HTML, Javascript and CSS and does not know anything about PHP, Python, Ruby and other languages. As such it may – for example – work well for HTML based templating syntaxes but will not lead to any results formatting the parts in such a file that are not HTML, Javascript or CSS.

Currently the following additional syntaxes are enabled:

Use at your own risk.

Known issues

  • If some configuration options do not have an effect, try disabling the preserve existing line-breaks and check other preserve options.
  • If some configuration options entered into text fields are not directly used, then this is due to a bug in Nova. You have to switch to another activated extension in the extension library (i.e. loose focus on the Beautify extension) before the values get updated. You can check which configuration options are being used by checking the extension console after formatting.

Screenshots


Changelog

Version 1.8

  • Added config options for indent empty lines and max. preserved line-breaks (all)
  • Added config options for operator position (Javascript & JSON)

Version 1.7.3

  • Updated JS-Beautify to 1.14.11

Version 1.7.2

  • Updated JS-Beautify to 1.14.9

Version 1.7.1

  • Updated JS-Beautify to 1.14.9

Version 1.7

  • Updated JS-Beautify to 1.14.8

Version 1.6

  • Added (experimental) support for HTML (EJS) and HTML (ERB)
  • Added (experimental) support for HTML (Jinja2), see Jinja2 Nova Extension
  • Added (experimental) support for HTML (Liquid), CSS (Liquid), SCSS (Liquid), see Liquid Nova Extension

Version 1.5

  • Added format on save option
  • Updated JS-Beautify to 1.14.7

Version 1.4.1

  • Automatic lowercasing of configuration option values (as expected by JS-Beautify)
  • Extension console logs configuration options used for formatting

Version 1.4

  • Added commands to format as specific syntax
  • Removed Format selection
  • Automatically formats any selected text or the whole document if there was no selection

Version 1.3

  • Added config options for add spaces around combinators (CSS, SCSS & LESS)

Version 1.2

  • Added config options for unformatted tags, unformatted content and extra lines before (HTML & XML)

Version 1.1

  • Line ending setting is inherited from the open document
  • Main configuration options of JS-Beautify can be set globally

Version 1.0

  • Initial release