Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option for sqlformat to re-indent #1926

Merged
merged 6 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
53 changes: 53 additions & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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`
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@
{
"name": "Steven Zeck",
"url": "https://github.com/szeck87"
},
{
"name": "Faheel Ahmad",
"url": "https://github.com/faheel"
}
],
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/beautifiers/sqlformat.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 4 additions & 0 deletions src/languages/sql.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down