diff --git a/CHANGELOG.md b/CHANGELOG.md index 3284e8d7b..de268ab50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Next - Fix [#1862](https://github.com/Glavin001/atom-beautify/issues/1862) Add support for ocp-indent as an executable +- Add "Reindent" option for sqlformat. See [#1926](https://github.com/Glavin001/atom-beautify/pull/1926). # v0.30.9 (2017-11-22) - Fix [#1949](https://github.com/Glavin001/atom-beautify/issues/1949): Fix beautify on save when text has not changed. diff --git a/docs/options.md b/docs/options.md index 0ae28407c..0f1c5c170 100644 --- a/docs/options.md +++ b/docs/options.md @@ -11726,6 +11726,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff) | `identifiers` | :white_check_mark: | | `indent_size` | :white_check_mark: | | `keywords` | :white_check_mark: | +| `reindent` | :white_check_mark: | **Description**: @@ -11868,6 +11869,32 @@ Change case of keywords (Supported by sqlformat) } ``` +##### [Reindent](#reindent) + +**Namespace**: `sql` + +**Key**: `reindent` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`sqlformat`](#sqlformat) + +**Description**: + +Change indentations of the statements. Uncheck this option to preserve indentation (Supported by sqlformat) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "sql": { + "reindent": true + } +} +``` + #### [SVG](#svg) **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) @@ -20617,6 +20644,32 @@ Indentation size/length (Supported by sqlformat) } ``` +##### [Reindent](#reindent) + +**Namespace**: `sql` + +**Key**: `reindent` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`sqlformat`](#sqlformat) + +**Description**: + +Change indentations of the statements. Uncheck this option to preserve indentation (Supported by sqlformat) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "sql": { + "reindent": true + } +} +``` + ##### [Keywords](#keywords) **Namespace**: `sql` diff --git a/package.json b/package.json index 8898cdd74..e7dea6a15 100644 --- a/package.json +++ b/package.json @@ -150,6 +150,10 @@ { "name": "Steven Zeck", "url": "https://github.com/szeck87" + }, + { + "name": "Faheel Ahmad", + "url": "https://github.com/faheel" } ], "engines": { diff --git a/src/beautifiers/sqlformat.coffee b/src/beautifiers/sqlformat.coffee index e6b00589d..02c53331b 100644 --- a/src/beautifiers/sqlformat.coffee +++ b/src/beautifiers/sqlformat.coffee @@ -17,7 +17,7 @@ module.exports = class Sqlformat extends Beautifier beautify: (text, language, options) -> @run("sqlformat", [ @tempFile("input", text) - "--reindent" + "--reindent=#{options.reindent}" if options.reindent? "--indent_width=#{options.indent_size}" if options.indent_size? "--keywords=#{options.keywords}" if (options.keywords? && options.keywords != 'unchanged') "--identifiers=#{options.identifiers}" if (options.identifiers? && options.identifiers != 'unchanged') diff --git a/src/languages/sql.coffee b/src/languages/sql.coffee index c8e8192ff..b6079c461 100644 --- a/src/languages/sql.coffee +++ b/src/languages/sql.coffee @@ -26,6 +26,10 @@ module.exports = { default: null minimum: 0 description: "Indentation size/length" + reindent: + type: 'boolean' + default: true + description: "Change indentations of the statements. Uncheck this option to preserve indentation" keywords: type: 'string' default: "upper" diff --git a/src/options.json b/src/options.json index 35bda1b67..c574c59dd 100644 --- a/src/options.json +++ b/src/options.json @@ -6914,6 +6914,20 @@ "namespace": "sql" } }, + "reindent": { + "type": "boolean", + "default": true, + "description": "Change indentations of the statements. Uncheck this option to preserve indentation (Supported by sqlformat)", + "title": "Reindent", + "beautifiers": [ + "sqlformat" + ], + "key": "reindent", + "language": { + "name": "SQL", + "namespace": "sql" + } + }, "keywords": { "type": "string", "default": "upper",