From df6599f2c6ba5e4bb1dc91c9009a22d3376080a2 Mon Sep 17 00:00:00 2001 From: Focus Date: Wed, 2 Mar 2016 15:35:56 +0000 Subject: [PATCH 1/8] Basic implementation for latex with latexindent.pl --- docs/options.md | 424 ++++++++++++++++++++++++++++++++--- src/beautifiers/index.coffee | 1 + src/languages/index.coffee | 1 + 3 files changed, 397 insertions(+), 29 deletions(-) diff --git a/docs/options.md b/docs/options.md index bb9a843..254d5bc 100644 --- a/docs/options.md +++ b/docs/options.md @@ -1848,6 +1848,343 @@ If a terminating comma should be inserted into arrays, object literals, and dest } ``` +#### [LaTeX - Indent size](#latex---indent-size) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `4` + +**Type**: `integer` + +**Description**: + +Indentation size/length (Not supported by any beautifiers) + +**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 "*LaTeX - Indent size*" and change it to your desired configuration. + +#### [LaTeX - Indent char](#latex---indent-char) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: ` ` + +**Type**: `string` + +**Description**: + +Indentation character (Not supported by any beautifiers) + +**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 "*LaTeX - Indent char*" and change it to your desired configuration. + +#### [LaTeX - Indent level](#latex---indent-level) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `integer` + +**Description**: + +Initial indentation level (Not supported by any beautifiers) + +**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 "*LaTeX - Indent level*" and change it to your desired configuration. + +#### [LaTeX - Indent with tabs](#latex---indent-with-tabs) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Not supported by any beautifiers) + +**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 "*LaTeX - Indent with tabs*" and change it to your desired configuration. + +#### [LaTeX - Preserve newlines](#latex---preserve-newlines) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `true` + +**Type**: `boolean` + +**Description**: + +Preserve line-breaks (Not supported by any beautifiers) + +**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 "*LaTeX - Preserve newlines*" and change it to your desired configuration. + +#### [LaTeX - Max preserve newlines](#latex---max-preserve-newlines) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `10` + +**Type**: `integer` + +**Description**: + +Number of line-breaks to be preserved in one chunk (Not supported by any beautifiers) + +**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 "*LaTeX - Max preserve newlines*" and change it to your desired configuration. + +#### [LaTeX - Space in paren](#latex---space-in-paren) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Add padding spaces within paren, ie. f( a, b ) (Not supported by any beautifiers) + +**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 "*LaTeX - Space in paren*" and change it to your desired configuration. + +#### [LaTeX - Jslint happy](#latex---jslint-happy) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Enable jslint-stricter mode (Not supported by any beautifiers) + +**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 "*LaTeX - Jslint happy*" and change it to your desired configuration. + +#### [LaTeX - Space after anon function](#latex---space-after-anon-function) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Add a space before an anonymous function's parens, ie. function () (Not supported by any beautifiers) + +**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 "*LaTeX - Space after anon function*" and change it to your desired configuration. + +#### [LaTeX - Brace style](#latex---brace-style) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `collapse` + +**Type**: `string` + +**Enum**: `collapse` `collapse-preserve-inline` `expand` `end-expand` `none` + +**Description**: + +[collapse|collapse-preserve-inline|expand|end-expand|none] (Not supported by any beautifiers) + +**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 "*LaTeX - Brace style*" and change it to your desired configuration. + +#### [LaTeX - Break chained methods](#latex---break-chained-methods) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Break chained method calls across subsequent lines (Not supported by any beautifiers) + +**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 "*LaTeX - Break chained methods*" and change it to your desired configuration. + +#### [LaTeX - Keep array indentation](#latex---keep-array-indentation) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Preserve array indentation (Not supported by any beautifiers) + +**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 "*LaTeX - Keep array indentation*" and change it to your desired configuration. + +#### [LaTeX - Keep function indentation](#latex---keep-function-indentation) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + + (Not supported by any beautifiers) + +**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 "*LaTeX - Keep function indentation*" and change it to your desired configuration. + +#### [LaTeX - Space before conditional](#latex---space-before-conditional) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `true` + +**Type**: `boolean` + +**Description**: + + (Not supported by any beautifiers) + +**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 "*LaTeX - Space before conditional*" and change it to your desired configuration. + +#### [LaTeX - Eval code](#latex---eval-code) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + + (Not supported by any beautifiers) + +**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 "*LaTeX - Eval code*" and change it to your desired configuration. + +#### [LaTeX - Unescape strings](#latex---unescape-strings) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Decode printable characters encoded in xNN notation (Not supported by any beautifiers) + +**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 "*LaTeX - Unescape strings*" and change it to your desired configuration. + +#### [LaTeX - Wrap line length](#latex---wrap-line-length) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `integer` + +**Description**: + +Wrap lines at next opportunity after N characters (Not supported by any beautifiers) + +**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 "*LaTeX - Wrap line length*" and change it to your desired configuration. + +#### [LaTeX - End with newline](#latex---end-with-newline) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +End output with newline (Not supported by any beautifiers) + +**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 "*LaTeX - End with newline*" and change it to your desired configuration. + +#### [LaTeX - End with comma](#latex---end-with-comma) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +If a terminating comma should be inserted into arrays, object literals, and destructured objects. (Not supported by any beautifiers) + +**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 "*LaTeX - End with comma*" and change it to your desired configuration. + #### [Markdown - Gfm](#markdown---gfm) **Namespace**: `markdown` @@ -2076,11 +2413,11 @@ By default, all PSR-2 fixers and some additional ones are run. (Supported by PHP **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) +Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -2944,7 +3281,7 @@ Disable D Beautification **Important**: This option is only configurable from within Atom Beautify's setting panel. -**Default**: `dfmt` +**Default**: `Uncrustify` **Type**: `string` @@ -3746,6 +4083,59 @@ Automatically beautify JSX files on save 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Language Config - JSX - Beautify On Save*" and change it to your desired configuration. +#### [Language Config - LaTeX - Disable Beautifying Language](#language-config---latex---disable-beautifying-language) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Disable LaTeX 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 "*Language Config - LaTeX - Disable Beautifying Language*" and change it to your desired configuration. + +#### [Language Config - LaTeX - Default Beautifier](#language-config---latex---default-beautifier) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `Latex Beautify` + +**Type**: `string` + +**Description**: + +Default Beautifier to be used for LaTeX + +**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 "*Language Config - LaTeX - Default Beautifier*" and change it to your desired configuration. + +#### [Language Config - LaTeX - Beautify On Save](#language-config---latex---beautify-on-save) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Automatically beautify LaTeX 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 "*Language Config - LaTeX - Beautify On Save*" and change it to your desired configuration. + #### [Language Config - LESS - Disable Beautifying Language](#language-config---less---disable-beautifying-language) **Important**: This option is only configurable from within Atom Beautify's setting panel. @@ -7303,11 +7693,11 @@ By default, all PSR-2 fixers and some additional ones are run. (Supported by PHP **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) +Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -7346,30 +7736,6 @@ Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS ru ### PHPCBF -#### [PHP - PHPCBF Path](#php---phpcbf-path) - -**Namespace**: `php` - -**Key**: `phpcbf_path` - -**Type**: `string` - -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) - -**Description**: - -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "php": { - "phpcbf_path": "" - } -} -``` - #### [PHP - PHPCBF Standard](#php---phpcbf-standard) **Namespace**: `php` diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 732e0a6..c72b73e 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -44,6 +44,7 @@ module.exports = class Beautifiers extends EventEmitter 'csscomb' 'gherkin' 'gofmt' + 'latex-beautify' 'fortran-beautifier' 'js-beautify' 'jscs' diff --git a/src/languages/index.coffee b/src/languages/index.coffee index 5a699dc..94e4982 100644 --- a/src/languages/index.coffee +++ b/src/languages/index.coffee @@ -36,6 +36,7 @@ module.exports = class Languages "javascript" "json" "jsx" + "latex" "less" "markdown" 'marko' From a4ff384dbfe2e998ea8abca1029c14d656240ba6 Mon Sep 17 00:00:00 2001 From: Focus Date: Wed, 2 Mar 2016 16:45:56 +0000 Subject: [PATCH 2/8] Implements #384 --- src/beautifiers/latex-beautify.coffee | 27 ++++++ src/languages/latex.coffee | 115 ++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 src/beautifiers/latex-beautify.coffee create mode 100644 src/languages/latex.coffee diff --git a/src/beautifiers/latex-beautify.coffee b/src/beautifiers/latex-beautify.coffee new file mode 100644 index 0000000..f019ee7 --- /dev/null +++ b/src/beautifiers/latex-beautify.coffee @@ -0,0 +1,27 @@ +"use strict" +Beautifier = require('./beautifier') +path = require('path') + +module.exports = class LatexBeautify extends Beautifier + name: "Latex Beautify" + + options: { + LaTeX: true + } + + beautify: (text, language, options) -> + @tempFile("indent", "", "log") + .then( (logFile)=> + logDir = path.dirname logFile + @tempTex = @tempFile("latex", text) + run = @run "latexindent", [ + "-o" + "-s" + "-c=" + logDir + @tempTex + @tempTex + ] + ) + .then( => + @readFile(@tempTex) + ) diff --git a/src/languages/latex.coffee b/src/languages/latex.coffee new file mode 100644 index 0000000..1e9fc4a --- /dev/null +++ b/src/languages/latex.coffee @@ -0,0 +1,115 @@ +# Get Atom defaults +scope = ['source.js'] +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: "LaTeX" + namespace: "latex" + + ### + Supported Grammars + ### + grammars: [ + "LaTeX" + ] + + ### + Supported extensions + ### + extensions: [ + "tex" + ] + + defaultBeautifier: "Latex Beautify" + + ### + + ### + options: + # JavaScript + indent_size: + type: 'integer' + default: defaultIndentSize + minimum: 0 + description: "Indentation size/length" + indent_char: + type: 'string' + default: defaultIndentChar + description: "Indentation character" + indent_level: + type: 'integer' + default: 0 + description: "Initial indentation level" + indent_with_tabs: + type: 'boolean' + default: defaultIndentWithTabs + description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`" + preserve_newlines: + type: 'boolean' + default: true + description: "Preserve line-breaks" + max_preserve_newlines: + type: 'integer' + default: 10 + description: "Number of line-breaks to be preserved in one chunk" + space_in_paren: + type: 'boolean' + default: false + description: "Add padding spaces within paren, ie. f( a, b )" + jslint_happy: + type: 'boolean' + default: false + description: "Enable jslint-stricter mode" + space_after_anon_function: + type: 'boolean' + default: false + description: "Add a space before an anonymous function's parens, ie. function ()" + brace_style: + type: 'string' + default: "collapse" + enum: ["collapse", "collapse-preserve-inline", "expand", "end-expand", "none"] + description: "[collapse|collapse-preserve-inline|expand|end-expand|none]" + break_chained_methods: + type: 'boolean' + default: false + description: "Break chained method calls across subsequent lines" + keep_array_indentation: + type: 'boolean' + default: false + description: "Preserve array indentation" + keep_function_indentation: + type: 'boolean' + default: false + description: "" + space_before_conditional: + type: 'boolean' + default: true + description: "" + eval_code: + type: 'boolean' + default: false + description: "" + unescape_strings: + type: 'boolean' + default: false + description: "Decode printable characters encoded in xNN notation" + wrap_line_length: + type: 'integer' + default: 0 + description: "Wrap lines at next opportunity after N characters" + end_with_newline: + type: 'boolean' + default: false + description: "End output with newline" + end_with_comma: + type: 'boolean' + default: false + description: "If a terminating comma should be inserted into \ + arrays, object literals, and destructured objects." + +} From ff377a7a3a4752974be93ac0d172798b7e4a074f Mon Sep 17 00:00:00 2001 From: Focus Date: Thu, 3 Mar 2016 21:06:05 +0000 Subject: [PATCH 3/8] Implemented options and a clean layout --- src/beautifiers/latex-beautify.coffee | 69 +++++++++++++++++++---- src/languages/latex.coffee | 81 +++++---------------------- 2 files changed, 71 insertions(+), 79 deletions(-) diff --git a/src/beautifiers/latex-beautify.coffee b/src/beautifiers/latex-beautify.coffee index f019ee7..f527431 100644 --- a/src/beautifiers/latex-beautify.coffee +++ b/src/beautifiers/latex-beautify.coffee @@ -1,6 +1,9 @@ "use strict" Beautifier = require('./beautifier') path = require('path') +fs = require("fs") +temp = require("temp").track() + module.exports = class LatexBeautify extends Beautifier name: "Latex Beautify" @@ -9,19 +12,61 @@ module.exports = class LatexBeautify extends Beautifier LaTeX: true } + # There are too many options with latexmk, I have tried to slim this down to the most useful ones. + # This method creates a configuration file for latexindent. + buildConfigFile: (options) -> + indentChar = options.indent_char + if options.indent_with_tabs + indentChar = "\t" + # +true = 1 and +false = 0 + config = """ + defaultIndent: \"#{indentChar}\" + alwaysLookforSplitBraces: #{+options.always_look_for_split_braces} + alwaysLookforSplitBrackets: #{+options.always_look_for_split_brackets} + indentPreamble: #{+options.indent_preamble} + removeTrailingWhitespace: #{+options.remove_trailing_whitespace} + lookForAlignDelims:\n + """ + for delim in options.align_columns_in_environments + config += "\t#{delim}: 1\n" + return config + + # Latexindent accepts configuration _files_ only. + # This file has to be named localSettings.yaml and be in the same folder as the tex file. + # It also insists on creating a log file somewhere. + # So we set up a directory with all the files in place. + setUpDir: (dirPath, text, config) -> + @texFile = path.join(dirPath, "latex.tex") + fs.writeFile @texFile, text, (err) -> + return reject(err) if err + @configFile = path.join(dirPath, "localSettings.yaml") + fs.writeFile @configFile, config, (err) -> + return reject(err) if err + @logFile = path.join(dirPath, "indent.log") + fs.writeFile @logFile, "", (err) -> + return reject(err) if err + + #Beautifier does not currently have a method for creating directories, so we call temp directly. beautify: (text, language, options) -> - @tempFile("indent", "", "log") - .then( (logFile)=> - logDir = path.dirname logFile - @tempTex = @tempFile("latex", text) + new @Promise((resolve, reject) -> + temp.mkdir("latex", (err, dirPath) -> + return reject(err) if err + resolve(dirPath) + ) + ) + .then((dirPath)=> + @setUpDir(dirPath, text, @buildConfigFile(options)) run = @run "latexindent", [ - "-o" - "-s" - "-c=" + logDir - @tempTex - @tempTex - ] + "-o" #Output to the same location as file, -w creates a backup file, whereas this does not + "-s" #Silent mode + "-l" #Tell latexindent we have a local configuration file + "-c=" + dirPath #Tell latexindent to place the log file in this directory + @texFile + @texFile + ], help: { + link: "https://github.com/cmhughes/latexindent.pl" + } ) .then( => - @readFile(@tempTex) - ) + @readFile(@texFile) + ) diff --git a/src/languages/latex.coffee b/src/languages/latex.coffee index 1e9fc4a..f7de84b 100644 --- a/src/languages/latex.coffee +++ b/src/languages/latex.coffee @@ -31,85 +31,32 @@ module.exports = { ### options: - # JavaScript - indent_size: - type: 'integer' - default: defaultIndentSize - minimum: 0 - description: "Indentation size/length" indent_char: type: 'string' default: defaultIndentChar description: "Indentation character" - indent_level: - type: 'integer' - default: 0 - description: "Initial indentation level" indent_with_tabs: type: 'boolean' default: defaultIndentWithTabs description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`" - preserve_newlines: + indent_preamble: + type: 'boolean' + default: false + description: "Indent the preable" + always_look_for_split_braces: type: 'boolean' default: true - description: "Preserve line-breaks" - max_preserve_newlines: - type: 'integer' - default: 10 - description: "Number of line-breaks to be preserved in one chunk" - space_in_paren: + description: "If `latexindent` should look for commands that split braces across lines" + always_look_for_split_brackets: type: 'boolean' default: false - description: "Add padding spaces within paren, ie. f( a, b )" - jslint_happy: + description: "If `latexindent` should look for commands that split brackets across lines" + remove_trailing_whitespace: type: 'boolean' default: false - description: "Enable jslint-stricter mode" - space_after_anon_function: - type: 'boolean' - default: false - description: "Add a space before an anonymous function's parens, ie. function ()" - brace_style: - type: 'string' - default: "collapse" - enum: ["collapse", "collapse-preserve-inline", "expand", "end-expand", "none"] - description: "[collapse|collapse-preserve-inline|expand|end-expand|none]" - break_chained_methods: - type: 'boolean' - default: false - description: "Break chained method calls across subsequent lines" - keep_array_indentation: - type: 'boolean' - default: false - description: "Preserve array indentation" - keep_function_indentation: - type: 'boolean' - default: false - description: "" - space_before_conditional: - type: 'boolean' - default: true - description: "" - eval_code: - type: 'boolean' - default: false - description: "" - unescape_strings: - type: 'boolean' - default: false - description: "Decode printable characters encoded in xNN notation" - wrap_line_length: - type: 'integer' - default: 0 - description: "Wrap lines at next opportunity after N characters" - end_with_newline: - type: 'boolean' - default: false - description: "End output with newline" - end_with_comma: - type: 'boolean' - default: false - description: "If a terminating comma should be inserted into \ - arrays, object literals, and destructured objects." - + description: "Remove trailing whitespace" + align_columns_in_environments: + type: 'array' + default:["tabular", "matrix", "bmatrix", "pmatrix"] + decription: "Aligns columns by the alignment tabs for environments specified" } From 08fa230f71082a9927300f00128a57ab9b2f6be7 Mon Sep 17 00:00:00 2001 From: Focus Date: Thu, 3 Mar 2016 22:16:58 +0000 Subject: [PATCH 4/8] Tests --- examples/nested-jsbeautifyrc/latex/expected/test.tex | 5 +++++ examples/nested-jsbeautifyrc/latex/original/test.tex | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 examples/nested-jsbeautifyrc/latex/expected/test.tex create mode 100644 examples/nested-jsbeautifyrc/latex/original/test.tex diff --git a/examples/nested-jsbeautifyrc/latex/expected/test.tex b/examples/nested-jsbeautifyrc/latex/expected/test.tex new file mode 100644 index 0000000..f94ff9f --- /dev/null +++ b/examples/nested-jsbeautifyrc/latex/expected/test.tex @@ -0,0 +1,5 @@ +This is a sample. +\[ + \int_0^1f(x)\, dx +\] +The above should be indented. diff --git a/examples/nested-jsbeautifyrc/latex/original/test.tex b/examples/nested-jsbeautifyrc/latex/original/test.tex new file mode 100644 index 0000000..3252c8c --- /dev/null +++ b/examples/nested-jsbeautifyrc/latex/original/test.tex @@ -0,0 +1,5 @@ +This is a sample. +\[ +\int_0^1f(x)\, dx +\] +The above should be indented. From 183cbafb3d28f40fe33b6074e6cd54f9c9d082bd Mon Sep 17 00:00:00 2001 From: Focus Date: Thu, 3 Mar 2016 22:24:48 +0000 Subject: [PATCH 5/8] Changelog and package.json update --- CHANGELOG.md | 1 + package.json | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bebce81..60dc625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ # v0.29.0 - Closes [#447](https://github.com/Glavin001/atom-beautify/issues/447). Improved Handlebars language support +- Closes [#384](https://github.com/Glavin001/atom-beautify/issues/384). Add [latexindent.pl](https://github.com/cmhughes/latexindent.pl) beautifier for LaTeX language # v0.26.0 (2015-05-03) - Closes [#176](https://github.com/Glavin001/atom-beautify/issues/176). Add [gofmt](http://golang.org/cmd/gofmt/) beautifier for Go language diff --git a/package.json b/package.json index f095e62..6703ae4 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,10 @@ { "name": "Luis Arias", "url": "https://github.com/kaaloo" + }, + { + "name": "Bati Sengul", + "url": "https://github.com/Focus" } ], "engines": { From 547a8b11a73a94f2f74ef9e449dce26dcd0a6be5 Mon Sep 17 00:00:00 2001 From: Focus Date: Thu, 3 Mar 2016 22:32:24 +0000 Subject: [PATCH 6/8] Rollback on options.md --- docs/options.md | 424 ++++-------------------------------------------- 1 file changed, 29 insertions(+), 395 deletions(-) diff --git a/docs/options.md b/docs/options.md index 254d5bc..bb9a843 100644 --- a/docs/options.md +++ b/docs/options.md @@ -1848,343 +1848,6 @@ If a terminating comma should be inserted into arrays, object literals, and dest } ``` -#### [LaTeX - Indent size](#latex---indent-size) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Default**: `4` - -**Type**: `integer` - -**Description**: - -Indentation size/length (Not supported by any beautifiers) - -**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 "*LaTeX - Indent size*" and change it to your desired configuration. - -#### [LaTeX - Indent char](#latex---indent-char) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Default**: ` ` - -**Type**: `string` - -**Description**: - -Indentation character (Not supported by any beautifiers) - -**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 "*LaTeX - Indent char*" and change it to your desired configuration. - -#### [LaTeX - Indent level](#latex---indent-level) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `integer` - -**Description**: - -Initial indentation level (Not supported by any beautifiers) - -**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 "*LaTeX - Indent level*" and change it to your desired configuration. - -#### [LaTeX - Indent with tabs](#latex---indent-with-tabs) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Not supported by any beautifiers) - -**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 "*LaTeX - Indent with tabs*" and change it to your desired configuration. - -#### [LaTeX - Preserve newlines](#latex---preserve-newlines) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Default**: `true` - -**Type**: `boolean` - -**Description**: - -Preserve line-breaks (Not supported by any beautifiers) - -**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 "*LaTeX - Preserve newlines*" and change it to your desired configuration. - -#### [LaTeX - Max preserve newlines](#latex---max-preserve-newlines) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Default**: `10` - -**Type**: `integer` - -**Description**: - -Number of line-breaks to be preserved in one chunk (Not supported by any beautifiers) - -**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 "*LaTeX - Max preserve newlines*" and change it to your desired configuration. - -#### [LaTeX - Space in paren](#latex---space-in-paren) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Add padding spaces within paren, ie. f( a, b ) (Not supported by any beautifiers) - -**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 "*LaTeX - Space in paren*" and change it to your desired configuration. - -#### [LaTeX - Jslint happy](#latex---jslint-happy) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Enable jslint-stricter mode (Not supported by any beautifiers) - -**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 "*LaTeX - Jslint happy*" and change it to your desired configuration. - -#### [LaTeX - Space after anon function](#latex---space-after-anon-function) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Add a space before an anonymous function's parens, ie. function () (Not supported by any beautifiers) - -**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 "*LaTeX - Space after anon function*" and change it to your desired configuration. - -#### [LaTeX - Brace style](#latex---brace-style) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Default**: `collapse` - -**Type**: `string` - -**Enum**: `collapse` `collapse-preserve-inline` `expand` `end-expand` `none` - -**Description**: - -[collapse|collapse-preserve-inline|expand|end-expand|none] (Not supported by any beautifiers) - -**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 "*LaTeX - Brace style*" and change it to your desired configuration. - -#### [LaTeX - Break chained methods](#latex---break-chained-methods) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Break chained method calls across subsequent lines (Not supported by any beautifiers) - -**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 "*LaTeX - Break chained methods*" and change it to your desired configuration. - -#### [LaTeX - Keep array indentation](#latex---keep-array-indentation) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Preserve array indentation (Not supported by any beautifiers) - -**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 "*LaTeX - Keep array indentation*" and change it to your desired configuration. - -#### [LaTeX - Keep function indentation](#latex---keep-function-indentation) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - - (Not supported by any beautifiers) - -**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 "*LaTeX - Keep function indentation*" and change it to your desired configuration. - -#### [LaTeX - Space before conditional](#latex---space-before-conditional) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Default**: `true` - -**Type**: `boolean` - -**Description**: - - (Not supported by any beautifiers) - -**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 "*LaTeX - Space before conditional*" and change it to your desired configuration. - -#### [LaTeX - Eval code](#latex---eval-code) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - - (Not supported by any beautifiers) - -**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 "*LaTeX - Eval code*" and change it to your desired configuration. - -#### [LaTeX - Unescape strings](#latex---unescape-strings) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Decode printable characters encoded in xNN notation (Not supported by any beautifiers) - -**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 "*LaTeX - Unescape strings*" and change it to your desired configuration. - -#### [LaTeX - Wrap line length](#latex---wrap-line-length) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `integer` - -**Description**: - -Wrap lines at next opportunity after N characters (Not supported by any beautifiers) - -**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 "*LaTeX - Wrap line length*" and change it to your desired configuration. - -#### [LaTeX - End with newline](#latex---end-with-newline) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -End output with newline (Not supported by any beautifiers) - -**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 "*LaTeX - End with newline*" and change it to your desired configuration. - -#### [LaTeX - End with comma](#latex---end-with-comma) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -If a terminating comma should be inserted into arrays, object literals, and destructured objects. (Not supported by any beautifiers) - -**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 "*LaTeX - End with comma*" and change it to your desired configuration. - #### [Markdown - Gfm](#markdown---gfm) **Namespace**: `markdown` @@ -2413,11 +2076,11 @@ By default, all PSR-2 fixers and some additional ones are run. (Supported by PHP **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) +Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -3281,7 +2944,7 @@ Disable D Beautification **Important**: This option is only configurable from within Atom Beautify's setting panel. -**Default**: `Uncrustify` +**Default**: `dfmt` **Type**: `string` @@ -4083,59 +3746,6 @@ Automatically beautify JSX files on save 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Language Config - JSX - Beautify On Save*" and change it to your desired configuration. -#### [Language Config - LaTeX - Disable Beautifying Language](#language-config---latex---disable-beautifying-language) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Disable LaTeX 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 "*Language Config - LaTeX - Disable Beautifying Language*" and change it to your desired configuration. - -#### [Language Config - LaTeX - Default Beautifier](#language-config---latex---default-beautifier) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Default**: `Latex Beautify` - -**Type**: `string` - -**Description**: - -Default Beautifier to be used for LaTeX - -**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 "*Language Config - LaTeX - Default Beautifier*" and change it to your desired configuration. - -#### [Language Config - LaTeX - Beautify On Save](#language-config---latex---beautify-on-save) - -**Important**: This option is only configurable from within Atom Beautify's setting panel. - -**Type**: `boolean` - -**Description**: - -Automatically beautify LaTeX 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 "*Language Config - LaTeX - Beautify On Save*" and change it to your desired configuration. - #### [Language Config - LESS - Disable Beautifying Language](#language-config---less---disable-beautifying-language) **Important**: This option is only configurable from within Atom Beautify's setting panel. @@ -7693,11 +7303,11 @@ By default, all PSR-2 fixers and some additional ones are run. (Supported by PHP **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) +Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -7736,6 +7346,30 @@ Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS ru ### PHPCBF +#### [PHP - PHPCBF Path](#php---phpcbf-path) + +**Namespace**: `php` + +**Key**: `phpcbf_path` + +**Type**: `string` + +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) + +**Description**: + +Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "php": { + "phpcbf_path": "" + } +} +``` + #### [PHP - PHPCBF Standard](#php---phpcbf-standard) **Namespace**: `php` From 3a40d562793f375c2e4352ca41e733ef19e868df Mon Sep 17 00:00:00 2001 From: Focus Date: Thu, 3 Mar 2016 23:26:20 +0000 Subject: [PATCH 7/8] Documentation changes --- docs/options.md | 450 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 421 insertions(+), 29 deletions(-) diff --git a/docs/options.md b/docs/options.md index bb9a843..76c6304 100644 --- a/docs/options.md +++ b/docs/options.md @@ -1848,6 +1848,185 @@ If a terminating comma should be inserted into arrays, object literals, and dest } ``` +#### [LaTeX - Indent char](#latex---indent-char) + +**Namespace**: `latex` + +**Key**: `indent_char` + +**Default**: ` ` + +**Type**: `string` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +Indentation character (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "indent_char": " " + } +} +``` + +#### [LaTeX - Indent with tabs](#latex---indent-with-tabs) + +**Namespace**: `latex` + +**Key**: `indent_with_tabs` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "indent_with_tabs": false + } +} +``` + +#### [LaTeX - Indent preamble](#latex---indent-preamble) + +**Namespace**: `latex` + +**Key**: `indent_preamble` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +Indent the preable (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "indent_preamble": false + } +} +``` + +#### [LaTeX - Always look for split braces](#latex---always-look-for-split-braces) + +**Namespace**: `latex` + +**Key**: `always_look_for_split_braces` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +If `latexindent` should look for commands that split braces across lines (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "always_look_for_split_braces": true + } +} +``` + +#### [LaTeX - Always look for split brackets](#latex---always-look-for-split-brackets) + +**Namespace**: `latex` + +**Key**: `always_look_for_split_brackets` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +If `latexindent` should look for commands that split brackets across lines (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "always_look_for_split_brackets": false + } +} +``` + +#### [LaTeX - Remove trailing whitespace](#latex---remove-trailing-whitespace) + +**Namespace**: `latex` + +**Key**: `remove_trailing_whitespace` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +Remove trailing whitespace (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "remove_trailing_whitespace": false + } +} +``` + +#### [LaTeX - Align columns in environments](#latex---align-columns-in-environments) + +**Namespace**: `latex` + +**Key**: `align_columns_in_environments` + +**Default**: `tabular,matrix,bmatrix,pmatrix` + +**Type**: `array` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +undefined (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "align_columns_in_environments": [ + "tabular", + "matrix", + "bmatrix", + "pmatrix" + ] + } +} +``` + #### [Markdown - Gfm](#markdown---gfm) **Namespace**: `markdown` @@ -2076,11 +2255,11 @@ By default, all PSR-2 fixers and some additional ones are run. (Supported by PHP **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) +Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -2944,7 +3123,7 @@ Disable D Beautification **Important**: This option is only configurable from within Atom Beautify's setting panel. -**Default**: `dfmt` +**Default**: `Uncrustify` **Type**: `string` @@ -3746,6 +3925,61 @@ Automatically beautify JSX files on save 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Language Config - JSX - Beautify On Save*" and change it to your desired configuration. +#### [Language Config - LaTeX - Disable Beautifying Language](#language-config---latex---disable-beautifying-language) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Disable LaTeX 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 "*Language Config - LaTeX - Disable Beautifying Language*" and change it to your desired configuration. + +#### [Language Config - LaTeX - Default Beautifier](#language-config---latex---default-beautifier) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `Latex Beautify` + +**Type**: `string` + +**Enum**: `Latex Beautify` + +**Description**: + +Default Beautifier to be used for LaTeX + +**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 "*Language Config - LaTeX - Default Beautifier*" and change it to your desired configuration. + +#### [Language Config - LaTeX - Beautify On Save](#language-config---latex---beautify-on-save) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Automatically beautify LaTeX 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 "*Language Config - LaTeX - Beautify On Save*" and change it to your desired configuration. + #### [Language Config - LESS - Disable Beautifying Language](#language-config---less---disable-beautifying-language) **Important**: This option is only configurable from within Atom Beautify's setting panel. @@ -7115,6 +7349,188 @@ Path to the emacs script (Supported by Fortran Beautifier) ``` +### Latex Beautify + +#### [LaTeX - Indent char](#latex---indent-char) + +**Namespace**: `latex` + +**Key**: `indent_char` + +**Default**: ` ` + +**Type**: `string` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +Indentation character (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "indent_char": " " + } +} +``` + +#### [LaTeX - Indent with tabs](#latex---indent-with-tabs) + +**Namespace**: `latex` + +**Key**: `indent_with_tabs` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "indent_with_tabs": false + } +} +``` + +#### [LaTeX - Indent preamble](#latex---indent-preamble) + +**Namespace**: `latex` + +**Key**: `indent_preamble` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +Indent the preable (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "indent_preamble": false + } +} +``` + +#### [LaTeX - Always look for split braces](#latex---always-look-for-split-braces) + +**Namespace**: `latex` + +**Key**: `always_look_for_split_braces` + +**Default**: `true` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +If `latexindent` should look for commands that split braces across lines (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "always_look_for_split_braces": true + } +} +``` + +#### [LaTeX - Always look for split brackets](#latex---always-look-for-split-brackets) + +**Namespace**: `latex` + +**Key**: `always_look_for_split_brackets` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +If `latexindent` should look for commands that split brackets across lines (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "always_look_for_split_brackets": false + } +} +``` + +#### [LaTeX - Remove trailing whitespace](#latex---remove-trailing-whitespace) + +**Namespace**: `latex` + +**Key**: `remove_trailing_whitespace` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +Remove trailing whitespace (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "remove_trailing_whitespace": false + } +} +``` + +#### [LaTeX - Align columns in environments](#latex---align-columns-in-environments) + +**Namespace**: `latex` + +**Key**: `align_columns_in_environments` + +**Default**: `tabular,matrix,bmatrix,pmatrix` + +**Type**: `array` + +**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify) + +**Description**: + +undefined (Supported by Latex Beautify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "latex": { + "align_columns_in_environments": [ + "tabular", + "matrix", + "bmatrix", + "pmatrix" + ] + } +} +``` + + ### Remark #### [Markdown - Gfm](#markdown---gfm) @@ -7303,11 +7719,11 @@ By default, all PSR-2 fixers and some additional ones are run. (Supported by PHP **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) +Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -7346,30 +7762,6 @@ Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS ru ### PHPCBF -#### [PHP - PHPCBF Path](#php---phpcbf-path) - -**Namespace**: `php` - -**Key**: `phpcbf_path` - -**Type**: `string` - -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) - -**Description**: - -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer, PHPCBF) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "php": { - "phpcbf_path": "" - } -} -``` - #### [PHP - PHPCBF Standard](#php---phpcbf-standard) **Namespace**: `php` From 75ca70bc1f2a9a8b8d9883a17278cffe4f25fb58 Mon Sep 17 00:00:00 2001 From: Focus Date: Sat, 5 Mar 2016 10:07:23 +0000 Subject: [PATCH 8/8] Tabs changed to literal and default to using tabs --- src/beautifiers/latex-beautify.coffee | 2 +- src/languages/latex.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/beautifiers/latex-beautify.coffee b/src/beautifiers/latex-beautify.coffee index f527431..9c4fd95 100644 --- a/src/beautifiers/latex-beautify.coffee +++ b/src/beautifiers/latex-beautify.coffee @@ -17,7 +17,7 @@ module.exports = class LatexBeautify extends Beautifier buildConfigFile: (options) -> indentChar = options.indent_char if options.indent_with_tabs - indentChar = "\t" + indentChar = "\\t" # +true = 1 and +false = 0 config = """ defaultIndent: \"#{indentChar}\" diff --git a/src/languages/latex.coffee b/src/languages/latex.coffee index f7de84b..112f090 100644 --- a/src/languages/latex.coffee +++ b/src/languages/latex.coffee @@ -37,7 +37,7 @@ module.exports = { description: "Indentation character" indent_with_tabs: type: 'boolean' - default: defaultIndentWithTabs + default: true description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`" indent_preamble: type: 'boolean'