Merge branch 'JackTreble-fix-beautify-file-option-for-lua-files'

This commit is contained in:
Glavin Wiechert 2018-03-01 23:30:26 -04:00
commit 33d98ed587
6 changed files with 159 additions and 3 deletions

View File

@ -1,4 +1,5 @@
# Next
- Fix Beauify File option for .lua files
- Switch to Remark as a default markdown beautifier due to a more active state of its community compared to Tidy Markdown ([#2004](https://github.com/Glavin001/atom-beautify/pull/2004)).
This is a __breaking change__ for Tidy Markdown users:
- list indentation is now four characters per level (three spaces after `-` for unordered lists and two spaces after `N.` in ordered lists)

View File

@ -7718,6 +7718,8 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
| `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: |
| `end_of_line` | :white_check_mark: |
| `indent_char` | :white_check_mark: |
| `indent_size` | :white_check_mark: |
**Description**:
@ -7806,6 +7808,58 @@ Override EOL from line-ending-selector (Supported by Lua beautifier)
}
```
##### [Indent char](#indent-char)
**Namespace**: `lua`
**Key**: `indent_char`
**Default**: ` `
**Type**: `string`
**Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier)
**Description**:
Indentation character (Supported by Lua beautifier)
**Example `.jsbeautifyrc` Configuration**
```json
{
"lua": {
"indent_char": " "
}
}
```
##### [Indent size](#indent-size)
**Namespace**: `lua`
**Key**: `indent_size`
**Default**: `4`
**Type**: `integer`
**Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier)
**Description**:
Indentation size/length (Supported by Lua beautifier)
**Example `.jsbeautifyrc` Configuration**
```json
{
"lua": {
"indent_size": 4
}
}
```
#### [Markdown](#markdown)
**Supported Beautifiers**: [`Prettier`](#prettier) [`Remark`](#remark) [`Tidy Markdown`](#tidy-markdown)
@ -16460,6 +16514,58 @@ Aligns columns by the alignment tabs for environments specified (Supported by La
### Lua beautifier
##### [Indent size](#indent-size)
**Namespace**: `lua`
**Key**: `indent_size`
**Default**: `4`
**Type**: `integer`
**Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier)
**Description**:
Indentation size/length (Supported by Lua beautifier)
**Example `.jsbeautifyrc` Configuration**
```json
{
"lua": {
"indent_size": 4
}
}
```
##### [Indent char](#indent-char)
**Namespace**: `lua`
**Key**: `indent_char`
**Default**: ` `
**Type**: `string`
**Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier)
**Description**:
Indentation character (Supported by Lua beautifier)
**Example `.jsbeautifyrc` Configuration**
```json
{
"lua": {
"indent_char": " "
}
}
```
##### [End of line](#end-of-line)
**Namespace**: `lua`

View File

@ -163,6 +163,10 @@
{
"name": "Andrew Andrianov",
"url": "https://github.com/nekromant"
},
{
"name": "Jack Treble",
"url": "https://github.com/JackTreble"
}
],
"engines": {

View File

@ -11,13 +11,20 @@ module.exports = class Lua extends Beautifier
link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.coffee"
options: {
Lua: true
Lua: {
indent_size: true
indent_char: true
end_of_line: true
}
}
beautify: (text, language, options) ->
options.eol = @getDefaultLineEnding('\r\n','\n',options.end_of_line)
options.eol = @getDefaultLineEnding('\r\n','\n', options.end_of_line)
indentChar = options.indent_char or " "
indentSize = options.indent_size
indent = indentChar.repeat(indentSize)
new @Promise (resolve, reject) ->
try
resolve format text, options.indent_char.repeat(options.indent_size), @warn, options
resolve(format(text, indent, @warn, options));
catch error
reject error

View File

@ -21,6 +21,15 @@ module.exports = {
defaultBeautifier: "Lua beautifier"
options:
indent_size:
type: 'integer'
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: null
description: "Indentation character"
end_of_line:
type: 'string'
default: "System Default"

View File

@ -4457,6 +4457,35 @@
"ttslua"
],
"properties": {
"indent_size": {
"type": "integer",
"default": null,
"minimum": 0,
"description": "Indentation size/length (Supported by Lua beautifier)",
"title": "Indent size",
"beautifiers": [
"Lua beautifier"
],
"key": "indent_size",
"language": {
"name": "Lua",
"namespace": "lua"
}
},
"indent_char": {
"type": "string",
"default": null,
"description": "Indentation character (Supported by Lua beautifier)",
"title": "Indent char",
"beautifiers": [
"Lua beautifier"
],
"key": "indent_char",
"language": {
"name": "Lua",
"namespace": "lua"
}
},
"end_of_line": {
"type": "string",
"default": "System Default",