From df6599f2c6ba5e4bb1dc91c9009a22d3376080a2 Mon Sep 17 00:00:00 2001 From: Focus Date: Wed, 2 Mar 2016 15:35:56 +0000 Subject: [PATCH 01/13] 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 02/13] 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 03/13] 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 04/13] 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 05/13] 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 06/13] 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 07/13] 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 08/13] 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' From e8b26e8d18d843d1676e63daa299d7d3e9773b52 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Tue, 22 Mar 2016 23:19:14 -0300 Subject: [PATCH 09/13] Fixes #868. Update expand-home-dir to v0.0.3 The package must have been unpublished for v0.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aeef5be..4735cc4 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "diff": "^2.1.0", "editorconfig": "^0.12.2", "event-kit": "^1.4.1", - "expand-home-dir": "0.0.2", + "expand-home-dir": "0.0.3", "extend": "^3.0.0", "gherkin": "2.12.2", "handlebars": "^4.0.2", From 96e8cde969168b8802be612d0a9d1e6154bc7da9 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Tue, 22 Mar 2016 23:20:18 -0300 Subject: [PATCH 10/13] Prepare 0.28.27 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4735cc4..a09ccbe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom-beautify", "main": "./src/beautify", - "version": "0.28.26", + "version": "0.28.27", "private": true, "description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, and SQL in Atom", "repository": { From 18ae07eaff17a16a7a6e52143b3decc7252254a4 Mon Sep 17 00:00:00 2001 From: Michael Hancock Date: Thu, 24 Mar 2016 00:34:55 +0000 Subject: [PATCH 11/13] Added opencl language support OpenCL language support is achieved here simply by attaching '.CL' extension to the 'C' language module. OpenCL is C based however beautify will not support beautification despite having C language support, due to the different file extension. --- .../opencl/expected/test.cl | 77 +++++++++++++++++++ .../opencl/original/test.cl | 77 +++++++++++++++++++ src/languages/c.coffee | 2 + 3 files changed, 156 insertions(+) create mode 100644 examples/nested-jsbeautifyrc/opencl/expected/test.cl create mode 100644 examples/nested-jsbeautifyrc/opencl/original/test.cl diff --git a/examples/nested-jsbeautifyrc/opencl/expected/test.cl b/examples/nested-jsbeautifyrc/opencl/expected/test.cl new file mode 100644 index 0000000..546cf9a --- /dev/null +++ b/examples/nested-jsbeautifyrc/opencl/expected/test.cl @@ -0,0 +1,77 @@ +__kernel void reduce_min(__global const int* A, __global int* B, __local int* scratch) { + //Get local variable data + int id = get_global_id(0); + int lid = get_local_id(0); + int N = get_local_size(0); + + //Store valus of global memory into local memory + scratch[lid] = A[id]; + + //Wait for copying to complete + barrier(CLK_LOCAL_MEM_FENCE); + + for (int i = 1; i < N; i *= 2) { + if (!(lid % (i * 2)) && ((lid + i) < N)){ + if (scratch[lid] > scratch[lid + i]) + scratch[lid] = scratch[lid+i]; + } + + barrier(CLK_LOCAL_MEM_FENCE); + } + + //Store cache in output array + if (!lid) + atomic_min(&B[0], scratch[lid]); +} + + +__kernel void reduce_max(__global const int* A, __global int* B, __local int* scratch) { + //Get local variable data + int id = get_global_id(0); + int lid = get_local_id(0); + int N = get_local_size(0); + + //Store valus of global memory into local memory + scratch[lid] = A[id]; + + //Wait for copying to complete + barrier(CLK_LOCAL_MEM_FENCE); + + for (int i = 1; i < N; i *= 2) { + if (!(lid % (i * 2)) && ((lid + i) < N)){ + if (scratch[lid] < scratch[lid + i]) + scratch[lid] = scratch[lid+i]; + } + + barrier(CLK_LOCAL_MEM_FENCE); + } + + //Store cache in output array + if (!lid) + atomic_max(&B[0], scratch[lid]); +} + +__kernel void reduce_avg(__global const int* A, __global int* B, __local int* scratch) { + //Get local variable data + int id = get_global_id(0); + int lid = get_local_id(0); + int N = get_local_size(0); + + //Store valus of global memory into local memory + scratch[lid] = A[id]; + + //Wait for copying to complete + barrier(CLK_LOCAL_MEM_FENCE); + + for (int i = 1; i < N; i *= 2) { + if (!(lid % (i * 2)) && ((lid + i) < N)) + { + scratch[lid] += scratch[lid+i]; + } + barrier(CLK_LOCAL_MEM_FENCE); + } + + //Store cache in output array + if (!lid) + atomic_add(&B[0],scratch[lid]); +} diff --git a/examples/nested-jsbeautifyrc/opencl/original/test.cl b/examples/nested-jsbeautifyrc/opencl/original/test.cl new file mode 100644 index 0000000..546cf9a --- /dev/null +++ b/examples/nested-jsbeautifyrc/opencl/original/test.cl @@ -0,0 +1,77 @@ +__kernel void reduce_min(__global const int* A, __global int* B, __local int* scratch) { + //Get local variable data + int id = get_global_id(0); + int lid = get_local_id(0); + int N = get_local_size(0); + + //Store valus of global memory into local memory + scratch[lid] = A[id]; + + //Wait for copying to complete + barrier(CLK_LOCAL_MEM_FENCE); + + for (int i = 1; i < N; i *= 2) { + if (!(lid % (i * 2)) && ((lid + i) < N)){ + if (scratch[lid] > scratch[lid + i]) + scratch[lid] = scratch[lid+i]; + } + + barrier(CLK_LOCAL_MEM_FENCE); + } + + //Store cache in output array + if (!lid) + atomic_min(&B[0], scratch[lid]); +} + + +__kernel void reduce_max(__global const int* A, __global int* B, __local int* scratch) { + //Get local variable data + int id = get_global_id(0); + int lid = get_local_id(0); + int N = get_local_size(0); + + //Store valus of global memory into local memory + scratch[lid] = A[id]; + + //Wait for copying to complete + barrier(CLK_LOCAL_MEM_FENCE); + + for (int i = 1; i < N; i *= 2) { + if (!(lid % (i * 2)) && ((lid + i) < N)){ + if (scratch[lid] < scratch[lid + i]) + scratch[lid] = scratch[lid+i]; + } + + barrier(CLK_LOCAL_MEM_FENCE); + } + + //Store cache in output array + if (!lid) + atomic_max(&B[0], scratch[lid]); +} + +__kernel void reduce_avg(__global const int* A, __global int* B, __local int* scratch) { + //Get local variable data + int id = get_global_id(0); + int lid = get_local_id(0); + int N = get_local_size(0); + + //Store valus of global memory into local memory + scratch[lid] = A[id]; + + //Wait for copying to complete + barrier(CLK_LOCAL_MEM_FENCE); + + for (int i = 1; i < N; i *= 2) { + if (!(lid % (i * 2)) && ((lid + i) < N)) + { + scratch[lid] += scratch[lid+i]; + } + barrier(CLK_LOCAL_MEM_FENCE); + } + + //Store cache in output array + if (!lid) + atomic_add(&B[0],scratch[lid]); +} diff --git a/src/languages/c.coffee b/src/languages/c.coffee index a2b3296..8afd969 100644 --- a/src/languages/c.coffee +++ b/src/languages/c.coffee @@ -8,6 +8,7 @@ module.exports = { ### grammars: [ "C" + "opencl" ] ### @@ -15,6 +16,7 @@ module.exports = { ### extensions: [ "c" + "cl" ] options: From 337d308296e34b774bdfff9c9542b6bccc8ac600 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Mon, 14 Mar 2016 16:27:41 -0600 Subject: [PATCH 12/13] Remove --style flag from yapf The --style flag accepts different types of input. From their documentation - "accepts one of the predefined styles (e.g., pep8 or google), a path to a configuration file that specifies the desired style, or a dictionary of key/value pairs." By not explicitly specifying the --style flag, yapf will look for the following, in that order 1. In the [style] section of a .style.yapf file in either the current directory or one of its parent directories. 2. In the [yapf] secionf of a setup.cfg file in either the current directory or one of its parent directories. 3. In the ~/.config/yapf/style file in your home directory. --- src/beautifiers/yapf.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/beautifiers/yapf.coffee b/src/beautifiers/yapf.coffee index b82bc8d..9e44982 100644 --- a/src/beautifiers/yapf.coffee +++ b/src/beautifiers/yapf.coffee @@ -16,7 +16,6 @@ module.exports = class Yapf extends Beautifier beautify: (text, language, options) -> @run("yapf", [ "-i" - ["--style=pep8"] tempFile = @tempFile("input", text) ], help: { link: "https://github.com/google/yapf" From 632e90a8046eb005466598aa2e1b3291bb607c41 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Mon, 14 Mar 2016 16:42:25 -0600 Subject: [PATCH 13/13] Updated CHANGELOG.md and package.json --- CHANGELOG.md | 1 + package.json | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60dc625..a4f84f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - 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. - 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. # v0.29.0 - Closes [#447](https://github.com/Glavin001/atom-beautify/issues/447). Improved Handlebars language support diff --git a/package.json b/package.json index 2edfbe3..ab09ae1 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,10 @@ { "name": "Bati Sengul", "url": "https://github.com/Focus" + }, + { + "name": "Dheepak Krishnamurthy", + "url": "https://github.com/kdheepak89" } ], "engines": {