From 85d0f19e37b048bba5813b4b0e4f8c91cccf8568 Mon Sep 17 00:00:00 2001 From: Daniel Brodin Date: Tue, 25 Oct 2016 10:19:26 +0200 Subject: [PATCH 01/64] Use local phpcs config file if available. --- package.json | 6 +++++- src/beautifiers/phpcbf.coffee | 4 ++++ src/languages/php.coffee | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 497e15c..23ec485 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,10 @@ { "name": "Victor Uriarte", "url": "https://github.com/vmuriart" + }, + { + "name": "Daniel Brodin", + "url": "https://github.com/danielbrodin" } ], "engines": { @@ -301,4 +305,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} \ No newline at end of file +} diff --git a/src/beautifiers/phpcbf.coffee b/src/beautifiers/phpcbf.coffee index 67ebd2f..414ff37 100644 --- a/src/beautifiers/phpcbf.coffee +++ b/src/beautifiers/phpcbf.coffee @@ -20,6 +20,10 @@ module.exports = class PHPCBF extends Beautifier beautify: (text, language, options) -> @debug('phpcbf', options) + standardFiles = ['phpcs.xml', 'phpcs.xml.dist', 'phpcs.ruleset.xml', 'ruleset.xml'] + standardFile = @findFile(atom.project.getPaths()[0], standardFiles); + + options.standard = standardFile if standardFile isWin = @isWindows if isWin diff --git a/src/languages/php.coffee b/src/languages/php.coffee index c50aa8a..66899e5 100644 --- a/src/languages/php.coffee +++ b/src/languages/php.coffee @@ -42,6 +42,6 @@ module.exports = { title: "PHPCBF Standard" type: 'string' default: "", - description: "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules" + description: "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root." } From b6c3d7dad3f7449a889a496ff1dfe5212249102a Mon Sep 17 00:00:00 2001 From: guyskk Date: Sun, 6 Nov 2016 14:56:46 +0000 Subject: [PATCH 02/64] fix #585: Add option to disable the loading notification --- src/beautify.coffee | 7 ++++--- src/config.coffee | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/beautify.coffee b/src/beautify.coffee index c188d20..0a6afd6 100644 --- a/src/beautify.coffee +++ b/src/beautify.coffee @@ -56,9 +56,10 @@ setCursors = (editor, posArray) -> # Show beautification progress/loading view beautifier.on('beautify::start', -> - LoadingView ?= require "./views/loading-view" - loadingView ?= new LoadingView() - loadingView.show() + if atom.config.get("atom-beautify.general.showLoadingView") + LoadingView ?= require "./views/loading-view" + loadingView ?= new LoadingView() + loadingView.show() ) beautifier.on('beautify::end', -> loadingView?.hide() diff --git a/src/config.coffee b/src/config.coffee index 6d3a80d..5c6ceaf 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -42,4 +42,9 @@ module.exports = { type : 'boolean' default : false description : "Do not show any/all errors when they occur" + showLoadingView : + title: "Show Loading View" + type : 'boolean' + default : true + description : "Show loading view when beautifying" } From d85bd22bcb4bd19e9ebd81b20a9cf9084586fc78 Mon Sep 17 00:00:00 2001 From: guyskk Date: Sun, 20 Nov 2016 09:23:36 +0000 Subject: [PATCH 03/64] add pybeautifier --- package.json | 5 +++ src/beautifiers/index.coffee | 1 + src/beautifiers/pybeautifier.coffee | 66 +++++++++++++++++++++++++++++ src/languages/python.coffee | 23 +++++++++- 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 src/beautifiers/pybeautifier.coffee diff --git a/package.json b/package.json index 497e15c..95ceb9f 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,10 @@ { "name": "Victor Uriarte", "url": "https://github.com/vmuriart" + }, + { + "name": "guyskk", + "url": "https://github.com/guyskk" } ], "engines": { @@ -288,6 +292,7 @@ "clojure beautifier", "nunjucks", "ux markup", + "pybeautifier", "cljfmt" ], "devDependencies": { diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 704ed86..6e1a5c2 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -57,6 +57,7 @@ module.exports = class Beautifiers extends EventEmitter 'php-cs-fixer' 'phpcbf' 'prettydiff' + 'pybeautifier' 'pug-beautify' 'puppet-fix' 'remark' diff --git a/src/beautifiers/pybeautifier.coffee b/src/beautifiers/pybeautifier.coffee new file mode 100644 index 0000000..692a8fb --- /dev/null +++ b/src/beautifiers/pybeautifier.coffee @@ -0,0 +1,66 @@ +'use strict' +net = require('net') +Beautifier = require('./beautifier') + +HOST = '127.0.0.1' +PORT = 36805 +MULTI_LINE_OUTPUT_TABLE = { + 'Grid': 0, + 'Vertical': 1, + 'Hanging Indent': 2, + 'Vertical Hanging Indent': 3, + 'Hanging Grid': 4, + 'Hanging Grid Grouped': 5, + 'NOQA': 6 +} + +format = (data, formaters) -> + return new Promise (resolve, reject) -> + client = new net.Socket() + client.on 'error', (error) -> + client.destroy() + reject(error) + client.connect PORT, HOST, -> + client.setEncoding('utf8') + client.write(JSON.stringify({'data': data, 'formaters': formaters})) + response = '' + client.on 'data', (chunk) -> + response += chunk + client.on 'end', -> + response = JSON.parse(response) + if response.error? + reject(Error(response.error)) + else + resolve(response.data) + client.destroy() + +module.exports = class PythonBeautifier extends Beautifier + + name: "pybeautifier" + link: "https://github.com/guyskk/pybeautifier" + + options: { + Python: true + } + + beautify: (text, language, options) -> + formater = {'name': options.formater} + if options.formater == 'autopep8' + formater.config = { + 'ignore': options.ignore + 'max_line_length': options.max_line_length + } + else if options.formater == 'yapf' + formater.config = {'style_config': options.style_config} + formaters = [formater] + if options.sort_imports + multi_line_output = MULTI_LINE_OUTPUT_TABLE[options.multi_line_output] + formaters.push + 'name': 'isort' + 'config': {'multi_line_output': multi_line_output} + return new @Promise (resolve, reject) -> + format(text, formaters) + .then (data) -> + resolve(data) + .catch (error) -> + reject(error) diff --git a/src/languages/python.coffee b/src/languages/python.coffee index f598815..d62e0f5 100644 --- a/src/languages/python.coffee +++ b/src/languages/python.coffee @@ -41,9 +41,30 @@ module.exports = { items: type: 'string' description: "do not fix these errors/warnings" + formater: + type: 'string' + default: 'autopep8' + enum: ['autopep8', 'yapf'] + description: "formater used by pybeautifier" + style_config: + type: 'string' + default: 'pep8' + description: "formatting style used by yapf" sort_imports: type: 'boolean' default: false description: "sort imports (requires isort installed)" - + multi_line_output: + type: 'string' + default: 'Hanging Grid Grouped' + enum: [ + 'Grid' + 'Vertical' + 'Hanging Indent' + 'Vertical Hanging Indent' + 'Hanging Grid' + 'Hanging Grid Grouped' + 'NOQA' + ] + description: "defines how from imports wrap (requires isort installed)" } From 4a660f9e5a20b8b63c8d9a30f97269afc3d065e9 Mon Sep 17 00:00:00 2001 From: guyskk Date: Sun, 20 Nov 2016 09:24:36 +0000 Subject: [PATCH 04/64] update document via npm run docs --- README.md | 32 ++-- docs/options.md | 410 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 399 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 4a159f4..fc74dec 100644 --- a/README.md +++ b/README.md @@ -46,18 +46,18 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify` By default `Anonymous Analytics` is enabled. If you do not wish to have usage data sent to Google Analytics then please disable `Anonymous Analytics` option before using Atom-Beautify. -See [`Anonymous Analytics` section of docs](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md#anonymous-analytics) for details. +See [`Anonymous Analytics` section of docs](docs/options.md#anonymous-analytics) for details. Thank you. ### Next Version: [Unibeautify](https://github.com/Unibeautify/unibeautify) Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core! -See [`unibeautify` branch](https://github.com/Glavin001/atom-beautify/tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174). +See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174). ## Language Support -See [all supported options in the documentation at `docs/options.md`](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md). +See [all supported options in the documentation at `docs/options.md`](docs/options.md). | Language | Grammars | File Extensions | Supported Beautifiers | | --- | --- | --- | ---- | @@ -99,9 +99,9 @@ See [all supported options in the documentation at `docs/options.md`](https://g | OCaml | `OCaml` |`.ml` | [`ocp-indent`](https://www.typerex.org/ocp-indent.html) (Default) | | Pawn | `Pawn` | | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | | Perl | `Perl`, `Perl 6` |`.pl` | [`Perltidy`](http://perltidy.sourceforge.net/) (Default) | -| PHP | `PHP` |`.php`, `.module`, `.inc` | [`PHP-CS-Fixer`](http://php.net/manual/en/install.php) (Default), [`PHPCBF`](http://php.net/manual/en/install.php) | +| PHP | `PHP` |`.php`, `.module`, `.inc` | [`PHP-CS-Fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (Default), [`PHPCBF`](http://php.net/manual/en/install.php) | | Puppet | `Puppet` |`.pp` | [`puppet-lint`](http://puppet-lint.com/) (Default) | -| Python | `Python` |`.py` | [`autopep8`](https://github.com/hhatto/autopep8) (Default), [`yapf`](https://github.com/google/yapf) | +| Python | `Python` |`.py` | [`autopep8`](https://github.com/hhatto/autopep8) (Default), [`pybeautifier`](https://github.com/guyskk/pybeautifier), [`yapf`](https://github.com/google/yapf) | | R | `R` |`.r`, `.R` | [`formatR`](https://github.com/yihui/formatR) (Default) | | Riot.js | `Riot.js`, `HTML (Riot Tag)` |`.tag` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Ruby | `Ruby`, `Ruby on Rails` |`.rb` | [`Rubocop`](https://github.com/bbatsov/rubocop) (Default), [`Ruby Beautify`](https://github.com/erniebrodeur/ruby-beautify) | @@ -165,22 +165,22 @@ For example: Edit your `.jsbeautifyrc` file in any of the following locations: -- Atom Package Settings +- Atom Package Settings `Atom` ➔ `Preferences` ➔ Search for `atom-beautify` - Same directory as current file -- Project root +- Project root `atom-beautify` will recursively look up from the current file's directory to find `.jsbeautifyrc`. - Your user's home directory **Note**: *Comments are supported in `.jsbeautifyrc` thanks to [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).* -See examples of both ways inside [`examples/`](https://github.com/donaldpipowitch/atom-beautify/tree/master/examples) +See examples of both ways inside [`examples/`](examples) -See [all supported options in the documentation at `docs/options.md`](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md). +See [all supported options in the documentation at `docs/options.md`](docs/options.md). ### Simple -See [examples/simple-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/simple-jsbeautifyrc/.jsbeautifyrc). +See [examples/simple-jsbeautifyrc/.jsbeautifyrc](examples/simple-jsbeautifyrc/.jsbeautifyrc). ```json { @@ -198,7 +198,7 @@ See [examples/simple-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowi ### Nested (Recommended) -See [examples/nested-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/nested-jsbeautifyrc/.jsbeautifyrc). +See [examples/nested-jsbeautifyrc/.jsbeautifyrc](examples/nested-jsbeautifyrc/.jsbeautifyrc). ```json { @@ -236,16 +236,16 @@ See [examples/nested-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowi ## Troubleshooting -See [`docs/troubleshooting.md`](https://github.com/Glavin001/atom-beautify/blob/master/docs/troubleshooting.md). +See [`docs/troubleshooting.md`](docs/troubleshooting.md). ## Contributing -[See all contributors on GitHub](https://github.com/donaldpipowitch/atom-beautify/graphs/contributors). +[See all contributors on GitHub](../../graphs/contributors). -Please update the [CHANGELOG.md](https://github.com/donaldpipowitch/atom-beautify/blob/master/CHANGELOG.md), -add yourself as a contributor to the [package.json](https://github.com/donaldpipowitch/atom-beautify/blob/master/package.json), +Please update the [CHANGELOG.md](CHANGELOG.md), +add yourself as a contributor to the [package.json](package.json), and submit a [Pull Request on GitHub](https://help.github.com/articles/using-pull-requests/). ## License -[MIT](https://github.com/donaldpipowitch/atom-beautify/blob/master/LICENSE.md) © [Glavin Wiechert](https://github.com/Glavin001) +[MIT](LICENSE.md) © [Glavin Wiechert](https://github.com/Glavin001) diff --git a/docs/options.md b/docs/options.md index bcdd89e..d484f1d 100644 --- a/docs/options.md +++ b/docs/options.md @@ -8363,17 +8363,20 @@ Automatically beautify Puppet files on save #### [Python](#python) -**Supported Beautifiers**: [`autopep8`](#autopep8) [`yapf`](#yapf) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) [`yapf`](#yapf) -| Option | autopep8 | yapf | -| --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | -| `ignore` | :white_check_mark: | :x: | -| `indent_size` | :white_check_mark: | :x: | -| `max_line_length` | :white_check_mark: | :x: | -| `sort_imports` | :white_check_mark: | :x: | +| Option | autopep8 | pybeautifier | yapf | +| --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `formater` | :white_check_mark: | :white_check_mark: | :x: | +| `ignore` | :white_check_mark: | :white_check_mark: | :x: | +| `indent_size` | :white_check_mark: | :white_check_mark: | :x: | +| `max_line_length` | :white_check_mark: | :white_check_mark: | :x: | +| `multi_line_output` | :white_check_mark: | :white_check_mark: | :x: | +| `sort_imports` | :white_check_mark: | :white_check_mark: | :x: | +| `style_config` | :white_check_mark: | :white_check_mark: | :x: | **Description**: @@ -8404,7 +8407,7 @@ Disable Python Beautification **Type**: `string` -**Enum**: `autopep8` `yapf` +**Enum**: `autopep8` `pybeautifier` `yapf` **Description**: @@ -8434,6 +8437,34 @@ Automatically beautify Python files on save 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Beautify On Save*" and change it to your desired configuration. +##### [Formater](#formater) + +**Namespace**: `python` + +**Key**: `formater` + +**Default**: `autopep8` + +**Type**: `string` + +**Enum**: `autopep8` `yapf` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +formater used by pybeautifier (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "formater": "autopep8" + } +} +``` + ##### [Ignore](#ignore) **Namespace**: `python` @@ -8444,11 +8475,11 @@ Automatically beautify Python files on save **Type**: `array` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -do not fix these errors/warnings (Supported by autopep8) +do not fix these errors/warnings (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -8472,11 +8503,11 @@ do not fix these errors/warnings (Supported by autopep8) **Type**: `integer` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -Indentation size/length (Supported by autopep8) +Indentation size/length (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -8498,11 +8529,11 @@ Indentation size/length (Supported by autopep8) **Type**: `integer` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -set maximum allowed line length (Supported by autopep8) +set maximum allowed line length (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -8514,6 +8545,34 @@ set maximum allowed line length (Supported by autopep8) } ``` +##### [Multi line output](#multi-line-output) + +**Namespace**: `python` + +**Key**: `multi_line_output` + +**Default**: `Hanging Grid Grouped` + +**Type**: `string` + +**Enum**: `Grid` `Vertical` `Hanging Indent` `Vertical Hanging Indent` `Hanging Grid` `Hanging Grid Grouped` `NOQA` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +defines how from imports wrap (requires isort installed) (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "multi_line_output": "Hanging Grid Grouped" + } +} +``` + ##### [Sort imports](#sort-imports) **Namespace**: `python` @@ -8522,11 +8581,11 @@ set maximum allowed line length (Supported by autopep8) **Type**: `boolean` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -sort imports (requires isort installed) (Supported by autopep8) +sort imports (requires isort installed) (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -8538,6 +8597,32 @@ sort imports (requires isort installed) (Supported by autopep8) } ``` +##### [Style config](#style-config) + +**Namespace**: `python` + +**Key**: `style_config` + +**Default**: `pep8` + +**Type**: `string` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +formatting style used by yapf (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "style_config": "pep8" + } +} +``` + #### [R](#r) **Supported Beautifiers**: [`formatR`](#formatr) @@ -16782,11 +16867,11 @@ List of tags (defaults to [head,body,/html] that should have an extra newline be **Type**: `integer` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -set maximum allowed line length (Supported by autopep8) +set maximum allowed line length (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -16808,11 +16893,11 @@ set maximum allowed line length (Supported by autopep8) **Type**: `integer` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -Indentation size/length (Supported by autopep8) +Indentation size/length (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -16834,11 +16919,11 @@ Indentation size/length (Supported by autopep8) **Type**: `array` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -do not fix these errors/warnings (Supported by autopep8) +do not fix these errors/warnings (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -16852,6 +16937,60 @@ do not fix these errors/warnings (Supported by autopep8) } ``` +##### [Formater](#formater) + +**Namespace**: `python` + +**Key**: `formater` + +**Default**: `autopep8` + +**Type**: `string` + +**Enum**: `autopep8` `yapf` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +formater used by pybeautifier (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "formater": "autopep8" + } +} +``` + +##### [Style config](#style-config) + +**Namespace**: `python` + +**Key**: `style_config` + +**Default**: `pep8` + +**Type**: `string` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +formatting style used by yapf (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "style_config": "pep8" + } +} +``` + ##### [Sort imports](#sort-imports) **Namespace**: `python` @@ -16860,11 +16999,11 @@ do not fix these errors/warnings (Supported by autopep8) **Type**: `boolean` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -sort imports (requires isort installed) (Supported by autopep8) +sort imports (requires isort installed) (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -16876,6 +17015,34 @@ sort imports (requires isort installed) (Supported by autopep8) } ``` +##### [Multi line output](#multi-line-output) + +**Namespace**: `python` + +**Key**: `multi_line_output` + +**Default**: `Hanging Grid Grouped` + +**Type**: `string` + +**Enum**: `Grid` `Vertical` `Hanging Indent` `Vertical Hanging Indent` `Hanging Grid` `Hanging Grid Grouped` `NOQA` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +defines how from imports wrap (requires isort installed) (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "multi_line_output": "Hanging Grid Grouped" + } +} +``` + ### coffee-fmt @@ -16985,6 +17152,195 @@ Indentation size/length (Supported by formatR) ``` +### pybeautifier + +##### [Max line length](#max-line-length) + +**Namespace**: `python` + +**Key**: `max_line_length` + +**Default**: `79` + +**Type**: `integer` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +set maximum allowed line length (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "max_line_length": 79 + } +} +``` + +##### [Indent size](#indent-size) + +**Namespace**: `python` + +**Key**: `indent_size` + +**Default**: `4` + +**Type**: `integer` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +Indentation size/length (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "indent_size": 4 + } +} +``` + +##### [Ignore](#ignore) + +**Namespace**: `python` + +**Key**: `ignore` + +**Default**: `E24` + +**Type**: `array` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +do not fix these errors/warnings (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "ignore": [ + "E24" + ] + } +} +``` + +##### [Formater](#formater) + +**Namespace**: `python` + +**Key**: `formater` + +**Default**: `autopep8` + +**Type**: `string` + +**Enum**: `autopep8` `yapf` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +formater used by pybeautifier (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "formater": "autopep8" + } +} +``` + +##### [Style config](#style-config) + +**Namespace**: `python` + +**Key**: `style_config` + +**Default**: `pep8` + +**Type**: `string` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +formatting style used by yapf (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "style_config": "pep8" + } +} +``` + +##### [Sort imports](#sort-imports) + +**Namespace**: `python` + +**Key**: `sort_imports` + +**Type**: `boolean` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +sort imports (requires isort installed) (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "sort_imports": false + } +} +``` + +##### [Multi line output](#multi-line-output) + +**Namespace**: `python` + +**Key**: `multi_line_output` + +**Default**: `Hanging Grid Grouped` + +**Type**: `string` + +**Enum**: `Grid` `Vertical` `Hanging Indent` `Vertical Hanging Indent` `Hanging Grid` `Hanging Grid Grouped` `NOQA` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +defines how from imports wrap (requires isort installed) (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "multi_line_output": "Hanging Grid Grouped" + } +} +``` + + ### rustfmt ##### [Rustfmt path](#rustfmt-path) From 63947d851e3e8f7b6d9ef4369a765d4e44291816 Mon Sep 17 00:00:00 2001 From: s4l1h Date: Fri, 13 Jan 2017 01:27:28 +0300 Subject: [PATCH 05/64] Golang template support. --- README.md | 1 + src/beautifiers/prettydiff.coffee | 3 +++ src/languages/gohtml.coffee | 26 ++++++++++++++++++++++++++ src/languages/index.coffee | 1 + 4 files changed, 31 insertions(+) create mode 100644 src/languages/gohtml.coffee diff --git a/README.md b/README.md index da87ff0..a30dbc1 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | gherkin | `Gherkin` |`.feature` | [`Gherkin formatter`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee) (Default) | | GLSL | `C`, `opencl`, `GLSL` |`.vert`, `.frag` | [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) (Default) | | Go | `Go` |`.go` | [`gofmt`](https://golang.org/cmd/gofmt/) (Default) | +| Golang Template | `HTML (Go)`, `Go Template` |`.gohtml` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Handlebars | `Handlebars`, `HTML (Handlebars)` |`.hbs`, `.handlebars` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | Haskell | `Haskell` |`.hs` | [`stylish-haskell`](https://github.com/jaspervdj/stylish-haskell) (Default) | | HTML | `HTML` |`.html` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | diff --git a/src/beautifiers/prettydiff.coffee b/src/beautifiers/prettydiff.coffee index 2be957e..c7cc55f 100644 --- a/src/beautifiers/prettydiff.coffee +++ b/src/beautifiers/prettydiff.coffee @@ -66,6 +66,7 @@ module.exports = class PrettyDiff extends Beautifier Visualforce: true "Riot.js": true XTemplate: true + "Golang Template": true } beautify: (text, language, options) -> @@ -109,6 +110,8 @@ module.exports = class PrettyDiff extends Beautifier lang = "scss" when "TSS" lang = "tss" + when "Golang Template" + lang = "gohtml" else lang = "auto" diff --git a/src/languages/gohtml.coffee b/src/languages/gohtml.coffee new file mode 100644 index 0000000..c237043 --- /dev/null +++ b/src/languages/gohtml.coffee @@ -0,0 +1,26 @@ +module.exports = { + + name: "Golang Template" + description: "Comma-Separated Values" + namespace: "gohtml" + + ### + Supported Grammars + ### + grammars: [ + "HTML (Go)", + "Go Template" + ] + + ### + Supported extensions + ### + extensions: [ + 'gohtml' + ] + + defaultBeautifier: "Pretty Diff" + + options: [] + +} diff --git a/src/languages/index.coffee b/src/languages/index.coffee index d41c759..280324b 100644 --- a/src/languages/index.coffee +++ b/src/languages/index.coffee @@ -32,6 +32,7 @@ module.exports = class Languages "gherkin" "glsl" "go" + "gohtml" "fortran" "handlebars" "haskell" From bf91dd2d7a4979fa35ec696ce46a2245862d659b Mon Sep 17 00:00:00 2001 From: s4l1h Date: Fri, 13 Jan 2017 01:48:16 +0300 Subject: [PATCH 06/64] Golang template support added doc. --- docs/options.md | 177 ++++++++++++++++++++++++++++++++++++ package.json | 3 +- src/languages/gohtml.coffee | 1 + 3 files changed, 180 insertions(+), 1 deletion(-) diff --git a/docs/options.md b/docs/options.md index 6bb63b3..37a590a 100644 --- a/docs/options.md +++ b/docs/options.md @@ -3685,6 +3685,183 @@ Automatically beautify Go files on save 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Beautify On Save*" and change it to your desired configuration. +#### [Golang Template](#golang-template) + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +| Option | Pretty Diff | +| --- | --- | +| `disabled` | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | +| `indent_char` | :white_check_mark: | +| `indent_size` | :white_check_mark: | +| `preserve_newlines` | :white_check_mark: | +| `wrap_line_length` | :white_check_mark: | + +**Description**: + +Options for language Golang Template + +##### [Disable Beautifying Language](#disable-beautifying-language) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Disable Golang Template Beautification + +**How to Configure** + +1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to +*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*. +2. Go into *Packages* and search for "*Atom Beautify*" package. +3. Find the option "*Disable Beautifying Language*" and change it to your desired configuration. + +##### [Default Beautifier](#default-beautifier) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `Pretty Diff` + +**Type**: `string` + +**Enum**: `Pretty Diff` + +**Description**: + +Default Beautifier to be used for Golang Template + +**How to Configure** + +1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to +*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*. +2. Go into *Packages* and search for "*Atom Beautify*" package. +3. Find the option "*Default Beautifier*" and change it to your desired configuration. + +##### [Beautify On Save](#beautify-on-save) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Automatically beautify Golang Template files on save + +**How to Configure** + +1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to +*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*. +2. Go into *Packages* and search for "*Atom Beautify*" package. +3. Find the option "*Beautify On Save*" and change it to your desired configuration. + +##### [Indent char](#indent-char) + +**Namespace**: `html` + +**Key**: `indent_char` + +**Default**: ` ` + +**Type**: `string` + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +**Description**: + +Indentation character (Supported by Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "html": { + "indent_char": " " + } +} +``` + +##### [Indent size](#indent-size) + +**Namespace**: `html` + +**Key**: `indent_size` + +**Default**: `4` + +**Type**: `integer` + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +**Description**: + +Indentation size/length (Supported by Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "html": { + "indent_size": 4 + } +} +``` + +##### [Preserve newlines](#preserve-newlines) + +**Namespace**: `html` + +**Key**: `preserve_newlines` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +**Description**: + +Preserve line-breaks (Supported by Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "html": { + "preserve_newlines": true + } +} +``` + +##### [Wrap line length](#wrap-line-length) + +**Namespace**: `html` + +**Key**: `wrap_line_length` + +**Default**: `250` + +**Type**: `integer` + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +**Description**: + +Maximum characters per line (0 disables) (Supported by Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "html": { + "wrap_line_length": 250 + } +} +``` + #### [Handlebars](#handlebars) **Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) diff --git a/package.json b/package.json index a9f5bad..66b3df3 100644 --- a/package.json +++ b/package.json @@ -291,7 +291,8 @@ "bash", "beautysh", "glsl", - "hh_format" + "hh_format", + "golang template" ], "devDependencies": { "coffeelint": "^1.10.1", diff --git a/src/languages/gohtml.coffee b/src/languages/gohtml.coffee index c237043..76fdf67 100644 --- a/src/languages/gohtml.coffee +++ b/src/languages/gohtml.coffee @@ -3,6 +3,7 @@ module.exports = { name: "Golang Template" description: "Comma-Separated Values" namespace: "gohtml" + fallback: ["html"] ### Supported Grammars From 40a1a4237a80375ad4e94003f8930b527459d77f Mon Sep 17 00:00:00 2001 From: s4l1h Date: Fri, 13 Jan 2017 14:31:50 +0300 Subject: [PATCH 07/64] Latest version prettydiff --- package.json | 2 +- src/beautifiers/prettydiff.coffee | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 66b3df3..542475b 100644 --- a/package.json +++ b/package.json @@ -144,7 +144,7 @@ "node-cljfmt": "^0.5.3-1", "node-uuid": "^1.4.3", "open": "0.0.5", - "prettydiff": "^1.16.27", + "prettydiff": "git+https://github.com/prettydiff/prettydiff.git#master", "pug-beautify": "^0.1.1", "remark": "^6.0.1", "season": "^5.3.0", diff --git a/src/beautifiers/prettydiff.coffee b/src/beautifiers/prettydiff.coffee index c7cc55f..254be56 100644 --- a/src/beautifiers/prettydiff.coffee +++ b/src/beautifiers/prettydiff.coffee @@ -111,7 +111,7 @@ module.exports = class PrettyDiff extends Beautifier when "TSS" lang = "tss" when "Golang Template" - lang = "gohtml" + lang = "go" else lang = "auto" @@ -126,8 +126,7 @@ module.exports = class PrettyDiff extends Beautifier # Beautify @verbose('prettydiff', options) - output = prettydiff.api(options) - result = output[0] + result = prettydiff(options) # Return beautified text resolve(result) From 6f9f36ac4a9e592e51e90a3611d5a83d25f5a44f Mon Sep 17 00:00:00 2001 From: s4l1h Date: Fri, 13 Jan 2017 23:21:46 +0300 Subject: [PATCH 08/64] reverte prettydiff version 1.16.27 --- package.json | 2 +- src/beautifiers/prettydiff.coffee | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 542475b..66b3df3 100644 --- a/package.json +++ b/package.json @@ -144,7 +144,7 @@ "node-cljfmt": "^0.5.3-1", "node-uuid": "^1.4.3", "open": "0.0.5", - "prettydiff": "git+https://github.com/prettydiff/prettydiff.git#master", + "prettydiff": "^1.16.27", "pug-beautify": "^0.1.1", "remark": "^6.0.1", "season": "^5.3.0", diff --git a/src/beautifiers/prettydiff.coffee b/src/beautifiers/prettydiff.coffee index 254be56..21c6a99 100644 --- a/src/beautifiers/prettydiff.coffee +++ b/src/beautifiers/prettydiff.coffee @@ -126,7 +126,8 @@ module.exports = class PrettyDiff extends Beautifier # Beautify @verbose('prettydiff', options) - result = prettydiff(options) + output = prettydiff.api(options) + result = output[0] # Return beautified text resolve(result) From 46d49750e4b32baf536fafeb2e401dfedd630623 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Tue, 24 Jan 2017 21:59:11 -0400 Subject: [PATCH 09/64] See #1432. Improves JS-Beautify beautifier so it will throw error when missing language See #1458, #1471, #1483, #136, #1452 --- src/beautifiers/js-beautify.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/beautifiers/js-beautify.coffee b/src/beautifiers/js-beautify.coffee index 7092e23..902a86f 100644 --- a/src/beautifiers/js-beautify.coffee +++ b/src/beautifiers/js-beautify.coffee @@ -53,6 +53,8 @@ module.exports = class JSBeautify extends Beautifier beautifyCSS = require("js-beautify").css text = beautifyCSS(text, options) resolve text + else + reject(new Error("Unknown language for JS Beautify: "+language)) catch err @error("JS Beautify error: #{err}") reject(err) From cdb52a873d1b025faace99b566cc4f790f061325 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Tue, 24 Jan 2017 22:01:11 -0400 Subject: [PATCH 10/64] Prepare 0.29.17 release --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a9f5bad..a91d8a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom-beautify", "main": "./src/beautify", - "version": "0.29.16", + "version": "0.29.17", "private": true, "description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more in Atom", "repository": { @@ -305,4 +305,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} \ No newline at end of file +} From afee0a47c9ff662203ea0f12725706b2372b3bcc Mon Sep 17 00:00:00 2001 From: Denys Vitali Date: Mon, 30 Jan 2017 15:38:05 +0100 Subject: [PATCH 11/64] Add support for nginx --- .../nginx/expected/nginx.conf | 203 ++++++++++++++++++ .../nginx/original/nginx.conf | 194 +++++++++++++++++ package.json | 3 +- script/build-options.js | 2 +- src/beautifiers/index.coffee | 1 + src/beautifiers/nginx-beautify.coffee | 22 ++ src/languages/index.coffee | 1 + src/languages/nginx.coffee | 38 ++++ 8 files changed, 462 insertions(+), 2 deletions(-) create mode 100644 examples/nested-jsbeautifyrc/nginx/expected/nginx.conf create mode 100644 examples/nested-jsbeautifyrc/nginx/original/nginx.conf create mode 100644 src/beautifiers/nginx-beautify.coffee create mode 100644 src/languages/nginx.coffee diff --git a/examples/nested-jsbeautifyrc/nginx/expected/nginx.conf b/examples/nested-jsbeautifyrc/nginx/expected/nginx.conf new file mode 100644 index 0000000..866efd8 --- /dev/null +++ b/examples/nested-jsbeautifyrc/nginx/expected/nginx.conf @@ -0,0 +1,203 @@ + +#user html; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +error_log logs/error.log info; + +#pid logs/nginx.pid; + +events +{ + worker_connections 1024; +} + + +http +{ + include mime.types; + default_type application/octet-stream; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + + server + { + listen 80; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + location / + { + root /usr/share/nginx/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html + { + root /usr/share/nginx/html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + } + + + server + { + listen 80; + include mime.types; + server_name dv; + location /nginxstatic/ + { + alias /srv/http/dv/; + limit_rate 250k; + } + + location / + { + #root /srv/http/dv/; + #index index.html; + limit_rate 1M; + #limit_conn addr 1; + proxy_pass http://localhost:3000/; + } + } + + server + { + listen 80; + server_name ip.dv; + root /home/http/ip/; + include mime.types; + location / + { + try_files $uri $uri/ /index.php; + } + location ~ .php$ + { + try_files $uri =404; + fastcgi_pass unix:/var/run/php5-fpm/socket_name.socket; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + } + + server + { + listen 80; + server_name pma.dv; + location / + { + root /home/http/pma/; + index index.php; + } + + location ~ \.php$ + { + fastcgi_pass unix:/run/php-fpm/php-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME /home/http/pma/$fastcgi_script_name; + include fastcgi_params; + } + } + server + { + listen 80; + server_name swissecurity.coelis; + location / + { + root /srv/http/swissecurity-fm/; + index index.html; + } + } + + server + { + listen 80; + server_name p1.dv; + location / + { + proxy_pass http://127.0.0.1:1337/; + } + } + + + server + { + listen 80; + server_name s.dev; + location / + { + proxy_pass http://127.0.0.1:1337/; + } + } + + + # another virtual host using mix of IP-, name-, and port-based configuration + # + #server { + # listen 8000; + # listen somename:8080; + # server_name somename alias another.alias; + # location / { + # root html; + # index index.html index.htm; + # } + #} + # HTTPS server + # + #server { + # listen 443 ssl; + # server_name localhost; + # ssl_certificate cert.pem; + # ssl_certificate_key cert.key; + # ssl_session_cache shared:SSL:1m; + # ssl_session_timeout 5m; + # ssl_ciphers HIGH:!aNULL:!MD5; + # ssl_prefer_server_ciphers on; + # location / { + # root html; + # index index.html index.htm; + # } + #} +} diff --git a/examples/nested-jsbeautifyrc/nginx/original/nginx.conf b/examples/nested-jsbeautifyrc/nginx/original/nginx.conf new file mode 100644 index 0000000..42475dc --- /dev/null +++ b/examples/nested-jsbeautifyrc/nginx/original/nginx.conf @@ -0,0 +1,194 @@ + +#user html; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +error_log logs/error.log info; + +#pid logs/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + + server { + listen 80; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + } + + + server { + listen 80; + include mime.types; + server_name dv; + location /nginxstatic/ { + alias /srv/http/dv/; + limit_rate 250k; + } + + location / { + #root /srv/http/dv/; + #index index.html; + limit_rate 1M; + #limit_conn addr 1; + proxy_pass http://localhost:3000/; + } + } + + server { + listen 80; + server_name ip.dv; + root /home/http/ip/; + include mime.types; + location / { + try_files $uri $uri/ /index.php; + } + location ~ .php$ { + try_files $uri =404; + fastcgi_pass unix:/var/run/php5-fpm/socket_name.socket; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + } + + server { + listen 80; + server_name pma.dv; + location / { + root /home/http/pma/; + index index.php; + } + + location ~ \.php$ { + fastcgi_pass unix:/run/php-fpm/php-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME /home/http/pma/$fastcgi_script_name; + include fastcgi_params; + } + } + server { + listen 80; + server_name swissecurity.coelis; + location / { + root /srv/http/swissecurity-fm/; + index index.html; + } + } + + server { + listen 80; + server_name p1.dv; + location / { + proxy_pass http://127.0.0.1:1337/; + } + } + + + server { listen 80; + server_name s.dev; + location / { + proxy_pass http://127.0.0.1:1337/; + } + } + + + # another virtual host using mix of IP-, name-, and port-based configuration + # + #server { + # listen 8000; + # listen somename:8080; + # server_name somename alias another.alias; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + + + # HTTPS server + # + #server { + # listen 443 ssl; + # server_name localhost; + + # ssl_certificate cert.pem; + # ssl_certificate_key cert.key; + + # ssl_session_cache shared:SSL:1m; + # ssl_session_timeout 5m; + + # ssl_ciphers HIGH:!aNULL:!MD5; + # ssl_prefer_server_ciphers on; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + +} diff --git a/package.json b/package.json index a91d8a9..3101e28 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,7 @@ "lodash": "^4.14.2", "loophole": "^1.0.0", "marko-prettyprint": "^1.2.0", + "nginxbeautify": "^2.0.0", "node-dir": "^0.1.16", "node-cljfmt": "^0.5.3-1", "node-uuid": "^1.4.3", @@ -305,4 +306,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file diff --git a/script/build-options.js b/script/build-options.js index a0d3d6c..526e0d8 100644 --- a/script/build-options.js +++ b/script/build-options.js @@ -215,7 +215,7 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) { if (_.isArray(objValue)) { return _.uniq(objValue.concat(srcValue)); } - } + } for (j = 0, len1 = allLanguages.length; j < len1; j++) { lang = allLanguages[j]; namespaceDest = lang.namespace; diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 077190e..bf8a550 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -53,6 +53,7 @@ module.exports = class Beautifiers extends EventEmitter 'js-beautify' 'jscs' 'lua-beautifier' + 'nginx-beautify' 'ocp-indent' 'perltidy' 'php-cs-fixer' diff --git a/src/beautifiers/nginx-beautify.coffee b/src/beautifiers/nginx-beautify.coffee new file mode 100644 index 0000000..9c4985f --- /dev/null +++ b/src/beautifiers/nginx-beautify.coffee @@ -0,0 +1,22 @@ +"use strict" +Beautifier = require('./beautifier') + +module.exports = class NginxBeautify extends Beautifier + name: "Nginx Beautify" + link: "https://github.com/denysvitali/nginxbeautify" + + options: { + Nginx: true + } + + beautify: (text, language, options) -> + + return new @Promise((resolve, reject) -> + Beautify = require("nginxbeautify") + instance = new Beautify(options); + try + resolve(instance.parse(text)) + catch error + # Error occurred + reject(error) + ) diff --git a/src/languages/index.coffee b/src/languages/index.coffee index d41c759..9214e89 100644 --- a/src/languages/index.coffee +++ b/src/languages/index.coffee @@ -47,6 +47,7 @@ module.exports = class Languages "markdown" 'marko' "mustache" + "nginx" "nunjucks" "objective-c" "ocaml" diff --git a/src/languages/nginx.coffee b/src/languages/nginx.coffee new file mode 100644 index 0000000..f9a9833 --- /dev/null +++ b/src/languages/nginx.coffee @@ -0,0 +1,38 @@ +module.exports = { + + name: "Nginx" + namespace: "nginx" + + ### + Supported Grammars + ### + grammars: [ + "nginx" + ] + + ### + Supported extensions + ### + extensions: [ + "conf" + ] + + defaultBeautifier: "Nginx Beautify" + + options: + spaces: + title: "Spaces" + type: "number" + default: 0 + description: "Indent with spaces" + tabs: + title: "Tabs" + type: "number" + default: 1 + description: "Indent with tabs" + dontJoinCurlyBracet: + title: "Don't join curly brackets" + type: "boolean" + default: true + descriotion: "" +} From 1a687b8327f009d8750073986c2afdfa27b8f130 Mon Sep 17 00:00:00 2001 From: Denys Vitali Date: Mon, 30 Jan 2017 15:39:06 +0100 Subject: [PATCH 12/64] Add contributor --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3101e28..8372835 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,10 @@ { "name": "Victor Uriarte", "url": "https://github.com/vmuriart" + }, + { + "name": "Denys Vitali", + "url": "https://github.com/denysvitali" } ], "engines": { @@ -306,4 +310,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} \ No newline at end of file +} From 0dd50d6bc6f623d04b57133ec645029debd5fe45 Mon Sep 17 00:00:00 2001 From: Denys Vitali Date: Mon, 30 Jan 2017 15:41:20 +0100 Subject: [PATCH 13/64] Add nginx to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index da87ff0..724fd77 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | Markdown | `GitHub Markdown` |`.markdown`, `.md` | [`Remark`](https://github.com/wooorm/remark), [`Tidy Markdown`](https://github.com/slang800/tidy-markdown) (Default) | | Marko | `Marko` |`.marko` | [`Marko Beautifier`](https://github.com/marko-js/marko-prettyprint) (Default) | | Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default) | +| Nginx | `nginx` |`.conf` | [`Nginx Beautify`](https://github.com/denysvitali/nginxbeautify) (Default) | | Nunjucks | `Nunjucks`, `Nunjucks Templates`, `HTML (Nunjucks Templates)` |`.njk`, `.nunjucks` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Objective-C | `Objective-C`, `Objective-C++` |`.m`, `.mm`, `.h` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | | OCaml | `OCaml` |`.ml` | [`ocp-indent`](https://www.typerex.org/ocp-indent.html) (Default) | From ed45ccec8725f7ca01e18d91255107f8bbb6c750 Mon Sep 17 00:00:00 2001 From: Denys Vitali Date: Mon, 30 Jan 2017 15:46:48 +0100 Subject: [PATCH 14/64] Add nginx to docs --- docs/options.md | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) diff --git a/docs/options.md b/docs/options.md index 6bb63b3..e3e4729 100644 --- a/docs/options.md +++ b/docs/options.md @@ -8511,6 +8511,154 @@ Maximum characters per line (0 disables) (Supported by JS Beautify) } ``` +#### [Nginx](#nginx) + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +| Option | Nginx Beautify | +| --- | --- | +| `disabled` | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | +| `dontJoinCurlyBracet` | :white_check_mark: | +| `spaces` | :white_check_mark: | +| `tabs` | :white_check_mark: | + +**Description**: + +Options for language Nginx + +##### [Disable Beautifying Language](#disable-beautifying-language) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Disable Nginx Beautification + +**How to Configure** + +1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to +*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*. +2. Go into *Packages* and search for "*Atom Beautify*" package. +3. Find the option "*Disable Beautifying Language*" and change it to your desired configuration. + +##### [Default Beautifier](#default-beautifier) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `Nginx Beautify` + +**Type**: `string` + +**Enum**: `Nginx Beautify` + +**Description**: + +Default Beautifier to be used for Nginx + +**How to Configure** + +1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to +*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*. +2. Go into *Packages* and search for "*Atom Beautify*" package. +3. Find the option "*Default Beautifier*" and change it to your desired configuration. + +##### [Beautify On Save](#beautify-on-save) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Automatically beautify Nginx files on save + +**How to Configure** + +1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to +*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*. +2. Go into *Packages* and search for "*Atom Beautify*" package. +3. Find the option "*Beautify On Save*" and change it to your desired configuration. + +##### [Don't join curly brackets](#don't-join-curly-brackets) + +**Namespace**: `nginx` + +**Key**: `dontJoinCurlyBracet` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +**Description**: + +undefined (Supported by Nginx Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "nginx": { + "dontJoinCurlyBracet": true + } +} +``` + +##### [Spaces](#spaces) + +**Namespace**: `nginx` + +**Key**: `spaces` + +**Type**: `number` + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +**Description**: + +Indent with spaces (Supported by Nginx Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "nginx": { + "spaces": 0 + } +} +``` + +##### [Tabs](#tabs) + +**Namespace**: `nginx` + +**Key**: `tabs` + +**Default**: `1` + +**Type**: `number` + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +**Description**: + +Indent with tabs (Supported by Nginx Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "nginx": { + "tabs": 1 + } +} +``` + #### [Nunjucks](#nunjucks) **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) @@ -16297,6 +16445,85 @@ List of tags (defaults to [head,body,/html] that should have an extra newline be ``` +### Nginx Beautify + +##### [Spaces](#spaces) + +**Namespace**: `nginx` + +**Key**: `spaces` + +**Type**: `number` + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +**Description**: + +Indent with spaces (Supported by Nginx Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "nginx": { + "spaces": 0 + } +} +``` + +##### [Tabs](#tabs) + +**Namespace**: `nginx` + +**Key**: `tabs` + +**Default**: `1` + +**Type**: `number` + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +**Description**: + +Indent with tabs (Supported by Nginx Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "nginx": { + "tabs": 1 + } +} +``` + +##### [Don't join curly brackets](#don't-join-curly-brackets) + +**Namespace**: `nginx` + +**Key**: `dontJoinCurlyBracet` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +**Description**: + +undefined (Supported by Nginx Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "nginx": { + "dontJoinCurlyBracet": true + } +} +``` + + ### PHP-CS-Fixer ##### [PHP-CS-Fixer Path](#php-cs-fixer-path) From 5a4349d486c1b901cbc486a50c5860a9964defd0 Mon Sep 17 00:00:00 2001 From: Denys Vitali Date: Mon, 30 Jan 2017 16:36:46 +0100 Subject: [PATCH 15/64] Fix trailing semicolon --- src/beautifiers/nginx-beautify.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/beautifiers/nginx-beautify.coffee b/src/beautifiers/nginx-beautify.coffee index 9c4985f..12fbed2 100644 --- a/src/beautifiers/nginx-beautify.coffee +++ b/src/beautifiers/nginx-beautify.coffee @@ -13,7 +13,7 @@ module.exports = class NginxBeautify extends Beautifier return new @Promise((resolve, reject) -> Beautify = require("nginxbeautify") - instance = new Beautify(options); + instance = new Beautify(options) try resolve(instance.parse(text)) catch error From d9f81e84eb9428d95f210655a38dbbe54ae7c2f9 Mon Sep 17 00:00:00 2001 From: Denys Vitali Date: Mon, 30 Jan 2017 16:38:35 +0100 Subject: [PATCH 16/64] Add nginx keywords --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8372835..6f17459 100644 --- a/package.json +++ b/package.json @@ -296,7 +296,9 @@ "bash", "beautysh", "glsl", - "hh_format" + "hh_format", + "nginx", + "nginx beautify" ], "devDependencies": { "coffeelint": "^1.10.1", @@ -310,4 +312,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file From 05f339bc9d66e84d74f5a1e39b32ccf0d3df4eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Fr=C3=B3es=20Silva?= Date: Tue, 7 Feb 2017 19:20:13 -0200 Subject: [PATCH 17/64] Adding CUDA --- src/languages/cpp.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/languages/cpp.coffee b/src/languages/cpp.coffee index 6f7c6f8..cd5fb0e 100644 --- a/src/languages/cpp.coffee +++ b/src/languages/cpp.coffee @@ -20,10 +20,12 @@ module.exports = { "cpp" "cxx" "C" + "cu" "c++" "hpp" "hxx" "h++" + "cuh" ] options: From ccfebd3150aa8071a1e2c8b2c61826fba40e75d4 Mon Sep 17 00:00:00 2001 From: Scott Larkin Date: Thu, 9 Feb 2017 12:05:54 -0500 Subject: [PATCH 18/64] Create .codeclimate.yml Created a Code Climate config with CoffeeLint enabled. --- codeclimate.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 codeclimate.yml diff --git a/codeclimate.yml b/codeclimate.yml new file mode 100644 index 0000000..4e5fda9 --- /dev/null +++ b/codeclimate.yml @@ -0,0 +1,9 @@ +engines: + coffeelint: + enabled: true + +ratings: + paths: + - "**.coffee" + +exclude_paths: From dce64c0eb14d730a58149bcf6ac6b85851677ada Mon Sep 17 00:00:00 2001 From: Scott Larkin Date: Thu, 9 Feb 2017 12:08:19 -0500 Subject: [PATCH 19/64] Update and rename codeclimate.yml to .codeclimate.yml --- codeclimate.yml => .codeclimate.yml | 3 +++ 1 file changed, 3 insertions(+) rename codeclimate.yml => .codeclimate.yml (70%) diff --git a/codeclimate.yml b/.codeclimate.yml similarity index 70% rename from codeclimate.yml rename to .codeclimate.yml index 4e5fda9..d537ddc 100644 --- a/codeclimate.yml +++ b/.codeclimate.yml @@ -1,9 +1,12 @@ engines: coffeelint: enabled: true + eslint: + enabled: true ratings: paths: - "**.coffee" + - "**.js" exclude_paths: From 87ed01e7befb00682950bb8e1b810e5bd895b106 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 20:37:21 +0900 Subject: [PATCH 20/64] Enable PHP-CS-Fixer Path option except Windows --- src/beautifiers/php-cs-fixer.coffee | 81 +++++++++++++++-------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index 0cf8f01..0b8ec16 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -19,21 +19,22 @@ module.exports = class PHPCSFixer extends Beautifier configFile = if context? and context.filePath? then @findFile(path.dirname(context.filePath), '.php_cs') - if @isWindows - # Find php-cs-fixer.phar script - @Promise.all([ - @which(options.cs_fixer_path) if options.cs_fixer_path - @which('php-cs-fixer') - ]).then((paths) => - @debug('php-cs-fixer paths', paths) - _ = require 'lodash' - # Get first valid, absolute path - phpCSFixerPath = _.find(paths, (p) -> p and path.isAbsolute(p) ) - @verbose('phpCSFixerPath', phpCSFixerPath) - @debug('phpCSFixerPath', phpCSFixerPath, paths) - # Check if PHP-CS-Fixer path was found - if phpCSFixerPath? - # Found PHP-CS-Fixer path + # Find php-cs-fixer.phar script + @Promise.all([ + @which(options.cs_fixer_path) if options.cs_fixer_path + @which('php-cs-fixer') + ]).then((paths) => + @debug('php-cs-fixer paths', paths) + _ = require 'lodash' + # Get first valid, absolute path + phpCSFixerPath = _.find(paths, (p) -> p and path.isAbsolute(p) ) + @verbose('phpCSFixerPath', phpCSFixerPath) + @debug('phpCSFixerPath', phpCSFixerPath, paths) + + # Check if PHP-CS-Fixer path was found + if phpCSFixerPath? + # Found PHP-CS-Fixer path + if @isWindows @run("php", [ phpCSFixerPath "fix" @@ -51,30 +52,30 @@ module.exports = class PHPCSFixer extends Beautifier @readFile(tempFile) ) else - @verbose('php-cs-fixer not found!') - # Could not find PHP-CS-Fixer path - @Promise.reject(@commandNotFoundError( - 'php-cs-fixer' - { - link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" - program: "php-cs-fixer.phar" - pathOption: "PHP - CS Fixer Path" + @run(phpCSFixerPath, [ + "fix" + "--level=#{options.level}" if options.level + "--fixers=#{options.fixers}" if options.fixers + "--config-file=#{configFile}" if configFile + tempFile = @tempFile("temp", text) + ], { + ignoreReturnCode: true + help: { + link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" + } }) - ) - ) - else - @run("php-cs-fixer", [ - "fix" - "--level=#{options.level}" if options.level - "--fixers=#{options.fixers}" if options.fixers - "--config-file=#{configFile}" if configFile - tempFile = @tempFile("temp", text) - ], { - ignoreReturnCode: true - help: { - link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" - } - }) - .then(=> - @readFile(tempFile) + .then(=> + @readFile(tempFile) + ) + else + @verbose('php-cs-fixer not found!') + # Could not find PHP-CS-Fixer path + @Promise.reject(@commandNotFoundError( + 'php-cs-fixer' + { + link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" + program: "php-cs-fixer.phar" + pathOption: "PHP - CS Fixer Path" + }) ) + ) From bf7586c858658040bd6d3a6da09587c34070b5e9 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 20:44:13 +0900 Subject: [PATCH 21/64] DRY @run options --- src/beautifiers/php-cs-fixer.coffee | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index 0b8ec16..c6b1b4a 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -18,6 +18,12 @@ module.exports = class PHPCSFixer extends Beautifier @debug('php-cs-fixer', options) configFile = if context? and context.filePath? then @findFile(path.dirname(context.filePath), '.php_cs') + runOptions = { + ignoreReturnCode: true + help: { + link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" + } + } # Find php-cs-fixer.phar script @Promise.all([ @@ -42,12 +48,7 @@ module.exports = class PHPCSFixer extends Beautifier "--fixers=#{options.fixers}" if options.fixers "--config-file=#{configFile}" if configFile tempFile = @tempFile("temp", text) - ], { - ignoreReturnCode: true - help: { - link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" - } - }) + ], runOptions) .then(=> @readFile(tempFile) ) @@ -58,12 +59,7 @@ module.exports = class PHPCSFixer extends Beautifier "--fixers=#{options.fixers}" if options.fixers "--config-file=#{configFile}" if configFile tempFile = @tempFile("temp", text) - ], { - ignoreReturnCode: true - help: { - link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" - } - }) + ], runOptions) .then(=> @readFile(tempFile) ) From c48989d9a9402c4aa794d3c74509ec1cf9bc5de6 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 20:49:42 +0900 Subject: [PATCH 22/64] DRY php-cs-fixer options --- src/beautifiers/php-cs-fixer.coffee | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index c6b1b4a..1768cfe 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -18,6 +18,12 @@ module.exports = class PHPCSFixer extends Beautifier @debug('php-cs-fixer', options) configFile = if context? and context.filePath? then @findFile(path.dirname(context.filePath), '.php_cs') + phpCsFixerOptions = [ + "fix" + "--level=#{options.level}" if options.level + "--fixers=#{options.fixers}" if options.fixers + "--config-file=#{configFile}" if configFile + ] runOptions = { ignoreReturnCode: true help: { @@ -40,26 +46,15 @@ module.exports = class PHPCSFixer extends Beautifier # Check if PHP-CS-Fixer path was found if phpCSFixerPath? # Found PHP-CS-Fixer path + tempFile = @tempFile("temp", text) + if @isWindows - @run("php", [ - phpCSFixerPath - "fix" - "--level=#{options.level}" if options.level - "--fixers=#{options.fixers}" if options.fixers - "--config-file=#{configFile}" if configFile - tempFile = @tempFile("temp", text) - ], runOptions) + @run("php", [phpCSFixerPath, phpCsFixerOptions, tempFile], runOptions) .then(=> @readFile(tempFile) ) else - @run(phpCSFixerPath, [ - "fix" - "--level=#{options.level}" if options.level - "--fixers=#{options.fixers}" if options.fixers - "--config-file=#{configFile}" if configFile - tempFile = @tempFile("temp", text) - ], runOptions) + @run(phpCSFixerPath, [phpCsFixerOptions, tempFile], runOptions) .then(=> @readFile(tempFile) ) From 17314013060611e3c38b59342b139b4fc71545d1 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 20:51:55 +0900 Subject: [PATCH 23/64] fix indent --- src/beautifiers/php-cs-fixer.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index 1768cfe..4117b41 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -64,9 +64,9 @@ module.exports = class PHPCSFixer extends Beautifier @Promise.reject(@commandNotFoundError( 'php-cs-fixer' { - link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" - program: "php-cs-fixer.phar" - pathOption: "PHP - CS Fixer Path" + link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" + program: "php-cs-fixer.phar" + pathOption: "PHP - CS Fixer Path" }) ) ) From 42cc95593048c2b78d7df9699cce50f966f7dc8d Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 21:53:35 +0900 Subject: [PATCH 24/64] Add rules option Merged fixers and level options --- src/beautifiers/php-cs-fixer.coffee | 3 +-- src/languages/php.coffee | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index 4117b41..b4009cd 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -20,8 +20,7 @@ module.exports = class PHPCSFixer extends Beautifier configFile = if context? and context.filePath? then @findFile(path.dirname(context.filePath), '.php_cs') phpCsFixerOptions = [ "fix" - "--level=#{options.level}" if options.level - "--fixers=#{options.fixers}" if options.fixers + "--rules=#{options.rules}" if options.rules "--config-file=#{configFile}" if configFile ] runOptions = { diff --git a/src/languages/php.coffee b/src/languages/php.coffee index ef8eade..7f9d4fe 100644 --- a/src/languages/php.coffee +++ b/src/languages/php.coffee @@ -27,14 +27,10 @@ module.exports = { type: 'string' default: "" description: "Path to the `php-cs-fixer` CLI executable" - fixers: + rules: type: 'string' default: "" - description: "Add fixer(s). i.e. linefeed,-short_tag,indentation" - level: - type: 'string' - default: "" - description: "By default, all PSR-2 fixers and some additional ones are run." + description: "Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2" phpcbf_path: title: "PHPCBF Path" type: 'string' From 17cd9ce63f75704a2b45d3d572ea8d360db56fff Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 21:55:06 +0900 Subject: [PATCH 25/64] Change config file option --- src/beautifiers/php-cs-fixer.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index b4009cd..4f2d376 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -21,7 +21,7 @@ module.exports = class PHPCSFixer extends Beautifier phpCsFixerOptions = [ "fix" "--rules=#{options.rules}" if options.rules - "--config-file=#{configFile}" if configFile + "--config=#{configFile}" if configFile ] runOptions = { ignoreReturnCode: true From b63965bbdea0654c956d053a4ef3b422b559309b Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 21:57:45 +0900 Subject: [PATCH 26/64] Modify php-cs-fixer path description --- src/languages/php.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/php.coffee b/src/languages/php.coffee index 7f9d4fe..c6ab4b2 100644 --- a/src/languages/php.coffee +++ b/src/languages/php.coffee @@ -26,7 +26,7 @@ module.exports = { title: "PHP-CS-Fixer Path" type: 'string' default: "" - description: "Path to the `php-cs-fixer` CLI executable" + description: "Absolute path to the `php-cs-fixer` CLI executable" rules: type: 'string' default: "" From cd2ae5d0f787f4989e32084553da0bf0b242b843 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 21:59:34 +0900 Subject: [PATCH 27/64] Disable cache Because 'Failed to write file ".php_cs.cache", "no reason available".' error occurs --- src/beautifiers/php-cs-fixer.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index 4f2d376..dffc6b5 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -22,6 +22,7 @@ module.exports = class PHPCSFixer extends Beautifier "fix" "--rules=#{options.rules}" if options.rules "--config=#{configFile}" if configFile + "--using-cache=no" ] runOptions = { ignoreReturnCode: true From 2bb88c46bc27366a99c573a4bcba7036e098ba97 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Sat, 11 Feb 2017 23:01:32 +0900 Subject: [PATCH 28/64] Modify PHP settings --- docs/options.md | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/docs/options.md b/docs/options.md index 6bb63b3..4aa8892 100644 --- a/docs/options.md +++ b/docs/options.md @@ -9049,8 +9049,7 @@ Specify a configuration file which will override the default name of .perltidyrc | `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `cs_fixer_path` | :white_check_mark: | :x: | :x: | -| `fixers` | :white_check_mark: | :x: | :x: | -| `level` | :white_check_mark: | :x: | :x: | +| `rules` | :white_check_mark: | :x: | :x: | | `phpcbf_path` | :white_check_mark: | :x: | :x: | | `standard` | :white_check_mark: | :white_check_mark: | :x: | @@ -9125,7 +9124,7 @@ Automatically beautify PHP files on save **Description**: -Path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) +Absolute path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -9137,50 +9136,26 @@ Path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) } ``` -##### [Fixers](#fixers) +##### [Rules](#rules) **Namespace**: `php` -**Key**: `fixers` +**Key**: `rules` **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) **Description**: -Add fixer(s). i.e. linefeed,-short_tag,indentation (Supported by PHP-CS-Fixer) +Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2 (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** ```json { "php": { - "fixers": "" - } -} -``` - -##### [Level](#level) - -**Namespace**: `php` - -**Key**: `level` - -**Type**: `string` - -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) - -**Description**: - -By default, all PSR-2 fixers and some additional ones are run. (Supported by PHP-CS-Fixer) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "php": { - "level": "" + "rules": "" } } ``` From e314fdf0992148e782b66a4d49dc0524fd349401 Mon Sep 17 00:00:00 2001 From: Taylon Silmer Date: Sun, 29 Jan 2017 18:16:35 -0200 Subject: [PATCH 29/64] Add ESLint beautifier --- CHANGELOG.md | 1 + README.md | 2 +- package.json | 7 +++++++ src/beautifiers/eslint.coffee | 33 +++++++++++++++++++++++++++++++++ src/beautifiers/index.coffee | 1 + 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/beautifiers/eslint.coffee diff --git a/CHANGELOG.md b/CHANGELOG.md index 32ecf1d..4ddcef9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Add [elm-format](https://github.com/avh4/elm-format) beautifier for the Elm language. - Add [clang-format](http://clang.llvm.org/docs/ClangFormat.html) beautifier for C/C++/Obj-C languages. - Add [yapf](http://github.com/google/yapf) beautifier for Python. +- Add [ESLint](https://github.com/eslint/eslint) beautifier for Javascript - Closes [#776] (https://github.com/Glavin001/atom-beautify/issues/776) Add support for `collapse-preserve-inline` brace_style for javascript. - Closes [#786](https://github.com/Glavin001/atom-beautify/issues/786) YAPF configuration files are ignored. - Fix phpcbf hanging issue by closing stdin. See [#893](https://github.com/Glavin001/atom-beautify/issues/893) diff --git a/README.md b/README.md index da87ff0..78f1de3 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | HTML | `HTML` |`.html` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | Jade | `Jade`, `Pug` |`.jade`, `.pug` | [`Pug Beautify`](https://github.com/vingorius/pug-beautify) (Default) | | Java | `Java` |`.java` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | -| JavaScript | `JavaScript` |`.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | +| JavaScript | `JavaScript` |`.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Pretty Diff`](https://github.com/prettydiff/prettydiff), [`ESLint Fixer`](https://github.com/eslint/eslint) | | JSON | `JSON` |`.json` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | JSX | `JSX`, `JavaScript (JSX)`, `Babel ES6 JavaScript`, `JavaScript with JSX` |`.jsx`, `.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | LaTeX | `LaTeX` |`.tex` | [`Latex Beautify`](https://github.com/cmhughes/latexindent.pl) (Default) | diff --git a/package.json b/package.json index a91d8a9..026cf1a 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,10 @@ { "name": "Victor Uriarte", "url": "https://github.com/vmuriart" + }, + { + "name": "Taylon Silmer", + "url": "https://github.com/taylon" } ], "engines": { @@ -130,6 +134,7 @@ "csscomb": "^3.1.7", "diff": "3.0.0", "editorconfig": "^0.13.2", + "eslint": "^3.13.1", "event-kit": "^2.1.0", "expand-home-dir": "0.0.3", "extend": "^3.0.0", @@ -259,6 +264,8 @@ "fortran beautifier", "js beautify", "jscs fixer", + "eslint", + "eslint fixer", "lua beautifier", "ocp-indent", "perltidy", diff --git a/src/beautifiers/eslint.coffee b/src/beautifiers/eslint.coffee new file mode 100644 index 0000000..55b52f8 --- /dev/null +++ b/src/beautifiers/eslint.coffee @@ -0,0 +1,33 @@ +"use strict" + +Beautifier = require('./beautifier') +Path = require('path') +{allowUnsafeNewFunction} = require 'loophole' + +module.exports = class ESLintFixer extends Beautifier + name: "ESLint Fixer" + link: "https://github.com/eslint/eslint" + + options: { + JavaScript: false + } + + beautify: (text, language, options) -> + return new @Promise((resolve, reject) => + editor = atom.workspace.getActiveTextEditor() + filePath = editor.getPath() + projectPath = atom.project.relativizePath(filePath)[0] + + result = null + allowUnsafeNewFunction => + importPath = Path.join(projectPath, 'node_modules', 'eslint') + try + CLIEngine = require(importPath).CLIEngine + + cli = new CLIEngine(fix: true, cwd: projectPath) + result = cli.executeOnText(text).results[0] + + resolve result.output + catch err + reject(err) + ) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 077190e..16113d4 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -52,6 +52,7 @@ module.exports = class Beautifiers extends EventEmitter 'fortran-beautifier' 'js-beautify' 'jscs' + 'eslint' 'lua-beautifier' 'ocp-indent' 'perltidy' From e34228af807f93229794709c9f695b5899f449b9 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Tue, 14 Feb 2017 19:01:17 +0900 Subject: [PATCH 30/64] Fix gem install error --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7debaf4..b5faca8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,6 +15,7 @@ environment: - PYTHON: "C:\\Python27" PYTHON_VERSION: "2.7.8" PYTHON_ARCH: "32" + RUBY_VERSION: 23 # - PYTHON: "C:\\Python27-x64" # PYTHON_VERSION: "2.7.8" @@ -82,8 +83,7 @@ install: - "%CMD_IN_ENV% pip install --upgrade sqlparse" # Ruby & Gem - - cinst ruby -y - - "SET PATH=C:\\tools\\ruby23\\bin;%PATH%" + - SET PATH=C:\Ruby%RUBY_VERSION%\bin;C:\Ruby23-x64\DevKit\mingw\bin;%PATH% # Rubocop - gem install rubocop - where rubocop From e62cb301b1b02bbcf256a2d51caa140b16d60346 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Tue, 14 Feb 2017 19:58:53 +0900 Subject: [PATCH 31/64] Fix php install error http://help.appveyor.com/discussions/problems/5616-not-able-to-build-due-to-problem-in-chocolateyinstallps1 --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index b5faca8..90df6fd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -104,6 +104,7 @@ install: # FIXME: Enable allowEmptyChecksums, until someone fixes the checksum issue of php - choco feature enable -n allowEmptyChecksums # PHP + - ps: Set-Service wuauserv -StartupType Manual - cinst php -y - ps: "ls \"C:\\tools\\php\"" - "SET PATH=C:\\tools\\php;%PATH%" From f6a7f53513d352f88b3bf38c64c8dea234520079 Mon Sep 17 00:00:00 2001 From: onigra <3280467rec@gmail.com> Date: Tue, 14 Feb 2017 20:06:44 +0900 Subject: [PATCH 32/64] Modify php71 path --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 90df6fd..002bd1f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -106,8 +106,8 @@ install: # PHP - ps: Set-Service wuauserv -StartupType Manual - cinst php -y - - ps: "ls \"C:\\tools\\php\"" - - "SET PATH=C:\\tools\\php;%PATH%" + - ps: "ls \"C:\\tools\\php71\"" + - "SET PATH=C:\\tools\\php71;%PATH%" - where php # PHP-CS-Fixer - cinst curl -y # Use cURL to download file from URL From 7627a9239a53e788827e2552adb2c3fadbeb4cde Mon Sep 17 00:00:00 2001 From: Taylon Silmer Date: Tue, 14 Feb 2017 11:31:05 -0200 Subject: [PATCH 33/64] Fix coffeelint errors --- src/beautifiers/eslint.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/beautifiers/eslint.coffee b/src/beautifiers/eslint.coffee index 55b52f8..2f9947d 100644 --- a/src/beautifiers/eslint.coffee +++ b/src/beautifiers/eslint.coffee @@ -13,13 +13,13 @@ module.exports = class ESLintFixer extends Beautifier } beautify: (text, language, options) -> - return new @Promise((resolve, reject) => + return new @Promise((resolve, reject) -> editor = atom.workspace.getActiveTextEditor() filePath = editor.getPath() projectPath = atom.project.relativizePath(filePath)[0] result = null - allowUnsafeNewFunction => + allowUnsafeNewFunction -> importPath = Path.join(projectPath, 'node_modules', 'eslint') try CLIEngine = require(importPath).CLIEngine From e61868f1ec8c80dc7866c7a12613030aa3b2c544 Mon Sep 17 00:00:00 2001 From: re6exp Date: Sun, 19 Feb 2017 10:22:11 +0300 Subject: [PATCH 34/64] Support for additional wrap attributes options of js-beautify (html): force-aligned and force-expand-multiline. --- src/languages/html.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/html.coffee b/src/languages/html.coffee index 6fd85bb..8d6746d 100644 --- a/src/languages/html.coffee +++ b/src/languages/html.coffee @@ -56,8 +56,8 @@ module.exports = { wrap_attributes: type: 'string' default: "auto" - enum: ["auto", "force"] - description: "Wrap attributes to new lines [auto|force]" + enum: ["auto", "force", "force-aligned", "force-expand-multiline"] + description: "Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline]" wrap_attributes_indent_size: type: 'integer' default: defaultIndentSize From 678fc181467f53c7bdbed59f90a36f2568302e35 Mon Sep 17 00:00:00 2001 From: re6exp Date: Sun, 19 Feb 2017 10:22:11 +0300 Subject: [PATCH 35/64] Support for additional wrap attributes options of js-beautify (html): force-aligned and force-expand-multiline. --- CHANGELOG.md | 1 + package.json | 4 ++++ src/languages/html.coffee | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32ecf1d..5e58a46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # dev +- Add support for additional wrap attribute options of js-beautify (html): force-aligned and force-expand-multiline. - Update to `remark`'s new API and fix [#1196](https://github.com/Glavin001/atom-beautify/issues/1196) - Add beautifier for the Lua language. - Add [ocp-indent](https://github.com/OCamlPro/ocp-indent) beautifier for the OCaml language. diff --git a/package.json b/package.json index a91d8a9..992e664 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,10 @@ { "name": "Victor Uriarte", "url": "https://github.com/vmuriart" + }, + { + "name": "Anton Brok-Volchansky", + "url": "https://github.com/re6exp" } ], "engines": { diff --git a/src/languages/html.coffee b/src/languages/html.coffee index 6fd85bb..8d6746d 100644 --- a/src/languages/html.coffee +++ b/src/languages/html.coffee @@ -56,8 +56,8 @@ module.exports = { wrap_attributes: type: 'string' default: "auto" - enum: ["auto", "force"] - description: "Wrap attributes to new lines [auto|force]" + enum: ["auto", "force", "force-aligned", "force-expand-multiline"] + description: "Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline]" wrap_attributes_indent_size: type: 'integer' default: defaultIndentSize From 2285525c641592ff84db30975f9bee0461dd9ee3 Mon Sep 17 00:00:00 2001 From: Taylon Silmer Date: Tue, 21 Feb 2017 09:37:14 -0300 Subject: [PATCH 36/64] Get isort configuration from project --- src/beautifiers/autopep8.coffee | 6 +++++- src/beautifiers/yapf.coffee | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/beautifiers/autopep8.coffee b/src/beautifiers/autopep8.coffee index 3f4b546..e5cceef 100644 --- a/src/beautifiers/autopep8.coffee +++ b/src/beautifiers/autopep8.coffee @@ -26,8 +26,12 @@ module.exports = class Autopep8 extends Beautifier }) .then(=> if options.sort_imports + editor = atom.workspace.getActiveTextEditor() + filePath = editor.getPath() + projectPath = atom.project.relativizePath(filePath)[0] + @run("isort", - [tempFile], + ["-sp", projectPath, tempFile], help: { link: "https://github.com/timothycrosley/isort" }) diff --git a/src/beautifiers/yapf.coffee b/src/beautifiers/yapf.coffee index affd32e..34c8051 100644 --- a/src/beautifiers/yapf.coffee +++ b/src/beautifiers/yapf.coffee @@ -23,8 +23,12 @@ module.exports = class Yapf extends Beautifier }, ignoreReturnCode: true) .then(=> if options.sort_imports + editor = atom.workspace.getActiveTextEditor() + filePath = editor.getPath() + projectPath = atom.project.relativizePath(filePath)[0] + @run("isort", - [tempFile], + ["-sp", projectPath, tempFile], help: { link: "https://github.com/timothycrosley/isort" }) From aec0a682b55256985bf445ea0ba9299e8c5b62aa Mon Sep 17 00:00:00 2001 From: Guan Gui Date: Mon, 27 Feb 2017 22:14:09 +1100 Subject: [PATCH 37/64] Fixed JS Beautify JSX bug by adding e4x option --- package.json | 2 +- src/languages/jsx.coffee | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a91d8a9..df5b064 100644 --- a/package.json +++ b/package.json @@ -305,4 +305,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file diff --git a/src/languages/jsx.coffee b/src/languages/jsx.coffee index 6c26e95..cf67710 100644 --- a/src/languages/jsx.coffee +++ b/src/languages/jsx.coffee @@ -22,6 +22,12 @@ module.exports = { "js" ] - defaultBeautifier: "Pretty Diff" + defaultBeautifier: "JS Beautify" + + options: + e4x: + type: 'boolean' + default: true + description: "Support e4x/jsx syntax" } From 3b2404bc99fbd7e265cd6d121655c0fa5e988d8a Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Wed, 1 Mar 2017 22:10:19 -0400 Subject: [PATCH 38/64] Add notice for temporary pause with development --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index da87ff0..130a7fb 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,9 @@ Thank you. Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core! See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174). +## Temporary Pause With Development + +As I can see the Issues on GitHub are growing I want to let everyone know I still plan to maintain Atom-Beautify. Unfortunately, I will be fairly busy for a little while longer with my final semester of University (assignments, projects, exams, etc) and large work-related projects. Therefore, I apologize for my temporarily absense as I finish off these other commitments. My plan is to return to working on Atom-Beautify with a newfound energy to add features and squash bugs in Atom-Beautify when this University semester is over around mid-April 2017. Thank you for your understanding and patience during this time. - [Glavin](https://github.com/Glavin001) ## Language Support From 8c8afc407dc11b309e9db0d4caad820951820f18 Mon Sep 17 00:00:00 2001 From: hxsf Date: Tue, 28 Mar 2017 15:59:28 +0800 Subject: [PATCH 39/64] add a simple Lua format base on js --- .../lua-beautifier/beautifier.coffee | 79 +++++++++++++++++++ src/beautifiers/lua-beautifier/beautifier.pl | 57 ------------- src/beautifiers/lua-beautifier/index.coffee | 12 +-- 3 files changed, 85 insertions(+), 63 deletions(-) create mode 100644 src/beautifiers/lua-beautifier/beautifier.coffee delete mode 100644 src/beautifiers/lua-beautifier/beautifier.pl diff --git a/src/beautifiers/lua-beautifier/beautifier.coffee b/src/beautifiers/lua-beautifier/beautifier.coffee new file mode 100644 index 0000000..ab3833b --- /dev/null +++ b/src/beautifiers/lua-beautifier/beautifier.coffee @@ -0,0 +1,79 @@ +DEFAULT_INDENT = ' ' + +module.exports = (str, indent) -> + indent = indent or DEFAULT_INDENT + indent = ' '.repeat indent if Number.isInteger indent + $currIndent = 0 + $nextIndent = 0 + $prevLength = 0 + $extIndent = 0 + $lastIndent = 0 + $template = 0 + new_code = str.split(/\r?\n/g).map (line, line_number) -> + $template_flag = false + if $template + res2 = line.match /\](=*)\]/ + if res2 and $template == res2[1].length + 1 + $template = 0 + $template_flag = true + else + return line + res1 = line.match /\[(=*)\[/ + if res1 + $template = res1[1].length + 1 + if !$template_flag + line = line.trim() + # remote all spaces on both ends + string_list = line.match /(['"])[^\1]*?\1/g + line = line.replace /\s+/g, ' ' + # replace all whitespaces inside the string with one space, WARNING: the whitespaces in string will be replace too! + line = line.replace /([^\-])\s?(==|>=|<=|[=><\+\-\*\/])\s?([^\-\[])/g, '$1 $2 $3' + # add whitespace around the operator + line = line.replace /,([^\s])/g, ', $1' + line = line.replace /\s,/g, ',' + # recover the whitespaces in string. + line = line.replace /(['"])[^\1]*?\1/g, -> + string_list.shift() + + return '' if !line.length + raw_line = line + line = line.replace /(['"])[^\1]*?\1/, '' + # remove all quoted fragments for proper bracket processing + line = line.replace /\s*--.+/, '' + # remove all comments; this ignores long bracket style comments + if /^((local )?function|repeat|while)\b/.test(line) and !/\bend\s*[\),;]*$/.test(line) or /\b(then|do)$/.test(line) and !/^elseif\b/.test(line) or /^if\b/.test(line) and /\bthen\b/.test(line) and !/\bend$/.test(line) or /\bfunction ?(?:\w+ )?\([^\)]*\)$/.test(line) and !/\bend$/.test(line) + $nextIndent = $currIndent + 1 + else if /^until\b/.test(line) or /^end\s*[\),;]*$/.test(line) or /^end\s*\)\s*\.\./.test(line) or /^else(if)?\b/.test(line) and /\bend$/.test(line) + $nextIndent = --$currIndent + else if /^else\b/.test(line) or /^elseif\b/.test(line) + $nextIndent = $currIndent + $currIndent = $currIndent - 1 + $brackets = (line.match(/\(/g) or []).length - ((line.match(/\)/g) or []).length) + # capture unbalanced brackets + $curly = (line.match(/\{/g) or []).length - ((line.match(/\}/g) or []).length) + # capture unbalanced curly brackets + # close (curly) brackets if needed + $currIndent += $curly if $curly < 0 + $currIndent += $brackets if $brackets < 0 + $nextIndent += $brackets + $curly + + if $currIndent - $lastIndent > 1 + $extIndent += $nextIndent - $lastIndent - 1 + $nextIndent = $currIndent = 1 + $lastIndent + if $currIndent - $lastIndent < -1 and $extIndent > 0 + $extIndent += $currIndent - $lastIndent + 1 + $currIndent = -1 + $lastIndent + if $nextIndent < $currIndent + $nextIndent = $currIndent + + if $currIndent < 0 + console.warn 'WARNING: negative indentation at line ${line_number}: ${raw_line}' + new_line = (if raw_line.length and $currIndent > 0 and !$template_flag then indent.repeat($currIndent) else '') + raw_line + + $useful = $prevLength > 0 or raw_line.length > 0 + $lastIndent = $currIndent + $currIndent = $nextIndent + $prevLength = raw_line.length + return new_line if $useful + console.warn 'WARNING: positive indentation at the end' if $currIndent > 0 + new_code.join '\n' diff --git a/src/beautifiers/lua-beautifier/beautifier.pl b/src/beautifiers/lua-beautifier/beautifier.pl deleted file mode 100644 index 349831a..0000000 --- a/src/beautifiers/lua-beautifier/beautifier.pl +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2011 Paul Kulchenko -# Credits: http://notebook.kulchenko.com/programming/lua-beautifier-in-55-lines-of-perl -use strict; -use warnings; - -use constant INDENT => ' '; -my($currIndent, $nextIndent, $prevLength) = (0, 0, 0); - -while (<>) { - chomp; - s/^\s+|\s+$//g; # remote all spaces on both ends - s/\s+/ /g; # replace all whitespaces inside the string with one space - - my $orig = $_; - - s/(['"])[^\1]*?\1//g; # remove all quoted fragments for proper bracket processing - s/\s*--.+//; # remove all comments; this ignores long bracket style comments - - # open a level; increase next indentation; don't change current one - if (/^((local )?function|repeat|while)\b/ && !/\bend\s*[\),;]*$/ - || /\b(then|do)$/ && !/^elseif\b/ # only open on 'then' if there is no 'elseif' - || /^if\b/ && /\bthen\b/ && !/\bend$/ # only open on 'if' if there is no 'end' at the end - || /\bfunction\s*\([^\)]*\)$/) { - $nextIndent = $currIndent + 1; - } - # close the level; change both current and next indentation - elsif (/^until\b/ - || /^end\s*[\),;]*$/ - || /^end\s*\)\s*\.\./ # this is a special case of 'end).."some string"' - || /^else(if)?\b/ && /\bend$/) { - $nextIndent = $currIndent = $currIndent - 1; - } - # keep the level; decrease the current indentation; keep the next one - elsif (/^else\b/ - || /^elseif\b/) { - ($nextIndent, $currIndent) = ($currIndent, $currIndent-1); - } - - my $brackets = y/(// - y/)//; # capture unbalanced brackets - my $curly = y/{// - y/}//; # capture unbalanced curly brackets - - # close (curly) brackets if needed - $currIndent += $curly if $curly < 0 && /^\}/; - $currIndent += $brackets if $brackets < 0 && /^\)/; - - warn "WARNING: negative indentation at line $.: $orig\n" if $currIndent < 0; - - print((length($orig) ? (INDENT x $currIndent) : ''), $orig, "\n") - if $prevLength > 0 || length($orig) > 0; # this is to collapse empty lines - - $nextIndent += $brackets + $curly; - - $currIndent = $nextIndent; - $prevLength = length($orig); -} - -warn "WARNING: positive indentation at the end\n" if $nextIndent > 0; diff --git a/src/beautifiers/lua-beautifier/index.coffee b/src/beautifiers/lua-beautifier/index.coffee index c96c743..35a7bb5 100644 --- a/src/beautifiers/lua-beautifier/index.coffee +++ b/src/beautifiers/lua-beautifier/index.coffee @@ -4,6 +4,7 @@ path = require("path") "use strict" Beautifier = require('../beautifier') +format = require './beautifier' module.exports = class Lua extends Beautifier name: "Lua beautifier" @@ -14,9 +15,8 @@ module.exports = class Lua extends Beautifier } beautify: (text, language, options) -> - lua_beautifier = path.resolve(__dirname, "beautifier.pl") - @run("perl", [ - lua_beautifier, - '<', - @tempFile("input", text) - ]) + new @Promise (resolve, reject) -> + try + resolve format text, options.indent_char.repeat options.indent_size + catch error + reject error From 25b3ef04176d1a3a40f71a5f75de26f4c7a5dcb3 Mon Sep 17 00:00:00 2001 From: hxsf Date: Tue, 28 Mar 2017 16:25:52 +0800 Subject: [PATCH 40/64] add examples for lua --- .../simple-jsbeautifyrc/lua/expected/test.lua | 18 ++++++++++++++++-- .../simple-jsbeautifyrc/lua/original/test.lua | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/examples/simple-jsbeautifyrc/lua/expected/test.lua b/examples/simple-jsbeautifyrc/lua/expected/test.lua index 5c00e55..e2f200c 100644 --- a/examples/simple-jsbeautifyrc/lua/expected/test.lua +++ b/examples/simple-jsbeautifyrc/lua/expected/test.lua @@ -1,5 +1,19 @@ -- Ensure that that the element at i is in the right position, -- and return a closure which can be used for continuing the sort. +local a = 'a b c' +local b = '12345678' +local c = 'a b c' + 'a b c' +local t = { + a = 1, + b = 2, + c = 3, +} +local e = {a = 1, b = 2} + +function aaa(a, b, c) + return a + b +end + function quicksorter(i, vec, low, high) if low >= high then return quicksorter @@ -11,10 +25,10 @@ function quicksorter(i, vec, low, high) -- Create the promise local function self(i, vec, low, high) if i < middle then - left = left(i, vec, low, middle-1) + left = left(i, vec, low, middle - 1) return self elseif i > middle then - right = right(i, vec, middle+1, high) + right = right(i, vec, middle + 1, high) return self end end diff --git a/examples/simple-jsbeautifyrc/lua/original/test.lua b/examples/simple-jsbeautifyrc/lua/original/test.lua index 753deb3..e3692f5 100644 --- a/examples/simple-jsbeautifyrc/lua/original/test.lua +++ b/examples/simple-jsbeautifyrc/lua/original/test.lua @@ -1,5 +1,19 @@ -- Ensure that that the element at i is in the right position, -- and return a closure which can be used for continuing the sort. +local a= 'a b c' +local b ='12345678' +local c = 'a b c' +'a b c' +local t = { +a = 1, + b =2 , + c= 3, +} +local e={a=1,b=2} + +function aaa(a,b,c) +return a+b +end + function quicksorter(i, vec, low, high) if low >= high then return quicksorter @@ -18,7 +32,7 @@ right = right(i, vec, middle+1, high) return self end end - + -- Force the promise until i is in the right position return self(i, vec, low, high) end From 3c6479680b1b7034c950fefd36945d3dc3f6b4ba Mon Sep 17 00:00:00 2001 From: hxsf Date: Thu, 30 Mar 2017 12:08:51 +0800 Subject: [PATCH 41/64] fixed bugs and add feature + bugs: - negative number: 'local a = -1' => 'local a = - 1' - unequal: 'a ~= b' => 'a ~ = b' - change the comment: '-- a b' => '-- a b' + feature: - remove space before comma, add add space after comma: '{a = 1 ,b = 2}' => '{a = 1, b = 2}' --- .../simple-jsbeautifyrc/lua/expected/test.lua | 23 ++- .../simple-jsbeautifyrc/lua/original/test.lua | 23 ++- .../lua-beautifier/beautifier.coffee | 170 ++++++++++-------- 3 files changed, 135 insertions(+), 81 deletions(-) diff --git a/examples/simple-jsbeautifyrc/lua/expected/test.lua b/examples/simple-jsbeautifyrc/lua/expected/test.lua index e2f200c..878d1c1 100644 --- a/examples/simple-jsbeautifyrc/lua/expected/test.lua +++ b/examples/simple-jsbeautifyrc/lua/expected/test.lua @@ -8,11 +8,26 @@ local t = { b = 2, c = 3, } -local e = {a = 1, b = 2} - -function aaa(a, b, c) - return a + b +if a ~= 'a' then + local b = a end +local e = {a = 1, b = 2} +function aaa(a, b, c) + + -- comment 1 + -- comment 2 1231 + -- comment 1 123 123 123123 12 + -- [[ comment 1 ]] + --[[ + muli comments + ssss + @asdasd sad + ]] + local a = -1 + return a + b - c +end +local b = {a = 1, b = [[this is two space ; + ]], c = 2} function quicksorter(i, vec, low, high) if low >= high then diff --git a/examples/simple-jsbeautifyrc/lua/original/test.lua b/examples/simple-jsbeautifyrc/lua/original/test.lua index e3692f5..fed0705 100644 --- a/examples/simple-jsbeautifyrc/lua/original/test.lua +++ b/examples/simple-jsbeautifyrc/lua/original/test.lua @@ -8,11 +8,26 @@ a = 1, b =2 , c= 3, } -local e={a=1,b=2} - -function aaa(a,b,c) -return a+b +if a~='a' then +local b=a end +local e={a=1,b=2} +function aaa(a,b,c) + +-- comment 1 + -- comment 2 1231 + -- comment 1 123 123 123123 12 +-- [[ comment 1 ]] + --[[ + muli comments + ssss + @asdasd sad + ]] +local a = -1 +return a+b-c +end +local b = {a=1,b=[[this is two space ; + ]],c=2} function quicksorter(i, vec, low, high) if low >= high then diff --git a/src/beautifiers/lua-beautifier/beautifier.coffee b/src/beautifiers/lua-beautifier/beautifier.coffee index ab3833b..c24e3ba 100644 --- a/src/beautifiers/lua-beautifier/beautifier.coffee +++ b/src/beautifiers/lua-beautifier/beautifier.coffee @@ -1,79 +1,103 @@ DEFAULT_INDENT = ' ' -module.exports = (str, indent) -> - indent = indent or DEFAULT_INDENT - indent = ' '.repeat indent if Number.isInteger indent - $currIndent = 0 - $nextIndent = 0 - $prevLength = 0 - $extIndent = 0 - $lastIndent = 0 - $template = 0 - new_code = str.split(/\r?\n/g).map (line, line_number) -> - $template_flag = false - if $template - res2 = line.match /\](=*)\]/ - if res2 and $template == res2[1].length + 1 - $template = 0 - $template_flag = true - else - return line - res1 = line.match /\[(=*)\[/ - if res1 - $template = res1[1].length + 1 - if !$template_flag - line = line.trim() - # remote all spaces on both ends - string_list = line.match /(['"])[^\1]*?\1/g - line = line.replace /\s+/g, ' ' - # replace all whitespaces inside the string with one space, WARNING: the whitespaces in string will be replace too! - line = line.replace /([^\-])\s?(==|>=|<=|[=><\+\-\*\/])\s?([^\-\[])/g, '$1 $2 $3' - # add whitespace around the operator - line = line.replace /,([^\s])/g, ', $1' - line = line.replace /\s,/g, ',' - # recover the whitespaces in string. - line = line.replace /(['"])[^\1]*?\1/g, -> +adjust_space = (line) -> + string_list = line.match /(['"])[^\1]*?\1/g + muli_string = line.match /\[(=*)\[([^\]\1\]]*)/ + comment = line.match /\-{2}[^\[].*$/ + line = line.replace /\s+/g, ' ' + # replace all whitespaces inside the string with one space, WARNING: the whitespaces in string will be replace too! + line = line.replace /\s?(==|>=|<=|~=|[=><\+\*\/])\s?/g, ' $1 ' + # add whitespace around the operator + line = line.replace /([^=|\-|(|\s])\s?\-\s?([^\-|\[])/g, '$1 - $2' + # just format minus, not for -- or negative number or commentary. + line = line.replace /,([^\s])/g, ', $1' + # adjust ',' + line = line.replace /\s+,/g, ',' + # recover the whitespaces in string. + line = line.replace /(['"])[^\1]*?\1/g, -> string_list.shift() + if muli_string and muli_string[0] + line = line.replace /\[(=*)\[([^\]\1\]]*)/, muli_string[0] + if comment and comment[0] + line = line.replace /\-{2}[^\[].*$/, comment[0] + line - return '' if !line.length - raw_line = line - line = line.replace /(['"])[^\1]*?\1/, '' - # remove all quoted fragments for proper bracket processing - line = line.replace /\s*--.+/, '' - # remove all comments; this ignores long bracket style comments - if /^((local )?function|repeat|while)\b/.test(line) and !/\bend\s*[\),;]*$/.test(line) or /\b(then|do)$/.test(line) and !/^elseif\b/.test(line) or /^if\b/.test(line) and /\bthen\b/.test(line) and !/\bend$/.test(line) or /\bfunction ?(?:\w+ )?\([^\)]*\)$/.test(line) and !/\bend$/.test(line) - $nextIndent = $currIndent + 1 - else if /^until\b/.test(line) or /^end\s*[\),;]*$/.test(line) or /^end\s*\)\s*\.\./.test(line) or /^else(if)?\b/.test(line) and /\bend$/.test(line) - $nextIndent = --$currIndent - else if /^else\b/.test(line) or /^elseif\b/.test(line) - $nextIndent = $currIndent - $currIndent = $currIndent - 1 - $brackets = (line.match(/\(/g) or []).length - ((line.match(/\)/g) or []).length) - # capture unbalanced brackets - $curly = (line.match(/\{/g) or []).length - ((line.match(/\}/g) or []).length) - # capture unbalanced curly brackets - # close (curly) brackets if needed - $currIndent += $curly if $curly < 0 - $currIndent += $brackets if $brackets < 0 - $nextIndent += $brackets + $curly +DEFAULT_WARN_FN = (msg) -> + console.log('WARNING:', msg) - if $currIndent - $lastIndent > 1 - $extIndent += $nextIndent - $lastIndent - 1 - $nextIndent = $currIndent = 1 + $lastIndent - if $currIndent - $lastIndent < -1 and $extIndent > 0 - $extIndent += $currIndent - $lastIndent + 1 - $currIndent = -1 + $lastIndent - if $nextIndent < $currIndent - $nextIndent = $currIndent +module.exports = (str, indent, warn_fn) -> + indent = indent or DEFAULT_INDENT + warn_fn = if typeof warn_fn == 'function' then warn_fn else DEFAULT_WARN_FN + indent = ' '.repeat(indent) if Number.isInteger(indent) + $currIndent = 0 + $nextIndent = 0 + $prevLength = 0 + $extIndent = 0 + $lastIndent = 0 + $template = 0 + new_code = str.split(/\r?\n/g).map (line, line_number) -> + $template_flag = false + if $template + res2 = line.match(/\](=*)\]/) + if res2 and $template == res2[1].length + 1 + $template_flag = true + if $template and !/]=*]$/.test(line) + arr = line.split(/\]=*\]/, 2) + comment = arr[0] + code = arr[1] + line = comment + ']' + '='.repeat($template - 1) + ']' + adjust_space(code) + $template = 0 + $template = 0 + else + return line + res1 = line.match(/\[(=*)\[/) + if res1 + $template = res1[1].length + 1 + if !$template_flag + line = line.trim() + # remote all spaces on both ends + line = adjust_space(line) + if !line.length + return '' + raw_line = line + line = line.replace(/(['"])[^\1]*?\1/, '') + # remove all quoted fragments for proper bracket processing + line = line.replace(/\s*--.+/, '') + # remove all comments; this ignores long bracket style comments + if /^((local )?function|repeat|while)\b/.test(line) and !/\bend\s*[\),;]*$/.test(line) or /\b(then|do)$/.test(line) and !/^elseif\b/.test(line) or /^if\b/.test(line) and /\bthen\b/.test(line) and !/\bend$/.test(line) or /\bfunction ?(?:\w+ )?\([^\)]*\)$/.test(line) and !/\bend$/.test(line) + $nextIndent = $currIndent + 1 + else if /^until\b/.test(line) or /^end\s*[\),;]*$/.test(line) or /^end\s*\)\s*\.\./.test(line) or /^else(if)?\b/.test(line) and /\bend$/.test(line) + $nextIndent = --$currIndent + else if /^else\b/.test(line) or /^elseif\b/.test(line) + $nextIndent = $currIndent + $currIndent = $currIndent - 1 + $brackets = (line.match(/\(/g) or []).length - ((line.match(/\)/g) or []).length) + # capture unbalanced brackets + $curly = (line.match(/\{/g) or []).length - ((line.match(/\}/g) or []).length) + # capture unbalanced curly brackets + # close (curly) brackets if needed + if $curly < 0 + $currIndent += $curly + if $brackets < 0 + $currIndent += $brackets + $nextIndent += $brackets + $curly + # console.log({last: $lastIndent, curr: $currIndent, next: $nextIndent, ext: $extIndent}) + if $currIndent - $lastIndent > 1 + $extIndent += $nextIndent - $lastIndent - 1 + $nextIndent = $currIndent = 1 + $lastIndent + if $currIndent - $lastIndent < -1 and $extIndent > 0 + $extIndent += $currIndent - $lastIndent + 1 + $currIndent = -1 + $lastIndent + if $nextIndent < $currIndent + $nextIndent = $currIndent + # console.log({last: $lastIndent, curr: $currIndent, next: $nextIndent, ext: $extIndent}) + warn_fn """negative indentation at line #{line_number}: #{raw_line}""" if $currIndent < 0 + new_line = (if raw_line.length and $currIndent > 0 and !$template_flag then indent.repeat($currIndent) else '') + raw_line + $useful = $prevLength > 0 or raw_line.length > 0 + $lastIndent = $currIndent + $currIndent = $nextIndent + $prevLength = raw_line.length + new_line or undefined - if $currIndent < 0 - console.warn 'WARNING: negative indentation at line ${line_number}: ${raw_line}' - new_line = (if raw_line.length and $currIndent > 0 and !$template_flag then indent.repeat($currIndent) else '') + raw_line - - $useful = $prevLength > 0 or raw_line.length > 0 - $lastIndent = $currIndent - $currIndent = $nextIndent - $prevLength = raw_line.length - return new_line if $useful - console.warn 'WARNING: positive indentation at the end' if $currIndent > 0 - new_code.join '\n' + warn_fn 'positive indentation at the end' if $currIndent > 0 + new_code.join '\n' From 51af21106303dd97d8b510cd20ad1fdbebee83e4 Mon Sep 17 00:00:00 2001 From: hxsf Date: Thu, 30 Mar 2017 13:15:32 +0800 Subject: [PATCH 42/64] 'fix_indent' --- .../lua-beautifier/beautifier.coffee | 190 +++++++++--------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/src/beautifiers/lua-beautifier/beautifier.coffee b/src/beautifiers/lua-beautifier/beautifier.coffee index c24e3ba..e7aba13 100644 --- a/src/beautifiers/lua-beautifier/beautifier.coffee +++ b/src/beautifiers/lua-beautifier/beautifier.coffee @@ -1,103 +1,103 @@ DEFAULT_INDENT = ' ' adjust_space = (line) -> - string_list = line.match /(['"])[^\1]*?\1/g - muli_string = line.match /\[(=*)\[([^\]\1\]]*)/ - comment = line.match /\-{2}[^\[].*$/ - line = line.replace /\s+/g, ' ' - # replace all whitespaces inside the string with one space, WARNING: the whitespaces in string will be replace too! - line = line.replace /\s?(==|>=|<=|~=|[=><\+\*\/])\s?/g, ' $1 ' - # add whitespace around the operator - line = line.replace /([^=|\-|(|\s])\s?\-\s?([^\-|\[])/g, '$1 - $2' - # just format minus, not for -- or negative number or commentary. - line = line.replace /,([^\s])/g, ', $1' - # adjust ',' - line = line.replace /\s+,/g, ',' - # recover the whitespaces in string. - line = line.replace /(['"])[^\1]*?\1/g, -> - string_list.shift() - if muli_string and muli_string[0] - line = line.replace /\[(=*)\[([^\]\1\]]*)/, muli_string[0] - if comment and comment[0] - line = line.replace /\-{2}[^\[].*$/, comment[0] - line + string_list = line.match /(['"])[^\1]*?\1/g + muli_string = line.match /\[(=*)\[([^\]\1\]]*)/ + comment = line.match /\-{2}[^\[].*$/ + line = line.replace /\s+/g, ' ' + # replace all whitespaces inside the string with one space, WARNING: the whitespaces in string will be replace too! + line = line.replace /\s?(==|>=|<=|~=|[=><\+\*\/])\s?/g, ' $1 ' + # add whitespace around the operator + line = line.replace /([^=|\-|(|\s])\s?\-\s?([^\-|\[])/g, '$1 - $2' + # just format minus, not for -- or negative number or commentary. + line = line.replace /,([^\s])/g, ', $1' + # adjust ',' + line = line.replace /\s+,/g, ',' + # recover the whitespaces in string. + line = line.replace /(['"])[^\1]*?\1/g, -> + string_list.shift() + if muli_string and muli_string[0] + line = line.replace /\[(=*)\[([^\]\1\]]*)/, muli_string[0] + if comment and comment[0] + line = line.replace /\-{2}[^\[].*$/, comment[0] + line DEFAULT_WARN_FN = (msg) -> - console.log('WARNING:', msg) + console.log('WARNING:', msg) module.exports = (str, indent, warn_fn) -> - indent = indent or DEFAULT_INDENT - warn_fn = if typeof warn_fn == 'function' then warn_fn else DEFAULT_WARN_FN - indent = ' '.repeat(indent) if Number.isInteger(indent) - $currIndent = 0 - $nextIndent = 0 - $prevLength = 0 - $extIndent = 0 - $lastIndent = 0 - $template = 0 - new_code = str.split(/\r?\n/g).map (line, line_number) -> - $template_flag = false - if $template - res2 = line.match(/\](=*)\]/) - if res2 and $template == res2[1].length + 1 - $template_flag = true - if $template and !/]=*]$/.test(line) - arr = line.split(/\]=*\]/, 2) - comment = arr[0] - code = arr[1] - line = comment + ']' + '='.repeat($template - 1) + ']' + adjust_space(code) - $template = 0 - $template = 0 - else - return line - res1 = line.match(/\[(=*)\[/) - if res1 - $template = res1[1].length + 1 - if !$template_flag - line = line.trim() - # remote all spaces on both ends - line = adjust_space(line) - if !line.length - return '' - raw_line = line - line = line.replace(/(['"])[^\1]*?\1/, '') - # remove all quoted fragments for proper bracket processing - line = line.replace(/\s*--.+/, '') - # remove all comments; this ignores long bracket style comments - if /^((local )?function|repeat|while)\b/.test(line) and !/\bend\s*[\),;]*$/.test(line) or /\b(then|do)$/.test(line) and !/^elseif\b/.test(line) or /^if\b/.test(line) and /\bthen\b/.test(line) and !/\bend$/.test(line) or /\bfunction ?(?:\w+ )?\([^\)]*\)$/.test(line) and !/\bend$/.test(line) - $nextIndent = $currIndent + 1 - else if /^until\b/.test(line) or /^end\s*[\),;]*$/.test(line) or /^end\s*\)\s*\.\./.test(line) or /^else(if)?\b/.test(line) and /\bend$/.test(line) - $nextIndent = --$currIndent - else if /^else\b/.test(line) or /^elseif\b/.test(line) - $nextIndent = $currIndent - $currIndent = $currIndent - 1 - $brackets = (line.match(/\(/g) or []).length - ((line.match(/\)/g) or []).length) - # capture unbalanced brackets - $curly = (line.match(/\{/g) or []).length - ((line.match(/\}/g) or []).length) - # capture unbalanced curly brackets - # close (curly) brackets if needed - if $curly < 0 - $currIndent += $curly - if $brackets < 0 - $currIndent += $brackets - $nextIndent += $brackets + $curly - # console.log({last: $lastIndent, curr: $currIndent, next: $nextIndent, ext: $extIndent}) - if $currIndent - $lastIndent > 1 - $extIndent += $nextIndent - $lastIndent - 1 - $nextIndent = $currIndent = 1 + $lastIndent - if $currIndent - $lastIndent < -1 and $extIndent > 0 - $extIndent += $currIndent - $lastIndent + 1 - $currIndent = -1 + $lastIndent - if $nextIndent < $currIndent - $nextIndent = $currIndent - # console.log({last: $lastIndent, curr: $currIndent, next: $nextIndent, ext: $extIndent}) - warn_fn """negative indentation at line #{line_number}: #{raw_line}""" if $currIndent < 0 - new_line = (if raw_line.length and $currIndent > 0 and !$template_flag then indent.repeat($currIndent) else '') + raw_line - $useful = $prevLength > 0 or raw_line.length > 0 - $lastIndent = $currIndent - $currIndent = $nextIndent - $prevLength = raw_line.length - new_line or undefined + indent = indent or DEFAULT_INDENT + warn_fn = if typeof warn_fn == 'function' then warn_fn else DEFAULT_WARN_FN + indent = ' '.repeat(indent) if Number.isInteger(indent) + $currIndent = 0 + $nextIndent = 0 + $prevLength = 0 + $extIndent = 0 + $lastIndent = 0 + $template = 0 + new_code = str.split(/\r?\n/g).map (line, line_number) -> + $template_flag = false + if $template + res2 = line.match(/\](=*)\]/) + if res2 and $template == res2[1].length + 1 + $template_flag = true + if $template and !/]=*]$/.test(line) + arr = line.split(/\]=*\]/, 2) + comment = arr[0] + code = arr[1] + line = comment + ']' + '='.repeat($template - 1) + ']' + adjust_space(code) + $template = 0 + $template = 0 + else + return line + res1 = line.match(/\[(=*)\[/) + if res1 + $template = res1[1].length + 1 + if !$template_flag + line = line.trim() + # remote all spaces on both ends + line = adjust_space(line) + if !line.length + return '' + raw_line = line + line = line.replace(/(['"])[^\1]*?\1/, '') + # remove all quoted fragments for proper bracket processing + line = line.replace(/\s*--.+/, '') + # remove all comments; this ignores long bracket style comments + if /^((local )?function|repeat|while)\b/.test(line) and !/\bend\s*[\),;]*$/.test(line) or /\b(then|do)$/.test(line) and !/^elseif\b/.test(line) or /^if\b/.test(line) and /\bthen\b/.test(line) and !/\bend$/.test(line) or /\bfunction ?(?:\w+ )?\([^\)]*\)$/.test(line) and !/\bend$/.test(line) + $nextIndent = $currIndent + 1 + else if /^until\b/.test(line) or /^end\s*[\),;]*$/.test(line) or /^end\s*\)\s*\.\./.test(line) or /^else(if)?\b/.test(line) and /\bend$/.test(line) + $nextIndent = --$currIndent + else if /^else\b/.test(line) or /^elseif\b/.test(line) + $nextIndent = $currIndent + $currIndent = $currIndent - 1 + $brackets = (line.match(/\(/g) or []).length - ((line.match(/\)/g) or []).length) + # capture unbalanced brackets + $curly = (line.match(/\{/g) or []).length - ((line.match(/\}/g) or []).length) + # capture unbalanced curly brackets + # close (curly) brackets if needed + if $curly < 0 + $currIndent += $curly + if $brackets < 0 + $currIndent += $brackets + $nextIndent += $brackets + $curly + # console.log({last: $lastIndent, curr: $currIndent, next: $nextIndent, ext: $extIndent}) + if $currIndent - $lastIndent > 1 + $extIndent += $nextIndent - $lastIndent - 1 + $nextIndent = $currIndent = 1 + $lastIndent + if $currIndent - $lastIndent < -1 and $extIndent > 0 + $extIndent += $currIndent - $lastIndent + 1 + $currIndent = -1 + $lastIndent + if $nextIndent < $currIndent + $nextIndent = $currIndent + # console.log({last: $lastIndent, curr: $currIndent, next: $nextIndent, ext: $extIndent}) + warn_fn """negative indentation at line #{line_number}: #{raw_line}""" if $currIndent < 0 + new_line = (if raw_line.length and $currIndent > 0 and !$template_flag then indent.repeat($currIndent) else '') + raw_line + $useful = $prevLength > 0 or raw_line.length > 0 + $lastIndent = $currIndent + $currIndent = $nextIndent + $prevLength = raw_line.length + new_line or undefined - warn_fn 'positive indentation at the end' if $currIndent > 0 - new_code.join '\n' + warn_fn 'positive indentation at the end' if $currIndent > 0 + new_code.join '\n' From f9d643cc5f6b0e4132b0b1301d2230140ba9609b Mon Sep 17 00:00:00 2001 From: Li Yong Date: Fri, 31 Mar 2017 15:06:00 +0800 Subject: [PATCH 43/64] vue section mark right --- src/beautifiers/vue-beautifier.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/beautifiers/vue-beautifier.coffee b/src/beautifiers/vue-beautifier.coffee index bdfc661..85ee79b 100644 --- a/src/beautifiers/vue-beautifier.coffee +++ b/src/beautifiers/vue-beautifier.coffee @@ -11,7 +11,7 @@ module.exports = class VueBeautifier extends Beautifier beautify: (text, language, options) -> return new @Promise((resolve, reject) -> - regexp = /(<(template|script|style)[^>]*>)((\s|\S)*?)<\/\2>/gi + regexp = /(^<(template|script|style)[^>]*>)((\s|\S)*?)^<\/\2>/gim resolve(text.replace(regexp, (match, begin, type, text) -> lang = /lang\s*=\s*['"](\w+)["']/.exec(begin)?[1] From 86465ff084e1f845197bb2b9813fc4112e03ae21 Mon Sep 17 00:00:00 2001 From: Matthew Prestifilippo Date: Thu, 30 Mar 2017 09:29:14 -0400 Subject: [PATCH 44/64] Fix #1423 - extname is deprecated --- src/beautifiers/index.coffee | 47 +++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 077190e..e229452 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -140,20 +140,32 @@ module.exports = class Beautifiers extends EventEmitter ) or beautifiers[0] return beautifier - getLanguage : (grammar, filePath) -> + getExtension : (filePath) -> + if filePath + return path.extname(filePath).substr(1) + + getLanguages : (grammar, filePath) -> # Get language - fileExtension = path.extname(filePath) - # Remove prefix "." (period) in fileExtension - fileExtension = fileExtension.substr(1) - languages = @languages.getLanguages({grammar, extension: fileExtension}) - logger.verbose(languages, grammar, fileExtension) - # Check if unsupported language - if languages.length < 1 - return null + fileExtension = @getExtension(filePath) + + if fileExtension + languages = @languages.getLanguages({grammar, extension: fileExtension}) else - # TODO: select appropriate language + languages = @languages.getLanguages({grammar}) + + logger.verbose(languages, grammar, fileExtension) + + return languages + + getLanguage : (grammar, filePath) -> + languages = @getLanguages(grammar, filePath) + + # Check if unsupported language + if languages.length > 0 language = languages[0] + return language + getOptionsForLanguage : (allOptions, language) -> # Options for Language selections = (language.fallback or []).concat([language.namespace]) @@ -241,15 +253,10 @@ module.exports = class Beautifiers extends EventEmitter logger.info('beautify', text, allOptions, grammar, filePath, onSave) logger.verbose(allOptions) - # Get language - fileExtension = path.extname(filePath) - # Remove prefix "." (period) in fileExtension - fileExtension = fileExtension.substr(1) - languages = @languages.getLanguages({grammar, extension: fileExtension}) - logger.verbose(languages, grammar, fileExtension) + language = @getLanguage(grammar, filePath) # Check if unsupported language - if languages.length < 1 + if !language unsupportedGrammar = true logger.verbose('Unsupported language') @@ -260,19 +267,14 @@ module.exports = class Beautifiers extends EventEmitter # not intended to be beautified return resolve( null ) else - # TODO: select appropriate language - language = languages[0] - logger.verbose("Language #{language.name} supported") # Get language config langDisabled = atom.config.get("atom-beautify.#{language.namespace}.disabled") - # Beautify! unsupportedGrammar = false - # Check if Language is disabled if langDisabled logger.verbose("Language #{language.name} is disabled") @@ -370,6 +372,7 @@ module.exports = class Beautifiers extends EventEmitter if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors") return resolve( null ) else + fileExtension = @getExtension(filePath) repoBugsUrl = pkg.bugs.url title = "Atom Beautify could not find a supported beautifier for this file" detail = """ From 794a47ef880c93fcd4b94bca500211a7883775d0 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 01:34:35 -0300 Subject: [PATCH 45/64] Remove development pause notice --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 130a7fb..da87ff0 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,6 @@ Thank you. Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core! See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174). -## Temporary Pause With Development - -As I can see the Issues on GitHub are growing I want to let everyone know I still plan to maintain Atom-Beautify. Unfortunately, I will be fairly busy for a little while longer with my final semester of University (assignments, projects, exams, etc) and large work-related projects. Therefore, I apologize for my temporarily absense as I finish off these other commitments. My plan is to return to working on Atom-Beautify with a newfound energy to add features and squash bugs in Atom-Beautify when this University semester is over around mid-April 2017. Thank you for your understanding and patience during this time. - [Glavin](https://github.com/Glavin001) ## Language Support From ba2198675cbcc1ecd05f18e28e97133cdd2d5319 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 02:53:34 -0300 Subject: [PATCH 46/64] Add beautifiers information to README See https://github.com/Glavin001/atom-beautify/issues/1525#issuecomment-292817161 --- README-template.md | 6 +++ README.md | 54 +++++++++++++++++-- docs/index.coffee | 26 +++++++++ package.json | 2 +- src/beautifiers/autopep8.coffee | 1 + src/beautifiers/beautifier.coffee | 5 ++ src/beautifiers/beautysh.coffee | 2 + src/beautifiers/clang-format.coffee | 1 + src/beautifiers/crystal.coffee | 1 + src/beautifiers/dfmt.coffee | 1 + src/beautifiers/elm-format.coffee | 1 + src/beautifiers/erl_tidy.coffee | 1 + src/beautifiers/formatR/index.coffee | 1 + .../fortran-beautifier/index.coffee | 3 +- src/beautifiers/gofmt.coffee | 1 + src/beautifiers/hh_format.coffee | 1 + src/beautifiers/htmlbeautifier.coffee | 2 + src/beautifiers/latex-beautify.coffee | 1 + src/beautifiers/lua-beautifier/index.coffee | 3 +- src/beautifiers/ocp-indent.coffee | 1 + src/beautifiers/perltidy.coffee | 1 + src/beautifiers/php-cs-fixer.coffee | 1 + src/beautifiers/phpcbf.coffee | 1 + src/beautifiers/puppet-fix.coffee | 1 + src/beautifiers/rubocop.coffee | 1 + src/beautifiers/ruby-beautify.coffee | 1 + src/beautifiers/rustfmt.coffee | 1 + src/beautifiers/sass-convert.coffee | 1 + src/beautifiers/sqlformat.coffee | 1 + src/beautifiers/stylish-haskell.coffee | 1 + src/beautifiers/uncrustify/index.coffee | 2 + src/beautifiers/vue-beautifier.coffee | 1 + src/beautifiers/yapf.coffee | 1 + 33 files changed, 122 insertions(+), 6 deletions(-) diff --git a/README-template.md b/README-template.md index 34f56a8..82bca17 100644 --- a/README-template.md +++ b/README-template.md @@ -20,6 +20,7 @@ ## Table of Contents - [Installation](#installation) +- [Beautifiers](#beautifiers) - [Language Support](#language-support) - [Usage](#usage) - [Selection of Code](#selection-of-code) @@ -54,6 +55,11 @@ Thank you. Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core! See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174). +## Beautifiers + +Some of the supported beautifiers are developed for Node.js and are automatically installed when Atom-Beautify is installed. However, other beautifiers are command-line interface (CLI) applications and require you to manually install them. + +{{beautifiers-info beautifiers}} ## Language Support diff --git a/README.md b/README.md index da87ff0..f74d4a7 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ ## Table of Contents - [Installation](#installation) +- [Beautifiers](#beautifiers) - [Language Support](#language-support) - [Usage](#usage) - [Selection of Code](#selection-of-code) @@ -54,6 +55,53 @@ Thank you. Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core! See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174). +## Beautifiers + +Some of the supported beautifiers are developed for Node.js and are automatically installed when Atom-Beautify is installed. However, other beautifiers are command-line interface (CLI) applications and require you to manually install them. + +| Beautifier | Is Pre-Installed? | Installation Instructions | +| --- | --- | --- | ---- | +| autopep8 | :x: | Go to https://github.com/hhatto/autopep8 and follow the instructions. | +| beautysh | :x: | Go to https://github.com/bemeurer/beautysh and follow the instructions. | +| clang-format | :x: | Go to https://clang.llvm.org/docs/ClangFormat.html and follow the instructions. | +| cljfmt | :white_check_mark: | Nothing! | +| Coffee Formatter | :white_check_mark: | Nothing! | +| coffee-fmt | :white_check_mark: | Nothing! | +| Crystal | :x: | Go to http://crystal-lang.org and follow the instructions. | +| CSScomb | :white_check_mark: | Nothing! | +| dfmt | :x: | Go to https://github.com/Hackerpilot/dfmt and follow the instructions. | +| elm-format | :x: | Go to https://github.com/avh4/elm-format and follow the instructions. | +| erl_tidy | :x: | Go to http://erlang.org/doc/man/erl_tidy.html and follow the instructions. | +| formatR | :x: | Go to https://github.com/yihui/formatR and follow the instructions. | +| Fortran Beautifier | :x: | Go to https://www.gnu.org/software/emacs/ and follow the instructions. | +| Gherkin formatter | :white_check_mark: | Nothing! | +| gofmt | :x: | Go to https://golang.org/cmd/gofmt/ and follow the instructions. | +| hh_format | :x: | Go to http://hhvm.com/ and follow the instructions. | +| HTML Beautifier | :x: | Go to https://github.com/threedaymonk/htmlbeautifier and follow the instructions. | +| JS Beautify | :white_check_mark: | Nothing! | +| JSCS Fixer | :white_check_mark: | Nothing! | +| Latex Beautify | :x: | Go to https://github.com/cmhughes/latexindent.pl and follow the instructions. | +| Lua beautifier | :x: | Go to https://www.perl.org/ and follow the instructions. | +| Marko Beautifier | :white_check_mark: | Nothing! | +| ocp-indent | :x: | Go to https://www.typerex.org/ocp-indent.html and follow the instructions. | +| Perltidy | :x: | Go to http://perltidy.sourceforge.net/ and follow the instructions. | +| PHP-CS-Fixer | :x: | Go to https://github.com/FriendsOfPHP/PHP-CS-Fixer and follow the instructions. | +| PHPCBF | :x: | Go to http://php.net/manual/en/install.php and follow the instructions. | +| Pretty Diff | :white_check_mark: | Nothing! | +| Pug Beautify | :white_check_mark: | Nothing! | +| puppet-lint | :x: | Go to http://puppet-lint.com/ and follow the instructions. | +| Remark | :white_check_mark: | Nothing! | +| Rubocop | :x: | Go to https://github.com/bbatsov/rubocop and follow the instructions. | +| Ruby Beautify | :x: | Go to https://github.com/erniebrodeur/ruby-beautify and follow the instructions. | +| rustfmt | :x: | Go to https://github.com/nrc/rustfmt and follow the instructions. | +| SassConvert | :x: | Go to http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax and follow the instructions. | +| sqlformat | :x: | Go to https://github.com/andialbrecht/sqlparse and follow the instructions. | +| stylish-haskell | :x: | Go to https://github.com/jaspervdj/stylish-haskell and follow the instructions. | +| Tidy Markdown | :white_check_mark: | Nothing! | +| TypeScript Formatter | :white_check_mark: | Nothing! | +| Uncrustify | :x: | Go to https://github.com/uncrustify/uncrustify and follow the instructions. | +| Vue Beautifier | :white_check_mark: | Nothing! | +| yapf | :x: | Go to https://github.com/google/yapf and follow the instructions. | ## Language Support @@ -78,7 +126,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | Elm | `Elm` |`.elm` | [`elm-format`](https://github.com/avh4/elm-format) (Default) | | ERB | `HTML (Ruby - ERB)`, `HTML (Rails)` |`.erb` | [`HTML Beautifier`](https://github.com/threedaymonk/htmlbeautifier), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Erlang | `Erlang` |`.erl` | [`erl_tidy`](http://erlang.org/doc/man/erl_tidy.html) (Default) | -| Fortran | `Fortran - Modern` |`.f90`, `.F90`, `.f95`, `.F95` | [`Fortran Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/fortran-beautifier/emacs-fortran-formating-script.lisp) (Default) | +| Fortran | `Fortran - Modern` |`.f90`, `.F90`, `.f95`, `.F95` | [`Fortran Beautifier`](https://www.gnu.org/software/emacs/) (Default) | | gherkin | `Gherkin` |`.feature` | [`Gherkin formatter`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee) (Default) | | GLSL | `C`, `opencl`, `GLSL` |`.vert`, `.frag` | [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) (Default) | | Go | `Go` |`.go` | [`gofmt`](https://golang.org/cmd/gofmt/) (Default) | @@ -92,7 +140,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | JSX | `JSX`, `JavaScript (JSX)`, `Babel ES6 JavaScript`, `JavaScript with JSX` |`.jsx`, `.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | LaTeX | `LaTeX` |`.tex` | [`Latex Beautify`](https://github.com/cmhughes/latexindent.pl) (Default) | | LESS | `LESS` |`.less` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | -| Lua | `Lua` |`.lua` | [`Lua beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.pl) (Default) | +| Lua | `Lua` |`.lua` | [`Lua beautifier`](https://www.perl.org/) (Default) | | Markdown | `GitHub Markdown` |`.markdown`, `.md` | [`Remark`](https://github.com/wooorm/remark), [`Tidy Markdown`](https://github.com/slang800/tidy-markdown) (Default) | | Marko | `Marko` |`.marko` | [`Marko Beautifier`](https://github.com/marko-js/marko-prettyprint) (Default) | | Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default) | @@ -120,7 +168,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | UX Markup | `UX` |`.ux` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Vala | `Vala` |`.vala`, `.vapi` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | | Visualforce | `Visualforce` |`.page` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | -| Vue | `Vue Component` |`.vue` | `Vue Beautifier` (Default) | +| Vue | `Vue Component` |`.vue` | [`Vue Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee) (Default) | | XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP`, `GSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp`, `.gsp`, `.plist`, `.recipe` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | XTemplate | `XTemplate` |`.xtemplate` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | diff --git a/docs/index.coffee b/docs/index.coffee index 66b3247..482fc0f 100755 --- a/docs/index.coffee +++ b/docs/index.coffee @@ -150,6 +150,31 @@ Handlebars.registerHelper('language-options-support', (languageOptions, options) return new Handlebars.SafeString(results) ) + +Handlebars.registerHelper('beautifiers-info', (beautifiers, options) -> + + ### + | Beautifier | Is Pre-Installed? | Installation Instructions | + | --- | ---- | + | Pretty Diff | :white_check_mark: | N/A | + | AutoPEP8 | :x: | LINK | + ### + + rows = _.map(beautifiers, (beautifier, k) -> + name = beautifier.name + isPreInstalled = beautifier.isPreInstalled + link = beautifier.link + installationInstructions = if isPreInstalled then "Nothing!" else "Go to #{link} and follow the instructions." + return "| #{name} | #{if isPreInstalled then ':white_check_mark:' else ':x:'} | #{installationInstructions} |" + ) + results = """ + | Beautifier | Is Pre-Installed? | Installation Instructions | + | --- | --- | --- | ---- | + #{rows.join('\n')} + """ + return new Handlebars.SafeString(results) +) + sortKeysBy = (obj, comparator) -> keys = _.sortBy(_.keys(obj), (key) -> return if comparator then comparator(obj[key], key) else key @@ -176,6 +201,7 @@ context = { packageOptions: sortSettings(packageOptions) languageOptions: sortSettings(languageOptions) beautifierOptions: sortSettings(beautifierOptions) + beautifiers: _.sortBy(beautifier.beautifiers, (beautifier) -> beautifier.name.toLowerCase()) } result = template(context) readmeResult = readmeTemplate(context) diff --git a/package.json b/package.json index a91d8a9..df5b064 100644 --- a/package.json +++ b/package.json @@ -305,4 +305,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file diff --git a/src/beautifiers/autopep8.coffee b/src/beautifiers/autopep8.coffee index 3f4b546..cc1a234 100644 --- a/src/beautifiers/autopep8.coffee +++ b/src/beautifiers/autopep8.coffee @@ -9,6 +9,7 @@ module.exports = class Autopep8 extends Beautifier name: "autopep8" link: "https://github.com/hhatto/autopep8" + isPreInstalled: false options: { Python: true diff --git a/src/beautifiers/beautifier.coffee b/src/beautifiers/beautifier.coffee index e369ac6..40ba3ef 100644 --- a/src/beautifiers/beautifier.coffee +++ b/src/beautifiers/beautifier.coffee @@ -31,6 +31,11 @@ module.exports = class Beautifier ### options: {} + ### + Is the beautifier a command-line interface beautifier? + ### + isPreInstalled: true + ### Supported languages by this Beautifier diff --git a/src/beautifiers/beautysh.coffee b/src/beautifiers/beautysh.coffee index 62a22da..86626a3 100644 --- a/src/beautifiers/beautysh.coffee +++ b/src/beautifiers/beautysh.coffee @@ -4,6 +4,8 @@ Beautifier = require('./beautifier') module.exports = class BashBeautify extends Beautifier name: "beautysh" link: "https://github.com/bemeurer/beautysh" + isPreInstalled: false + options: { Bash: indent_size: true diff --git a/src/beautifiers/clang-format.coffee b/src/beautifiers/clang-format.coffee index 5fa9481..eb4fa32 100644 --- a/src/beautifiers/clang-format.coffee +++ b/src/beautifiers/clang-format.coffee @@ -11,6 +11,7 @@ module.exports = class ClangFormat extends Beautifier name: "clang-format" link: "https://clang.llvm.org/docs/ClangFormat.html" + isPreInstalled: false options: { "C++": false diff --git a/src/beautifiers/crystal.coffee b/src/beautifiers/crystal.coffee index 04c496c..cb1ad22 100644 --- a/src/beautifiers/crystal.coffee +++ b/src/beautifiers/crystal.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class Crystal extends Beautifier name: "Crystal" link: "http://crystal-lang.org" + isPreInstalled: false options: { Crystal: false diff --git a/src/beautifiers/dfmt.coffee b/src/beautifiers/dfmt.coffee index f77460b..0accd86 100644 --- a/src/beautifiers/dfmt.coffee +++ b/src/beautifiers/dfmt.coffee @@ -7,6 +7,7 @@ Beautifier = require('./beautifier') module.exports = class Dfmt extends Beautifier name: "dfmt" link: "https://github.com/Hackerpilot/dfmt" + isPreInstalled: false options: { D: false diff --git a/src/beautifiers/elm-format.coffee b/src/beautifiers/elm-format.coffee index 0623a79..af91cf5 100644 --- a/src/beautifiers/elm-format.coffee +++ b/src/beautifiers/elm-format.coffee @@ -7,6 +7,7 @@ Beautifier = require('./beautifier') module.exports = class ElmFormat extends Beautifier name: "elm-format" link: "https://github.com/avh4/elm-format" + isPreInstalled: false options: { Elm: true diff --git a/src/beautifiers/erl_tidy.coffee b/src/beautifiers/erl_tidy.coffee index a4d0bcd..c8e89ee 100644 --- a/src/beautifiers/erl_tidy.coffee +++ b/src/beautifiers/erl_tidy.coffee @@ -9,6 +9,7 @@ module.exports = class ErlTidy extends Beautifier name: "erl_tidy" link: "http://erlang.org/doc/man/erl_tidy.html" + isPreInstalled: false options: { Erlang: true diff --git a/src/beautifiers/formatR/index.coffee b/src/beautifiers/formatR/index.coffee index 7bfcee3..bf0e8f5 100644 --- a/src/beautifiers/formatR/index.coffee +++ b/src/beautifiers/formatR/index.coffee @@ -9,6 +9,7 @@ Beautifier = require('../beautifier') module.exports = class R extends Beautifier name: "formatR" link: "https://github.com/yihui/formatR" + isPreInstalled: false options: { R: true diff --git a/src/beautifiers/fortran-beautifier/index.coffee b/src/beautifiers/fortran-beautifier/index.coffee index 075290d..8fcd759 100644 --- a/src/beautifiers/fortran-beautifier/index.coffee +++ b/src/beautifiers/fortran-beautifier/index.coffee @@ -8,7 +8,8 @@ path = require("path") module.exports = class FortranBeautifier extends Beautifier name: "Fortran Beautifier" - link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/fortran-beautifier/emacs-fortran-formating-script.lisp" + link: "https://www.gnu.org/software/emacs/" + isPreInstalled: false options: { Fortran: true diff --git a/src/beautifiers/gofmt.coffee b/src/beautifiers/gofmt.coffee index 760a64a..31ded4d 100644 --- a/src/beautifiers/gofmt.coffee +++ b/src/beautifiers/gofmt.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class Gofmt extends Beautifier name: "gofmt" link: "https://golang.org/cmd/gofmt/" + isPreInstalled: false options: { Go: true diff --git a/src/beautifiers/hh_format.coffee b/src/beautifiers/hh_format.coffee index a2e0949..08986d0 100644 --- a/src/beautifiers/hh_format.coffee +++ b/src/beautifiers/hh_format.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class HhFormat extends Beautifier name: "hh_format" link: "http://hhvm.com/" + isPreInstalled: false options: PHP: false diff --git a/src/beautifiers/htmlbeautifier.coffee b/src/beautifiers/htmlbeautifier.coffee index 67558e4..f934d2f 100644 --- a/src/beautifiers/htmlbeautifier.coffee +++ b/src/beautifiers/htmlbeautifier.coffee @@ -8,6 +8,8 @@ Beautifier = require('./beautifier') module.exports = class HTMLBeautifier extends Beautifier name: "HTML Beautifier" link: "https://github.com/threedaymonk/htmlbeautifier" + isPreInstalled: false + options: { ERB: indent_size: true diff --git a/src/beautifiers/latex-beautify.coffee b/src/beautifiers/latex-beautify.coffee index bccfa11..1e13e7a 100644 --- a/src/beautifiers/latex-beautify.coffee +++ b/src/beautifiers/latex-beautify.coffee @@ -8,6 +8,7 @@ temp = require("temp").track() module.exports = class LatexBeautify extends Beautifier name: "Latex Beautify" link: "https://github.com/cmhughes/latexindent.pl" + isPreInstalled: false options: { LaTeX: true diff --git a/src/beautifiers/lua-beautifier/index.coffee b/src/beautifiers/lua-beautifier/index.coffee index c96c743..ff1ff42 100644 --- a/src/beautifiers/lua-beautifier/index.coffee +++ b/src/beautifiers/lua-beautifier/index.coffee @@ -7,7 +7,8 @@ Beautifier = require('../beautifier') module.exports = class Lua extends Beautifier name: "Lua beautifier" - link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.pl" + link: "https://www.perl.org/" + isPreInstalled: false options: { Lua: true diff --git a/src/beautifiers/ocp-indent.coffee b/src/beautifiers/ocp-indent.coffee index a7ea475..22c0463 100644 --- a/src/beautifiers/ocp-indent.coffee +++ b/src/beautifiers/ocp-indent.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class OCPIndent extends Beautifier name: "ocp-indent" link: "https://www.typerex.org/ocp-indent.html" + isPreInstalled: false options: { OCaml: true diff --git a/src/beautifiers/perltidy.coffee b/src/beautifiers/perltidy.coffee index 1823701..9ce6c00 100644 --- a/src/beautifiers/perltidy.coffee +++ b/src/beautifiers/perltidy.coffee @@ -7,6 +7,7 @@ Beautifier = require('./beautifier') module.exports = class PerlTidy extends Beautifier name: "Perltidy" link: "http://perltidy.sourceforge.net/" + isPreInstalled: false options: { Perl: true diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index 0cf8f01..959432d 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -10,6 +10,7 @@ module.exports = class PHPCSFixer extends Beautifier name: 'PHP-CS-Fixer' link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" + isPreInstalled: false options: PHP: true diff --git a/src/beautifiers/phpcbf.coffee b/src/beautifiers/phpcbf.coffee index 67ebd2f..0b0db2e 100644 --- a/src/beautifiers/phpcbf.coffee +++ b/src/beautifiers/phpcbf.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class PHPCBF extends Beautifier name: "PHPCBF" link: "http://php.net/manual/en/install.php" + isPreInstalled: false options: { _: diff --git a/src/beautifiers/puppet-fix.coffee b/src/beautifiers/puppet-fix.coffee index 20bd84c..4ae96ed 100644 --- a/src/beautifiers/puppet-fix.coffee +++ b/src/beautifiers/puppet-fix.coffee @@ -8,6 +8,7 @@ module.exports = class PuppetFix extends Beautifier # this is what displays as your Default Beautifier in Language Config name: "puppet-lint" link: "http://puppet-lint.com/" + isPreInstalled: false options: { Puppet: true diff --git a/src/beautifiers/rubocop.coffee b/src/beautifiers/rubocop.coffee index 20062a3..8a4d366 100644 --- a/src/beautifiers/rubocop.coffee +++ b/src/beautifiers/rubocop.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class Rubocop extends Beautifier name: "Rubocop" link: "https://github.com/bbatsov/rubocop" + isPreInstalled: false options: { Ruby: diff --git a/src/beautifiers/ruby-beautify.coffee b/src/beautifiers/ruby-beautify.coffee index 27a2c80..f710ec7 100644 --- a/src/beautifiers/ruby-beautify.coffee +++ b/src/beautifiers/ruby-beautify.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class RubyBeautify extends Beautifier name: "Ruby Beautify" link: "https://github.com/erniebrodeur/ruby-beautify" + isPreInstalled: false options: { Ruby: diff --git a/src/beautifiers/rustfmt.coffee b/src/beautifiers/rustfmt.coffee index e877820..8277653 100644 --- a/src/beautifiers/rustfmt.coffee +++ b/src/beautifiers/rustfmt.coffee @@ -11,6 +11,7 @@ versionCheckState = false module.exports = class Rustfmt extends Beautifier name: "rustfmt" link: "https://github.com/nrc/rustfmt" + isPreInstalled: false options: { Rust: true diff --git a/src/beautifiers/sass-convert.coffee b/src/beautifiers/sass-convert.coffee index 8e65da9..e53fa98 100644 --- a/src/beautifiers/sass-convert.coffee +++ b/src/beautifiers/sass-convert.coffee @@ -4,6 +4,7 @@ Beautifier = require('./beautifier') module.exports = class SassConvert extends Beautifier name: "SassConvert" link: "http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax" + isPreInstalled: false options: # TODO: Add support for options diff --git a/src/beautifiers/sqlformat.coffee b/src/beautifiers/sqlformat.coffee index 7095f3a..e6b0058 100644 --- a/src/beautifiers/sqlformat.coffee +++ b/src/beautifiers/sqlformat.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class Sqlformat extends Beautifier name: "sqlformat" link: "https://github.com/andialbrecht/sqlparse" + isPreInstalled: false options: { SQL: true diff --git a/src/beautifiers/stylish-haskell.coffee b/src/beautifiers/stylish-haskell.coffee index 65db98d..95ba9ad 100644 --- a/src/beautifiers/stylish-haskell.coffee +++ b/src/beautifiers/stylish-haskell.coffee @@ -8,6 +8,7 @@ Beautifier = require('./beautifier') module.exports = class StylishHaskell extends Beautifier name: "stylish-haskell" link: "https://github.com/jaspervdj/stylish-haskell" + isPreInstalled: false options: { Haskell: true diff --git a/src/beautifiers/uncrustify/index.coffee b/src/beautifiers/uncrustify/index.coffee index 92724c8..2ee1ae7 100644 --- a/src/beautifiers/uncrustify/index.coffee +++ b/src/beautifiers/uncrustify/index.coffee @@ -11,6 +11,8 @@ _ = require('lodash') module.exports = class Uncrustify extends Beautifier name: "Uncrustify" link: "https://github.com/uncrustify/uncrustify" + isPreInstalled: false + options: { Apex: true C: true diff --git a/src/beautifiers/vue-beautifier.coffee b/src/beautifiers/vue-beautifier.coffee index bdfc661..814893f 100644 --- a/src/beautifiers/vue-beautifier.coffee +++ b/src/beautifiers/vue-beautifier.coffee @@ -5,6 +5,7 @@ _ = require('lodash') module.exports = class VueBeautifier extends Beautifier name: "Vue Beautifier" + link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee" options: Vue: true diff --git a/src/beautifiers/yapf.coffee b/src/beautifiers/yapf.coffee index affd32e..5ba490c 100644 --- a/src/beautifiers/yapf.coffee +++ b/src/beautifiers/yapf.coffee @@ -9,6 +9,7 @@ module.exports = class Yapf extends Beautifier name: "yapf" link: "https://github.com/google/yapf" + isPreInstalled: false options: { Python: false From c40a5a4b5ad908e4cab3d1fb97b34ed44865797a Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 02:55:56 -0300 Subject: [PATCH 47/64] Fix beautifiers info table in README. See #1525 --- README.md | 2 +- docs/index.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f74d4a7..d3235ee 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Iss Some of the supported beautifiers are developed for Node.js and are automatically installed when Atom-Beautify is installed. However, other beautifiers are command-line interface (CLI) applications and require you to manually install them. | Beautifier | Is Pre-Installed? | Installation Instructions | -| --- | --- | --- | ---- | +| --- | --- | --- | | autopep8 | :x: | Go to https://github.com/hhatto/autopep8 and follow the instructions. | | beautysh | :x: | Go to https://github.com/bemeurer/beautysh and follow the instructions. | | clang-format | :x: | Go to https://clang.llvm.org/docs/ClangFormat.html and follow the instructions. | diff --git a/docs/index.coffee b/docs/index.coffee index 482fc0f..80539b9 100755 --- a/docs/index.coffee +++ b/docs/index.coffee @@ -169,7 +169,7 @@ Handlebars.registerHelper('beautifiers-info', (beautifiers, options) -> ) results = """ | Beautifier | Is Pre-Installed? | Installation Instructions | - | --- | --- | --- | ---- | + | --- | --- | --- | #{rows.join('\n')} """ return new Handlebars.SafeString(results) From 1982d7f405e74c8707def443da9af5b2eb2a5ad2 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 03:05:03 -0300 Subject: [PATCH 48/64] Fix linting issues --- src/beautifiers/index.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index e229452..4575fe5 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -146,7 +146,7 @@ module.exports = class Beautifiers extends EventEmitter getLanguages : (grammar, filePath) -> # Get language - fileExtension = @getExtension(filePath) + fileExtension = @getExtension(filePath) if fileExtension languages = @languages.getLanguages({grammar, extension: fileExtension}) @@ -256,7 +256,7 @@ module.exports = class Beautifiers extends EventEmitter language = @getLanguage(grammar, filePath) # Check if unsupported language - if !language + if !language unsupportedGrammar = true logger.verbose('Unsupported language') From 5ff3e2ada9a6c61a0dd6859f3e5bebf39ca0d36f Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 03:46:06 -0300 Subject: [PATCH 49/64] Update docs --- README.md | 3 ++- docs/options.md | 52 ++++++++++++++++++++++++------------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 85b4aef..61c8fb3 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | dfmt | :x: | Go to https://github.com/Hackerpilot/dfmt and follow the instructions. | | elm-format | :x: | Go to https://github.com/avh4/elm-format and follow the instructions. | | erl_tidy | :x: | Go to http://erlang.org/doc/man/erl_tidy.html and follow the instructions. | +| ESLint Fixer | :white_check_mark: | Nothing! | | formatR | :x: | Go to https://github.com/yihui/formatR and follow the instructions. | | Fortran Beautifier | :x: | Go to https://www.gnu.org/software/emacs/ and follow the instructions. | | Gherkin formatter | :white_check_mark: | Nothing! | @@ -135,7 +136,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | HTML | `HTML` |`.html` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | Jade | `Jade`, `Pug` |`.jade`, `.pug` | [`Pug Beautify`](https://github.com/vingorius/pug-beautify) (Default) | | Java | `Java` |`.java` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | -| JavaScript | `JavaScript` |`.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Pretty Diff`](https://github.com/prettydiff/prettydiff), [`ESLint Fixer`](https://github.com/eslint/eslint) | +| JavaScript | `JavaScript` |`.js` | [`ESLint Fixer`](https://github.com/eslint/eslint), [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | JSON | `JSON` |`.json` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | JSX | `JSX`, `JavaScript (JSX)`, `Babel ES6 JavaScript`, `JavaScript with JSX` |`.jsx`, `.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | LaTeX | `LaTeX` |`.tex` | [`Latex Beautify`](https://github.com/cmhughes/latexindent.pl) (Default) | diff --git a/docs/options.md b/docs/options.md index 6bb63b3..92af25a 100644 --- a/docs/options.md +++ b/docs/options.md @@ -4963,32 +4963,32 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify) #### [JavaScript](#javascript) -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`JSCS Fixer`](#jscs-fixer) [`Pretty Diff`](#pretty-diff) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`JSCS Fixer`](#jscs-fixer) [`ESLint Fixer`](#eslint-fixer) [`Pretty Diff`](#pretty-diff) -| Option | JS Beautify | JSCS Fixer | Pretty Diff | -| --- | --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `brace_style` | :white_check_mark: | :x: | :x: | -| `break_chained_methods` | :white_check_mark: | :x: | :white_check_mark: | -| `end_with_comma` | :white_check_mark: | :x: | :white_check_mark: | -| `end_with_newline` | :white_check_mark: | :x: | :x: | -| `eval_code` | :white_check_mark: | :x: | :x: | -| `indent_char` | :white_check_mark: | :x: | :white_check_mark: | -| `indent_level` | :white_check_mark: | :x: | :x: | -| `indent_size` | :white_check_mark: | :x: | :white_check_mark: | -| `indent_with_tabs` | :white_check_mark: | :x: | :white_check_mark: | -| `jslint_happy` | :white_check_mark: | :x: | :x: | -| `keep_array_indentation` | :white_check_mark: | :x: | :x: | -| `keep_function_indentation` | :white_check_mark: | :x: | :x: | -| `max_preserve_newlines` | :white_check_mark: | :x: | :x: | -| `preserve_newlines` | :white_check_mark: | :x: | :white_check_mark: | -| `space_after_anon_function` | :white_check_mark: | :x: | :white_check_mark: | -| `space_before_conditional` | :white_check_mark: | :x: | :x: | -| `space_in_paren` | :white_check_mark: | :x: | :white_check_mark: | -| `unescape_strings` | :white_check_mark: | :x: | :x: | -| `wrap_line_length` | :white_check_mark: | :x: | :white_check_mark: | +| Option | ESLint Fixer | JS Beautify | JSCS Fixer | Pretty Diff | +| --- | --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `brace_style` | :x: | :white_check_mark: | :x: | :x: | +| `break_chained_methods` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| `end_with_comma` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| `end_with_newline` | :x: | :white_check_mark: | :x: | :x: | +| `eval_code` | :x: | :white_check_mark: | :x: | :x: | +| `indent_char` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| `indent_level` | :x: | :white_check_mark: | :x: | :x: | +| `indent_size` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| `indent_with_tabs` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| `jslint_happy` | :x: | :white_check_mark: | :x: | :x: | +| `keep_array_indentation` | :x: | :white_check_mark: | :x: | :x: | +| `keep_function_indentation` | :x: | :white_check_mark: | :x: | :x: | +| `max_preserve_newlines` | :x: | :white_check_mark: | :x: | :x: | +| `preserve_newlines` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| `space_after_anon_function` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| `space_before_conditional` | :x: | :white_check_mark: | :x: | :x: | +| `space_in_paren` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| `unescape_strings` | :x: | :white_check_mark: | :x: | :x: | +| `wrap_line_length` | :x: | :white_check_mark: | :x: | :white_check_mark: | **Description**: @@ -5019,7 +5019,7 @@ Disable JavaScript Beautification **Type**: `string` -**Enum**: `JS Beautify` `JSCS Fixer` `Pretty Diff` +**Enum**: `JS Beautify` `JSCS Fixer` `ESLint Fixer` `Pretty Diff` **Description**: From 61f52cf15479d9c52e529648b97bc7f679afe89f Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 03:53:45 -0300 Subject: [PATCH 50/64] Change JSX default beautifier back to Pretty Diff --- src/languages/jsx.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/jsx.coffee b/src/languages/jsx.coffee index cf67710..f2af260 100644 --- a/src/languages/jsx.coffee +++ b/src/languages/jsx.coffee @@ -22,7 +22,7 @@ module.exports = { "js" ] - defaultBeautifier: "JS Beautify" + defaultBeautifier: "Pretty Diff" options: e4x: From c0f397a3ca3c586ad0388461689b591e7f8848b9 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 04:18:13 -0300 Subject: [PATCH 51/64] Update docs --- docs/options.md | 93 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 20 deletions(-) diff --git a/docs/options.md b/docs/options.md index 92af25a..943e3f1 100644 --- a/docs/options.md +++ b/docs/options.md @@ -2895,13 +2895,13 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Description**: -Wrap attributes to new lines [auto|force] (Supported by JS Beautify) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by JS Beautify) **Example `.jsbeautifyrc` Configuration** @@ -4110,13 +4110,13 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Description**: -Wrap attributes to new lines [auto|force] (Supported by JS Beautify) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by JS Beautify) **Example `.jsbeautifyrc` Configuration** @@ -4674,13 +4674,13 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Description**: -Wrap attributes to new lines [auto|force] (Supported by JS Beautify) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by JS Beautify) **Example `.jsbeautifyrc` Configuration** @@ -6088,6 +6088,7 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre | `beautify_on_save` | :white_check_mark: | :white_check_mark: | | `brace_style` | :white_check_mark: | :x: | | `break_chained_methods` | :white_check_mark: | :white_check_mark: | +| `e4x` | :white_check_mark: | :x: | | `end_with_comma` | :white_check_mark: | :white_check_mark: | | `end_with_newline` | :white_check_mark: | :x: | | `eval_code` | :white_check_mark: | :x: | @@ -6217,6 +6218,32 @@ Break chained method calls across subsequent lines (Supported by JS Beautify, Pr } ``` +##### [E4x](#e4x) + +**Namespace**: `jsx` + +**Key**: `e4x` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) + +**Description**: + +Support e4x/jsx syntax (Supported by JS Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "jsx": { + "e4x": true + } +} +``` + ##### [End with comma](#end-with-comma) **Namespace**: `js` @@ -7948,13 +7975,13 @@ List of tags (defaults to inline) that should not be reformatted (Supported by M **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`Marko Beautifier`](#marko-beautifier) **Description**: -Wrap attributes to new lines [auto|force] (Supported by Marko Beautifier) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by Marko Beautifier) **Example `.jsbeautifyrc` Configuration** @@ -8441,13 +8468,13 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Description**: -Wrap attributes to new lines [auto|force] (Supported by JS Beautify) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by JS Beautify) **Example `.jsbeautifyrc` Configuration** @@ -13501,13 +13528,13 @@ List of tags (defaults to inline) that should not be reformatted (Supported by V **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`Vue Beautifier`](#vue-beautifier) **Description**: -Wrap attributes to new lines [auto|force] (Supported by Vue Beautifier) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by Vue Beautifier) **Example `.jsbeautifyrc` Configuration** @@ -13996,13 +14023,13 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Description**: -Wrap attributes to new lines [auto|force] (Supported by JS Beautify) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by JS Beautify) **Example `.jsbeautifyrc` Configuration** @@ -15499,13 +15526,13 @@ Indent and sections. (Supported by JS Beautify) **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Description**: -Wrap attributes to new lines [auto|force] (Supported by JS Beautify) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by JS Beautify) **Example `.jsbeautifyrc` Configuration** @@ -15668,6 +15695,32 @@ List of tags (defaults to [head,body,/html] that should have an extra newline be } ``` +##### [E4x](#e4x) + +**Namespace**: `jsx` + +**Key**: `e4x` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) + +**Description**: + +Support e4x/jsx syntax (Supported by JS Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "jsx": { + "e4x": true + } +} +``` + ### Latex Beautify @@ -16051,13 +16104,13 @@ Maximum characters per line (0 disables) (Supported by Marko Beautifier) **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`Marko Beautifier`](#marko-beautifier) **Description**: -Wrap attributes to new lines [auto|force] (Supported by Marko Beautifier) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by Marko Beautifier) **Example `.jsbeautifyrc` Configuration** @@ -18133,13 +18186,13 @@ Indent and sections. (Supported by Vue Beautifier) **Type**: `string` -**Enum**: `auto` `force` +**Enum**: `auto` `force` `force-aligned` `force-expand-multiline` **Supported Beautifiers**: [`Vue Beautifier`](#vue-beautifier) **Description**: -Wrap attributes to new lines [auto|force] (Supported by Vue Beautifier) +Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] (Supported by Vue Beautifier) **Example `.jsbeautifyrc` Configuration** From 9373a63bd47456cf87fc788fea6d2ff191251631 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 04:20:17 -0300 Subject: [PATCH 52/64] Prepare 0.29.18 release --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 93c9b8d..9c35283 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom-beautify", "main": "./src/beautify", - "version": "0.29.17", + "version": "0.29.18", "private": true, "description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more in Atom", "repository": { @@ -316,4 +316,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} \ No newline at end of file +} From 84a81021bed53ce00c9ddd1b1e0950576c44e085 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Mon, 10 Apr 2017 04:39:42 -0300 Subject: [PATCH 53/64] Update docs --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 61c8fb3..6ef77a1 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | Coldfusion | `html` |`.cfm`, `.cfml`, `.cfc` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Clojure | `Clojure` |`.clj`, `.cljs`, `.edn` | [`cljfmt`](https://github.com/snoe/node-cljfmt) (Default) | | CoffeeScript | `CoffeeScript` |`.coffee` | [`Coffee Formatter`](https://github.com/Glavin001/Coffee-Formatter), [`coffee-fmt`](https://github.com/sterpe/coffee-fmt) (Default) | -| C++ | `C++` |`.h`, `.hh`, `.cc`, `.cpp`, `.cxx`, `.C`, `.c++`, `.hpp`, `.hxx`, `.h++` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | +| C++ | `C++` |`.h`, `.hh`, `.cc`, `.cpp`, `.cxx`, `.C`, `.cu`, `.c++`, `.hpp`, `.hxx`, `.h++`, `.cuh` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | | Crystal | `Crystal` |`.cr` | [`Crystal`](http://crystal-lang.org) (Default) | | C# | `C#` |`.cs` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | | CSS | `CSS` |`.css` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff), [`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) | diff --git a/package.json b/package.json index 9c35283..45e3ecd 100644 --- a/package.json +++ b/package.json @@ -316,4 +316,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file From 0d3649a9f70b6575430e5fa83f07f33974a09a9f Mon Sep 17 00:00:00 2001 From: "Keith (Neon)" Date: Wed, 12 Apr 2017 15:22:13 -0400 Subject: [PATCH 54/64] Add Pretty Diff support for Mustache --- src/beautifiers/prettydiff.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/beautifiers/prettydiff.coffee b/src/beautifiers/prettydiff.coffee index 2be957e..92d32c0 100644 --- a/src/beautifiers/prettydiff.coffee +++ b/src/beautifiers/prettydiff.coffee @@ -49,6 +49,7 @@ module.exports = class PrettyDiff extends Beautifier EJS: true HTML: true Handlebars: true + Mustache: true Nunjucks: true XML: true SVG: true From 62c16eef9cf131facb3ebbb1857ec588a977ea2c Mon Sep 17 00:00:00 2001 From: jkc07100 Date: Wed, 12 Apr 2017 17:59:38 -0400 Subject: [PATCH 55/64] Regenerate Documentation --- README.md | 2 +- docs/options.md | 56 ++++++++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 6ef77a1..dd963e4 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | Lua | `Lua` |`.lua` | [`Lua beautifier`](https://www.perl.org/) (Default) | | Markdown | `GitHub Markdown` |`.markdown`, `.md` | [`Remark`](https://github.com/wooorm/remark), [`Tidy Markdown`](https://github.com/slang800/tidy-markdown) (Default) | | Marko | `Marko` |`.marko` | [`Marko Beautifier`](https://github.com/marko-js/marko-prettyprint) (Default) | -| Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default) | +| Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | Nunjucks | `Nunjucks`, `Nunjucks Templates`, `HTML (Nunjucks Templates)` |`.njk`, `.nunjucks` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Objective-C | `Objective-C`, `Objective-C++` |`.m`, `.mm`, `.h` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | | OCaml | `OCaml` |`.ml` | [`ocp-indent`](https://www.typerex.org/ocp-indent.html) (Default) | diff --git a/docs/options.md b/docs/options.md index 943e3f1..65643a6 100644 --- a/docs/options.md +++ b/docs/options.md @@ -8047,26 +8047,26 @@ Maximum characters per line (0 disables) (Supported by Marko Beautifier) #### [Mustache](#mustache) -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) -| Option | JS Beautify | -| --- | --- | -| `disabled` | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | -| `brace_style` | :white_check_mark: | -| `end_with_newline` | :white_check_mark: | -| `extra_liners` | :white_check_mark: | -| `indent_char` | :white_check_mark: | -| `indent_inner_html` | :white_check_mark: | -| `indent_scripts` | :white_check_mark: | -| `indent_size` | :white_check_mark: | -| `max_preserve_newlines` | :white_check_mark: | -| `preserve_newlines` | :white_check_mark: | -| `unformatted` | :white_check_mark: | -| `wrap_attributes` | :white_check_mark: | -| `wrap_attributes_indent_size` | :white_check_mark: | -| `wrap_line_length` | :white_check_mark: | +| Option | JS Beautify | Pretty Diff | +| --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | +| `brace_style` | :white_check_mark: | :x: | +| `end_with_newline` | :white_check_mark: | :x: | +| `extra_liners` | :white_check_mark: | :x: | +| `indent_char` | :white_check_mark: | :white_check_mark: | +| `indent_inner_html` | :white_check_mark: | :x: | +| `indent_scripts` | :white_check_mark: | :x: | +| `indent_size` | :white_check_mark: | :white_check_mark: | +| `max_preserve_newlines` | :white_check_mark: | :x: | +| `preserve_newlines` | :white_check_mark: | :white_check_mark: | +| `unformatted` | :white_check_mark: | :x: | +| `wrap_attributes` | :white_check_mark: | :x: | +| `wrap_attributes_indent_size` | :white_check_mark: | :x: | +| `wrap_line_length` | :white_check_mark: | :white_check_mark: | **Description**: @@ -8097,7 +8097,7 @@ Disable Mustache Beautification **Type**: `string` -**Enum**: `JS Beautify` +**Enum**: `JS Beautify` `Pretty Diff` **Description**: @@ -8219,11 +8219,11 @@ List of tags (defaults to [head,body,/html] that should have an extra newline be **Type**: `string` -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) **Description**: -Indentation character (Supported by JS Beautify) +Indentation character (Supported by JS Beautify, Pretty Diff) **Example `.jsbeautifyrc` Configuration** @@ -8297,11 +8297,11 @@ Indent and sections. (Supported by JS Beautify) **Type**: `integer` -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) **Description**: -Indentation size/length (Supported by JS Beautify) +Indentation size/length (Supported by JS Beautify, Pretty Diff) **Example `.jsbeautifyrc` Configuration** @@ -8349,11 +8349,11 @@ Number of line-breaks to be preserved in one chunk (Supported by JS Beautify) **Type**: `boolean` -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) **Description**: -Preserve line-breaks (Supported by JS Beautify) +Preserve line-breaks (Supported by JS Beautify, Pretty Diff) **Example `.jsbeautifyrc` Configuration** @@ -8522,11 +8522,11 @@ Indent wrapped attributes to after N characters (Supported by JS Beautify) **Type**: `integer` -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) **Description**: -Maximum characters per line (0 disables) (Supported by JS Beautify) +Maximum characters per line (0 disables) (Supported by JS Beautify, Pretty Diff) **Example `.jsbeautifyrc` Configuration** From 3b56c809b6710e2ef00b5e74b895b3d397d3a340 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Thu, 13 Apr 2017 02:24:32 -0700 Subject: [PATCH 56/64] use tidy-markdown 2.0.3 explicitly Because 2.0.5 is broken Related to #1549 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 45e3ecd..134194e 100644 --- a/package.json +++ b/package.json @@ -160,7 +160,7 @@ "space-pen": "^5.1.1", "strip-json-comments": "^2.0.1", "temp": "^0.8.3", - "tidy-markdown": "^2.0.3", + "tidy-markdown": "2.0.3", "typescript": "^1.8.10", "typescript-formatter": "^2.3.0", "underscore-plus": "^1.6.6", @@ -316,4 +316,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} \ No newline at end of file +} From 0ac0c106eff2700abf0cf0f22d3c71326178dc2e Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 15 Apr 2017 01:59:06 -0300 Subject: [PATCH 57/64] Update docs --- docs/options.md | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/options.md b/docs/options.md index 5fd888e..d422691 100644 --- a/docs/options.md +++ b/docs/options.md @@ -9425,7 +9425,7 @@ Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules (Supported by PHP-CS-Fixer, PHPCBF) +Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -16637,7 +16637,7 @@ Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules (Supported by PHP-CS-Fixer, PHPCBF) +Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -16664,7 +16664,7 @@ Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS ru **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules (Supported by PHP-CS-Fixer, PHPCBF) +Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) **Example `.jsbeautifyrc` Configuration** diff --git a/package.json b/package.json index 832518b..d9d7b7b 100644 --- a/package.json +++ b/package.json @@ -321,4 +321,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file From 85a744fb98bab9d1282b47c2245ebb810b4def6d Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 15 Apr 2017 02:26:27 -0300 Subject: [PATCH 58/64] See #505 and #1494. Fix options of Nginx beautifier --- .../nginx/expected/nginx.conf | 326 +++++++++--------- src/beautifiers/nginx-beautify.coffee | 16 +- src/languages/nginx.coffee | 31 +- 3 files changed, 199 insertions(+), 174 deletions(-) diff --git a/examples/nested-jsbeautifyrc/nginx/expected/nginx.conf b/examples/nested-jsbeautifyrc/nginx/expected/nginx.conf index 866efd8..287f07e 100644 --- a/examples/nested-jsbeautifyrc/nginx/expected/nginx.conf +++ b/examples/nested-jsbeautifyrc/nginx/expected/nginx.conf @@ -10,194 +10,194 @@ error_log logs/error.log info; events { - worker_connections 1024; + worker_connections 1024; } http { - include mime.types; - default_type application/octet-stream; + include mime.types; + default_type application/octet-stream; - #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - # '$status $body_bytes_sent "$http_referer" ' - # '"$http_user_agent" "$http_x_forwarded_for"'; + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; - #access_log logs/access.log main; - sendfile on; - #tcp_nopush on; + #access_log logs/access.log main; + sendfile on; + #tcp_nopush on; - #keepalive_timeout 0; - keepalive_timeout 65; + #keepalive_timeout 0; + keepalive_timeout 65; - #gzip on; + #gzip on; - server - { - listen 80; - server_name localhost; + server + { + listen 80; + server_name localhost; - #charset koi8-r; + #charset koi8-r; - #access_log logs/host.access.log main; - location / - { - root /usr/share/nginx/html; - index index.html index.htm; - } + #access_log logs/host.access.log main; + location / + { + root /usr/share/nginx/html; + index index.html index.htm; + } - #error_page 404 /404.html; + #error_page 404 /404.html; - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html - { - root /usr/share/nginx/html; - } + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html + { + root /usr/share/nginx/html; + } - # proxy the PHP scripts to Apache listening on 127.0.0.1:80 - # - #location ~ \.php$ { - # proxy_pass http://127.0.0.1; - #} + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} - # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 - # - #location ~ \.php$ { - # root html; - # fastcgi_pass 127.0.0.1:9000; - # fastcgi_index index.php; - # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; - # include fastcgi_params; - #} - # deny access to .htaccess files, if Apache's document root - # concurs with nginx's one - # - #location ~ /\.ht { - # deny all; - #} - } + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + } - server - { - listen 80; - include mime.types; - server_name dv; - location /nginxstatic/ - { - alias /srv/http/dv/; - limit_rate 250k; - } + server + { + listen 80; + include mime.types; + server_name dv; + location /nginxstatic/ + { + alias /srv/http/dv/; + limit_rate 250k; + } - location / - { - #root /srv/http/dv/; - #index index.html; - limit_rate 1M; - #limit_conn addr 1; - proxy_pass http://localhost:3000/; - } - } + location / + { + #root /srv/http/dv/; + #index index.html; + limit_rate 1M; + #limit_conn addr 1; + proxy_pass http://localhost:3000/; + } + } - server - { - listen 80; - server_name ip.dv; - root /home/http/ip/; - include mime.types; - location / - { - try_files $uri $uri/ /index.php; - } - location ~ .php$ - { - try_files $uri =404; - fastcgi_pass unix:/var/run/php5-fpm/socket_name.socket; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } - } + server + { + listen 80; + server_name ip.dv; + root /home/http/ip/; + include mime.types; + location / + { + try_files $uri $uri/ /index.php; + } + location ~ .php$ + { + try_files $uri =404; + fastcgi_pass unix:/var/run/php5-fpm/socket_name.socket; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + } - server - { - listen 80; - server_name pma.dv; - location / - { - root /home/http/pma/; - index index.php; - } + server + { + listen 80; + server_name pma.dv; + location / + { + root /home/http/pma/; + index index.php; + } - location ~ \.php$ - { - fastcgi_pass unix:/run/php-fpm/php-fpm.sock; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME /home/http/pma/$fastcgi_script_name; - include fastcgi_params; - } - } - server - { - listen 80; - server_name swissecurity.coelis; - location / - { - root /srv/http/swissecurity-fm/; - index index.html; - } - } + location ~ \.php$ + { + fastcgi_pass unix:/run/php-fpm/php-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME /home/http/pma/$fastcgi_script_name; + include fastcgi_params; + } + } + server + { + listen 80; + server_name swissecurity.coelis; + location / + { + root /srv/http/swissecurity-fm/; + index index.html; + } + } - server - { - listen 80; - server_name p1.dv; - location / - { - proxy_pass http://127.0.0.1:1337/; - } - } + server + { + listen 80; + server_name p1.dv; + location / + { + proxy_pass http://127.0.0.1:1337/; + } + } - server - { - listen 80; - server_name s.dev; - location / - { - proxy_pass http://127.0.0.1:1337/; - } - } + server + { + listen 80; + server_name s.dev; + location / + { + proxy_pass http://127.0.0.1:1337/; + } + } - # another virtual host using mix of IP-, name-, and port-based configuration - # - #server { - # listen 8000; - # listen somename:8080; - # server_name somename alias another.alias; - # location / { - # root html; - # index index.html index.htm; - # } - #} - # HTTPS server - # - #server { - # listen 443 ssl; - # server_name localhost; - # ssl_certificate cert.pem; - # ssl_certificate_key cert.key; - # ssl_session_cache shared:SSL:1m; - # ssl_session_timeout 5m; - # ssl_ciphers HIGH:!aNULL:!MD5; - # ssl_prefer_server_ciphers on; - # location / { - # root html; - # index index.html index.htm; - # } - #} + # another virtual host using mix of IP-, name-, and port-based configuration + # + #server { + # listen 8000; + # listen somename:8080; + # server_name somename alias another.alias; + # location / { + # root html; + # index index.html index.htm; + # } + #} + # HTTPS server + # + #server { + # listen 443 ssl; + # server_name localhost; + # ssl_certificate cert.pem; + # ssl_certificate_key cert.key; + # ssl_session_cache shared:SSL:1m; + # ssl_session_timeout 5m; + # ssl_ciphers HIGH:!aNULL:!MD5; + # ssl_prefer_server_ciphers on; + # location / { + # root html; + # index index.html index.htm; + # } + #} } diff --git a/src/beautifiers/nginx-beautify.coffee b/src/beautifiers/nginx-beautify.coffee index 12fbed2..088d7d8 100644 --- a/src/beautifiers/nginx-beautify.coffee +++ b/src/beautifiers/nginx-beautify.coffee @@ -6,7 +6,21 @@ module.exports = class NginxBeautify extends Beautifier link: "https://github.com/denysvitali/nginxbeautify" options: { - Nginx: true + Nginx: { + spaces: ["indent_with_tabs", "indent_size", "indent_char", (indent_with_tabs, indent_size, indent_char) -> + if indent_with_tabs or indent_char is "\t" + 0 + else + indent_size + ] + tabs: ["indent_with_tabs", "indent_size", "indent_char", (indent_with_tabs, indent_size, indent_char) -> + if indent_with_tabs or indent_char is "\t" + indent_size + else + 0 + ] + dontJoinCurlyBracet: true + } } beautify: (text, language, options) -> diff --git a/src/languages/nginx.coffee b/src/languages/nginx.coffee index f9a9833..1ea7f2c 100644 --- a/src/languages/nginx.coffee +++ b/src/languages/nginx.coffee @@ -1,3 +1,11 @@ +# Get Atom defaults +scope = ['source.conf'] +tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4 +softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true +defaultIndentSize = (if softTabs then tabLength else 1) +defaultIndentChar = (if softTabs then " " else "\t") +defaultIndentWithTabs = not softTabs + module.exports = { name: "Nginx" @@ -20,16 +28,19 @@ module.exports = { defaultBeautifier: "Nginx Beautify" options: - spaces: - title: "Spaces" - type: "number" - default: 0 - description: "Indent with spaces" - tabs: - title: "Tabs" - type: "number" - default: 1 - description: "Indent with tabs" + indent_size: + type: 'integer' + default: defaultIndentSize + minimum: 0 + description: "Indentation size/length" + indent_char: + type: 'string' + default: defaultIndentChar + description: "Indentation character" + indent_with_tabs: + type: 'boolean' + default: defaultIndentWithTabs + description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`" dontJoinCurlyBracet: title: "Don't join curly brackets" type: "boolean" From 66830b53fc9c8bde8e136dd721167677519ef1e2 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 15 Apr 2017 02:27:12 -0300 Subject: [PATCH 59/64] Update docs. See #505 and #1494 --- README.md | 3 +- docs/options.md | 101 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 79 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 2923fb9..21170c5 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | Latex Beautify | :x: | Go to https://github.com/cmhughes/latexindent.pl and follow the instructions. | | Lua beautifier | :x: | Go to https://www.perl.org/ and follow the instructions. | | Marko Beautifier | :white_check_mark: | Nothing! | +| Nginx Beautify | :white_check_mark: | Nothing! | | ocp-indent | :x: | Go to https://www.typerex.org/ocp-indent.html and follow the instructions. | | Perltidy | :x: | Go to http://perltidy.sourceforge.net/ and follow the instructions. | | PHP-CS-Fixer | :x: | Go to https://github.com/FriendsOfPHP/PHP-CS-Fixer and follow the instructions. | @@ -145,8 +146,8 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | Lua | `Lua` |`.lua` | [`Lua beautifier`](https://www.perl.org/) (Default) | | Markdown | `GitHub Markdown` |`.markdown`, `.md` | [`Remark`](https://github.com/wooorm/remark), [`Tidy Markdown`](https://github.com/slang800/tidy-markdown) (Default) | | Marko | `Marko` |`.marko` | [`Marko Beautifier`](https://github.com/marko-js/marko-prettyprint) (Default) | -| Nginx | `nginx` |`.conf` | [`Nginx Beautify`](https://github.com/denysvitali/nginxbeautify) (Default) | | Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | +| Nginx | `nginx` |`.conf` | [`Nginx Beautify`](https://github.com/denysvitali/nginxbeautify) (Default) | | Nunjucks | `Nunjucks`, `Nunjucks Templates`, `HTML (Nunjucks Templates)` |`.njk`, `.nunjucks` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Objective-C | `Objective-C`, `Objective-C++` |`.m`, `.mm`, `.h` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | | OCaml | `OCaml` |`.ml` | [`ocp-indent`](https://www.typerex.org/ocp-indent.html) (Default) | diff --git a/docs/options.md b/docs/options.md index b0492fc..7e884f4 100644 --- a/docs/options.md +++ b/docs/options.md @@ -8725,8 +8725,9 @@ Maximum characters per line (0 disables) (Supported by JS Beautify, Pretty Diff) | `default_beautifier` | :white_check_mark: | | `beautify_on_save` | :white_check_mark: | | `dontJoinCurlyBracet` | :white_check_mark: | -| `spaces` | :white_check_mark: | -| `tabs` | :white_check_mark: | +| `indent_char` | :white_check_mark: | +| `indent_size` | :white_check_mark: | +| `indent_with_tabs` | :white_check_mark: | **Description**: @@ -8813,52 +8814,78 @@ undefined (Supported by Nginx Beautify) } ``` -##### [Spaces](#spaces) +##### [Indent char](#indent-char) **Namespace**: `nginx` -**Key**: `spaces` +**Key**: `indent_char` -**Type**: `number` +**Default**: ` ` + +**Type**: `string` **Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) **Description**: -Indent with spaces (Supported by Nginx Beautify) +Indentation character (Supported by Nginx Beautify) **Example `.jsbeautifyrc` Configuration** ```json { "nginx": { - "spaces": 0 + "indent_char": " " } } ``` -##### [Tabs](#tabs) +##### [Indent size](#indent-size) **Namespace**: `nginx` -**Key**: `tabs` +**Key**: `indent_size` -**Default**: `1` +**Default**: `4` -**Type**: `number` +**Type**: `integer` **Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) **Description**: -Indent with tabs (Supported by Nginx Beautify) +Indentation size/length (Supported by Nginx Beautify) **Example `.jsbeautifyrc` Configuration** ```json { "nginx": { - "tabs": 1 + "indent_size": 4 + } +} +``` + +##### [Indent with tabs](#indent-with-tabs) + +**Namespace**: `nginx` + +**Key**: `indent_with_tabs` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Nginx Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "nginx": { + "indent_with_tabs": false } } ``` @@ -16677,52 +16704,78 @@ List of tags (defaults to [head,body,/html] that should have an extra newline be ### Nginx Beautify -##### [Spaces](#spaces) +##### [Indent size](#indent-size) **Namespace**: `nginx` -**Key**: `spaces` +**Key**: `indent_size` -**Type**: `number` +**Default**: `4` + +**Type**: `integer` **Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) **Description**: -Indent with spaces (Supported by Nginx Beautify) +Indentation size/length (Supported by Nginx Beautify) **Example `.jsbeautifyrc` Configuration** ```json { "nginx": { - "spaces": 0 + "indent_size": 4 } } ``` -##### [Tabs](#tabs) +##### [Indent char](#indent-char) **Namespace**: `nginx` -**Key**: `tabs` +**Key**: `indent_char` -**Default**: `1` +**Default**: ` ` -**Type**: `number` +**Type**: `string` **Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) **Description**: -Indent with tabs (Supported by Nginx Beautify) +Indentation character (Supported by Nginx Beautify) **Example `.jsbeautifyrc` Configuration** ```json { "nginx": { - "tabs": 1 + "indent_char": " " + } +} +``` + +##### [Indent with tabs](#indent-with-tabs) + +**Namespace**: `nginx` + +**Key**: `indent_with_tabs` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Nginx Beautify`](#nginx-beautify) + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Nginx Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "nginx": { + "indent_with_tabs": false } } ``` From a1b19ba8aabb8b9216ce78a271a70002d37b7dcf Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 15 Apr 2017 02:47:17 -0300 Subject: [PATCH 60/64] See #1333 and #1437. fix vue nested templates formatted incorrectly --- src/beautifiers/vue-beautifier.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/beautifiers/vue-beautifier.coffee b/src/beautifiers/vue-beautifier.coffee index 0e09093..f62d8f8 100644 --- a/src/beautifiers/vue-beautifier.coffee +++ b/src/beautifiers/vue-beautifier.coffee @@ -12,7 +12,7 @@ module.exports = class VueBeautifier extends Beautifier beautify: (text, language, options) -> return new @Promise((resolve, reject) -> - regexp = /(^<(template|script|style)[^>]*>)((\s|\S)*?)^<\/\2>/gim + regexp = /(^<(template|script|style)[^>]*>)((\s|\S)*)^<\/\2>/gim resolve(text.replace(regexp, (match, begin, type, text) -> lang = /lang\s*=\s*['"](\w+)["']/.exec(begin)?[1] From b63fc3bc18e217b8b53053cf63a00cb72d96fc36 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 15 Apr 2017 03:12:19 -0300 Subject: [PATCH 61/64] Update docs --- README.md | 1 + docs/options.md | 272 ++++++++++++++++++++++-------------------------- 2 files changed, 124 insertions(+), 149 deletions(-) diff --git a/README.md b/README.md index 54df8cc..b1a431c 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | Pretty Diff | :white_check_mark: | Nothing! | | Pug Beautify | :white_check_mark: | Nothing! | | puppet-lint | :x: | Go to http://puppet-lint.com/ and follow the instructions. | +| pybeautifier | :white_check_mark: | Nothing! | | Remark | :white_check_mark: | Nothing! | | Rubocop | :x: | Go to https://github.com/bbatsov/rubocop and follow the instructions. | | Ruby Beautify | :x: | Go to https://github.com/erniebrodeur/ruby-beautify and follow the instructions. | diff --git a/docs/options.md b/docs/options.md index 4655344..0e4b4ba 100644 --- a/docs/options.md +++ b/docs/options.md @@ -124,6 +124,25 @@ Do not show "Unsupported Language" errors when they occur 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Mute Unsupported Language Errors*" and change it to your desired configuration. +##### [Show Loading View](#show-loading-view) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `true` + +**Type**: `boolean` + +**Description**: + +Show loading view when beautifying + +**How to Configure** + +1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to +*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*. +2. Go into *Packages* and search for "*Atom Beautify*" package. +3. Find the option "*Show Loading View*" and change it to your desired configuration. + ## Language Options @@ -9683,17 +9702,20 @@ Automatically beautify Puppet files on save #### [Python](#python) -**Supported Beautifiers**: [`autopep8`](#autopep8) [`yapf`](#yapf) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) [`yapf`](#yapf) -| Option | autopep8 | yapf | -| --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | -| `ignore` | :white_check_mark: | :x: | -| `indent_size` | :white_check_mark: | :x: | -| `max_line_length` | :white_check_mark: | :x: | -| `sort_imports` | :white_check_mark: | :x: | +| Option | autopep8 | pybeautifier | yapf | +| --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `formater` | :white_check_mark: | :white_check_mark: | :x: | +| `ignore` | :white_check_mark: | :white_check_mark: | :x: | +| `indent_size` | :white_check_mark: | :white_check_mark: | :x: | +| `max_line_length` | :white_check_mark: | :white_check_mark: | :x: | +| `multi_line_output` | :white_check_mark: | :white_check_mark: | :x: | +| `sort_imports` | :white_check_mark: | :white_check_mark: | :x: | +| `style_config` | :white_check_mark: | :white_check_mark: | :x: | **Description**: @@ -9724,7 +9746,7 @@ Disable Python Beautification **Type**: `string` -**Enum**: `autopep8` `yapf` +**Enum**: `autopep8` `pybeautifier` `yapf` **Description**: @@ -9754,6 +9776,34 @@ Automatically beautify Python files on save 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Beautify On Save*" and change it to your desired configuration. +##### [Formater](#formater) + +**Namespace**: `python` + +**Key**: `formater` + +**Default**: `autopep8` + +**Type**: `string` + +**Enum**: `autopep8` `yapf` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +formater used by pybeautifier (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "formater": "autopep8" + } +} +``` + ##### [Ignore](#ignore) **Namespace**: `python` @@ -9764,11 +9814,11 @@ Automatically beautify Python files on save **Type**: `array` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -do not fix these errors/warnings (Supported by autopep8) +do not fix these errors/warnings (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -9792,11 +9842,11 @@ do not fix these errors/warnings (Supported by autopep8) **Type**: `integer` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -Indentation size/length (Supported by autopep8) +Indentation size/length (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -9818,11 +9868,11 @@ Indentation size/length (Supported by autopep8) **Type**: `integer` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -set maximum allowed line length (Supported by autopep8) +set maximum allowed line length (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -9834,6 +9884,34 @@ set maximum allowed line length (Supported by autopep8) } ``` +##### [Multi line output](#multi-line-output) + +**Namespace**: `python` + +**Key**: `multi_line_output` + +**Default**: `Hanging Grid Grouped` + +**Type**: `string` + +**Enum**: `Grid` `Vertical` `Hanging Indent` `Vertical Hanging Indent` `Hanging Grid` `Hanging Grid Grouped` `NOQA` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +defines how from imports wrap (requires isort installed) (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "multi_line_output": "Hanging Grid Grouped" + } +} +``` + ##### [Sort imports](#sort-imports) **Namespace**: `python` @@ -9842,11 +9920,11 @@ set maximum allowed line length (Supported by autopep8) **Type**: `boolean` -**Supported Beautifiers**: [`autopep8`](#autopep8) +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) **Description**: -sort imports (requires isort installed) (Supported by autopep8) +sort imports (requires isort installed) (Supported by autopep8, pybeautifier) **Example `.jsbeautifyrc` Configuration** @@ -9858,6 +9936,32 @@ sort imports (requires isort installed) (Supported by autopep8) } ``` +##### [Style config](#style-config) + +**Namespace**: `python` + +**Key**: `style_config` + +**Default**: `pep8` + +**Type**: `string` + +**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) + +**Description**: + +formatting style used by yapf (Supported by autopep8, pybeautifier) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "python": { + "style_config": "pep8" + } +} +``` + #### [R](#r) **Supported Beautifiers**: [`formatR`](#formatr) @@ -10573,21 +10677,6 @@ Path to custom CSScomb config file, used in absense of a `.csscomb.json` or `.cs } ``` -**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) [`yapf`](#yapf) - -| Option | autopep8 | pybeautifier | yapf | -| --- | --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `formater` | :white_check_mark: | :white_check_mark: | :x: | -| `ignore` | :white_check_mark: | :white_check_mark: | :x: | -| `indent_size` | :white_check_mark: | :white_check_mark: | :x: | -| `max_line_length` | :white_check_mark: | :white_check_mark: | :x: | -| `multi_line_output` | :white_check_mark: | :white_check_mark: | :x: | -| `sort_imports` | :white_check_mark: | :white_check_mark: | :x: | -| `style_config` | :white_check_mark: | :white_check_mark: | :x: | - ##### [Convert quotes](#convert-quotes) **Namespace**: `css` @@ -10624,8 +10713,6 @@ Convert the quote characters delimiting strings from either double or single quo **Type**: `boolean` -**Enum**: `autopep8` `pybeautifier` `yapf` - **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) **Description**: @@ -10668,34 +10755,6 @@ Indentation character (Supported by Pretty Diff) } ``` -##### [Formater](#formater) - -**Namespace**: `python` - -**Key**: `formater` - -**Default**: `autopep8` - -**Type**: `string` - -**Enum**: `autopep8` `yapf` - -**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) - -**Description**: - -formater used by pybeautifier (Supported by autopep8, pybeautifier) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "python": { - "formater": "autopep8" - } -} -``` - ##### [Indent comments](#indent-comments) **Namespace**: `css` @@ -10706,12 +10765,6 @@ formater used by pybeautifier (Supported by autopep8, pybeautifier) **Type**: `boolean` -**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) - -**Description**: - -do not fix these errors/warnings (Supported by autopep8, pybeautifier) - **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) **Description**: @@ -10738,20 +10791,12 @@ Determines whether comments should be indented. (Supported by Pretty Diff) **Type**: `integer` - -**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) - -**Description**: - -Indentation size/length (Supported by autopep8, pybeautifier) - **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) **Description**: Indentation size/length (Supported by Pretty Diff) - **Example `.jsbeautifyrc` Configuration** ```json @@ -10772,11 +10817,6 @@ Indentation size/length (Supported by Pretty Diff) **Type**: `boolean` -**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) - -**Description**: - -set maximum allowed line length (Supported by autopep8, pybeautifier) **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) **Description**: @@ -10793,36 +10833,6 @@ Add a newline between CSS rules (Supported by Pretty Diff) } ``` -##### [Multi line output](#multi-line-output) - -**Namespace**: `python` - -**Key**: `multi_line_output` - -**Default**: `Hanging Grid Grouped` - -**Type**: `string` - -**Enum**: `Grid` `Vertical` `Hanging Indent` `Vertical Hanging Indent` `Hanging Grid` `Hanging Grid Grouped` `NOQA` - -**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) - -**Description**: - -defines how from imports wrap (requires isort installed) (Supported by autopep8, pybeautifier) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "python": { - "multi_line_output": "Hanging Grid Grouped" - } -} -``` - -##### [Sort imports](#sort-imports) - ##### [No lead zero](#no-lead-zero) **Namespace**: `css` @@ -10831,12 +10841,6 @@ defines how from imports wrap (requires isort installed) (Supported by autopep8, **Type**: `boolean` -**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) - -**Description**: - -sort imports (requires isort installed) (Supported by autopep8, pybeautifier) - **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) **Description**: @@ -10853,36 +10857,6 @@ If in CSS values leading 0s immediately preceeding a decimal should be removed o } ``` -##### [Style config](#style-config) - -**Namespace**: `python` - -**Key**: `style_config` - -**Default**: `pep8` - -**Type**: `string` - -**Supported Beautifiers**: [`autopep8`](#autopep8) [`pybeautifier`](#pybeautifier) - -**Description**: - -formatting style used by yapf (Supported by autopep8, pybeautifier) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "python": { - "style_config": "pep8" - } -} -``` - -#### [R](#r) - -**Supported Beautifiers**: [`formatR`](#formatr) - ##### [comb predefined config](#comb-predefined-config) **Namespace**: `css` From 7e958d0db0d4e6256308a509dcc6a2fa8c457aeb Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 15 Apr 2017 03:16:36 -0300 Subject: [PATCH 62/64] Update docs --- README.md | 4 ++-- src/beautifiers/nginx-beautify.coffee | 1 + src/beautifiers/pybeautifier.coffee | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b1a431c..b0f2e9f 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | Latex Beautify | :x: | Go to https://github.com/cmhughes/latexindent.pl and follow the instructions. | | Lua beautifier | :x: | Go to https://www.perl.org/ and follow the instructions. | | Marko Beautifier | :white_check_mark: | Nothing! | -| Nginx Beautify | :white_check_mark: | Nothing! | +| Nginx Beautify | :x: | Go to https://github.com/denysvitali/nginxbeautify and follow the instructions. | | ocp-indent | :x: | Go to https://www.typerex.org/ocp-indent.html and follow the instructions. | | Perltidy | :x: | Go to http://perltidy.sourceforge.net/ and follow the instructions. | | PHP-CS-Fixer | :x: | Go to https://github.com/FriendsOfPHP/PHP-CS-Fixer and follow the instructions. | @@ -92,7 +92,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | Pretty Diff | :white_check_mark: | Nothing! | | Pug Beautify | :white_check_mark: | Nothing! | | puppet-lint | :x: | Go to http://puppet-lint.com/ and follow the instructions. | -| pybeautifier | :white_check_mark: | Nothing! | +| pybeautifier | :x: | Go to https://github.com/guyskk/pybeautifier and follow the instructions. | | Remark | :white_check_mark: | Nothing! | | Rubocop | :x: | Go to https://github.com/bbatsov/rubocop and follow the instructions. | | Ruby Beautify | :x: | Go to https://github.com/erniebrodeur/ruby-beautify and follow the instructions. | diff --git a/src/beautifiers/nginx-beautify.coffee b/src/beautifiers/nginx-beautify.coffee index 088d7d8..2e41a4b 100644 --- a/src/beautifiers/nginx-beautify.coffee +++ b/src/beautifiers/nginx-beautify.coffee @@ -4,6 +4,7 @@ Beautifier = require('./beautifier') module.exports = class NginxBeautify extends Beautifier name: "Nginx Beautify" link: "https://github.com/denysvitali/nginxbeautify" + isPreInstalled: false options: { Nginx: { diff --git a/src/beautifiers/pybeautifier.coffee b/src/beautifiers/pybeautifier.coffee index 692a8fb..696428e 100644 --- a/src/beautifiers/pybeautifier.coffee +++ b/src/beautifiers/pybeautifier.coffee @@ -38,6 +38,7 @@ module.exports = class PythonBeautifier extends Beautifier name: "pybeautifier" link: "https://github.com/guyskk/pybeautifier" + isPreInstalled: false options: { Python: true From 6756b6747dedc10ca8d85ef04a85858196583649 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 15 Apr 2017 03:27:20 -0300 Subject: [PATCH 63/64] Prepare 0.29.19 release --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3a9d8e0..5ca514f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom-beautify", "main": "./src/beautify", - "version": "0.29.18", + "version": "0.29.19", "private": true, "description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more in Atom", "repository": { @@ -333,4 +333,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} \ No newline at end of file +} From c19a079040451c9704c7905fdaf5962b4f8a0e32 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 15 Apr 2017 03:42:12 -0300 Subject: [PATCH 64/64] Update docs --- docs/options.md | 84 ++++++++++++++++++------------------------------- package.json | 2 +- 2 files changed, 31 insertions(+), 55 deletions(-) diff --git a/docs/options.md b/docs/options.md index a74c3ce..5681bc0 100644 --- a/docs/options.md +++ b/docs/options.md @@ -9447,8 +9447,8 @@ Specify a configuration file which will override the default name of .perltidyrc | `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `cs_fixer_path` | :white_check_mark: | :x: | :x: | -| `rules` | :white_check_mark: | :x: | :x: | | `phpcbf_path` | :white_check_mark: | :x: | :x: | +| `rules` | :white_check_mark: | :x: | :x: | | `standard` | :white_check_mark: | :white_check_mark: | :x: | **Description**: @@ -9534,30 +9534,6 @@ Absolute path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) } ``` -##### [Rules](#rules) - -**Namespace**: `php` - -**Key**: `rules` - -**Type**: `string` - -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) - -**Description**: - -Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2 (Supported by PHP-CS-Fixer) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "php": { - "rules": "" - } -} -``` - ##### [PHPCBF Path](#phpcbf-path) **Namespace**: `php` @@ -9582,6 +9558,30 @@ Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) } ``` +##### [Rules](#rules) + +**Namespace**: `php` + +**Key**: `rules` + +**Type**: `string` + +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) + +**Description**: + +Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2 (Supported by PHP-CS-Fixer) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "php": { + "rules": "" + } +} +``` + ##### [PHPCBF Standard](#phpcbf-standard) **Namespace**: `php` @@ -16900,7 +16900,7 @@ undefined (Supported by Nginx Beautify) **Description**: -Path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) +Absolute path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -16912,11 +16912,11 @@ Path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) } ``` -##### [Fixers](#fixers) +##### [Rules](#rules) **Namespace**: `php` -**Key**: `fixers` +**Key**: `rules` **Type**: `string` @@ -16924,38 +16924,14 @@ Path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) **Description**: -Add fixer(s). i.e. linefeed,-short_tag,indentation (Supported by PHP-CS-Fixer) +Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2 (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** ```json { "php": { - "fixers": "" - } -} -``` - -##### [Level](#level) - -**Namespace**: `php` - -**Key**: `level` - -**Type**: `string` - -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) - -**Description**: - -By default, all PSR-2 fixers and some additional ones are run. (Supported by PHP-CS-Fixer) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "php": { - "level": "" + "rules": "" } } ``` diff --git a/package.json b/package.json index 5ca514f..1935066 100644 --- a/package.json +++ b/package.json @@ -333,4 +333,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file