Merge branch 'master' into master
This commit is contained in:
commit
b269279010
|
@ -0,0 +1,12 @@
|
||||||
|
engines:
|
||||||
|
coffeelint:
|
||||||
|
enabled: true
|
||||||
|
eslint:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
ratings:
|
||||||
|
paths:
|
||||||
|
- "**.coffee"
|
||||||
|
- "**.js"
|
||||||
|
|
||||||
|
exclude_paths:
|
|
@ -6,6 +6,7 @@
|
||||||
- Add [elm-format](https://github.com/avh4/elm-format) beautifier for the Elm language.
|
- Add [elm-format](https://github.com/avh4/elm-format) beautifier for the Elm language.
|
||||||
- Add [clang-format](http://clang.llvm.org/docs/ClangFormat.html) beautifier for C/C++/Obj-C languages.
|
- 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.
|
- Add [yapf](http://github.com/google/yapf) beautifier for Python.
|
||||||
|
- Add [ESLint](https://github.com/eslint/eslint) beautifier for Javascript
|
||||||
- Closes [#776] (https://github.com/Glavin001/atom-beautify/issues/776) Add support for `collapse-preserve-inline` brace_style for javascript.
|
- 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.
|
- Closes [#786](https://github.com/Glavin001/atom-beautify/issues/786) YAPF configuration files are ignored.
|
||||||
- Fix phpcbf hanging issue by closing stdin. See [#893](https://github.com/Glavin001/atom-beautify/issues/893)
|
- Fix phpcbf hanging issue by closing stdin. See [#893](https://github.com/Glavin001/atom-beautify/issues/893)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
|
- [Beautifiers](#beautifiers)
|
||||||
- [Language Support](#language-support)
|
- [Language Support](#language-support)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Selection of Code](#selection-of-code)
|
- [Selection of Code](#selection-of-code)
|
||||||
|
@ -54,6 +55,11 @@ Thank you.
|
||||||
Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core!
|
Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core!
|
||||||
See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174).
|
See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174).
|
||||||
|
|
||||||
|
## Beautifiers
|
||||||
|
|
||||||
|
Some of the supported beautifiers are developed for Node.js and are automatically installed when Atom-Beautify is installed. However, other beautifiers are command-line interface (CLI) applications and require you to manually install them.
|
||||||
|
|
||||||
|
{{beautifiers-info beautifiers}}
|
||||||
|
|
||||||
## Language Support
|
## Language Support
|
||||||
|
|
||||||
|
|
57
README.md
57
README.md
|
@ -20,6 +20,7 @@
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
|
- [Beautifiers](#beautifiers)
|
||||||
- [Language Support](#language-support)
|
- [Language Support](#language-support)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Selection of Code](#selection-of-code)
|
- [Selection of Code](#selection-of-code)
|
||||||
|
@ -54,6 +55,54 @@ Thank you.
|
||||||
Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core!
|
Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core!
|
||||||
See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174).
|
See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174).
|
||||||
|
|
||||||
|
## Beautifiers
|
||||||
|
|
||||||
|
Some of the supported beautifiers are developed for Node.js and are automatically installed when Atom-Beautify is installed. However, other beautifiers are command-line interface (CLI) applications and require you to manually install them.
|
||||||
|
|
||||||
|
| Beautifier | Is Pre-Installed? | Installation Instructions |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| autopep8 | :x: | Go to https://github.com/hhatto/autopep8 and follow the instructions. |
|
||||||
|
| beautysh | :x: | Go to https://github.com/bemeurer/beautysh and follow the instructions. |
|
||||||
|
| clang-format | :x: | Go to https://clang.llvm.org/docs/ClangFormat.html and follow the instructions. |
|
||||||
|
| cljfmt | :white_check_mark: | Nothing! |
|
||||||
|
| Coffee Formatter | :white_check_mark: | Nothing! |
|
||||||
|
| coffee-fmt | :white_check_mark: | Nothing! |
|
||||||
|
| Crystal | :x: | Go to http://crystal-lang.org and follow the instructions. |
|
||||||
|
| CSScomb | :white_check_mark: | Nothing! |
|
||||||
|
| dfmt | :x: | Go to https://github.com/Hackerpilot/dfmt and follow the instructions. |
|
||||||
|
| elm-format | :x: | Go to https://github.com/avh4/elm-format and follow the instructions. |
|
||||||
|
| erl_tidy | :x: | Go to http://erlang.org/doc/man/erl_tidy.html and follow the instructions. |
|
||||||
|
| ESLint Fixer | :white_check_mark: | Nothing! |
|
||||||
|
| formatR | :x: | Go to https://github.com/yihui/formatR and follow the instructions. |
|
||||||
|
| Fortran Beautifier | :x: | Go to https://www.gnu.org/software/emacs/ and follow the instructions. |
|
||||||
|
| Gherkin formatter | :white_check_mark: | Nothing! |
|
||||||
|
| gofmt | :x: | Go to https://golang.org/cmd/gofmt/ and follow the instructions. |
|
||||||
|
| hh_format | :x: | Go to http://hhvm.com/ and follow the instructions. |
|
||||||
|
| HTML Beautifier | :x: | Go to https://github.com/threedaymonk/htmlbeautifier and follow the instructions. |
|
||||||
|
| JS Beautify | :white_check_mark: | Nothing! |
|
||||||
|
| JSCS Fixer | :white_check_mark: | Nothing! |
|
||||||
|
| Latex Beautify | :x: | Go to https://github.com/cmhughes/latexindent.pl and follow the instructions. |
|
||||||
|
| Lua beautifier | :x: | Go to https://www.perl.org/ and follow the instructions. |
|
||||||
|
| Marko Beautifier | :white_check_mark: | Nothing! |
|
||||||
|
| ocp-indent | :x: | Go to https://www.typerex.org/ocp-indent.html and follow the instructions. |
|
||||||
|
| Perltidy | :x: | Go to http://perltidy.sourceforge.net/ and follow the instructions. |
|
||||||
|
| PHP-CS-Fixer | :x: | Go to https://github.com/FriendsOfPHP/PHP-CS-Fixer and follow the instructions. |
|
||||||
|
| PHPCBF | :x: | Go to http://php.net/manual/en/install.php and follow the instructions. |
|
||||||
|
| Pretty Diff | :white_check_mark: | Nothing! |
|
||||||
|
| Pug Beautify | :white_check_mark: | Nothing! |
|
||||||
|
| puppet-lint | :x: | Go to http://puppet-lint.com/ and follow the instructions. |
|
||||||
|
| Remark | :white_check_mark: | Nothing! |
|
||||||
|
| Rubocop | :x: | Go to https://github.com/bbatsov/rubocop and follow the instructions. |
|
||||||
|
| Ruby Beautify | :x: | Go to https://github.com/erniebrodeur/ruby-beautify and follow the instructions. |
|
||||||
|
| rustfmt | :x: | Go to https://github.com/nrc/rustfmt and follow the instructions. |
|
||||||
|
| SassConvert | :x: | Go to http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax and follow the instructions. |
|
||||||
|
| sqlformat | :x: | Go to https://github.com/andialbrecht/sqlparse and follow the instructions. |
|
||||||
|
| stylish-haskell | :x: | Go to https://github.com/jaspervdj/stylish-haskell and follow the instructions. |
|
||||||
|
| Tidy Markdown | :white_check_mark: | Nothing! |
|
||||||
|
| TypeScript Formatter | :white_check_mark: | Nothing! |
|
||||||
|
| Uncrustify | :x: | Go to https://github.com/uncrustify/uncrustify and follow the instructions. |
|
||||||
|
| Vue Beautifier | :white_check_mark: | Nothing! |
|
||||||
|
| yapf | :x: | Go to https://github.com/google/yapf and follow the instructions. |
|
||||||
|
|
||||||
## Language Support
|
## Language Support
|
||||||
|
|
||||||
|
@ -78,7 +127,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
|
||||||
| Elm | `Elm` |`.elm` | [`elm-format`](https://github.com/avh4/elm-format) (Default) |
|
| Elm | `Elm` |`.elm` | [`elm-format`](https://github.com/avh4/elm-format) (Default) |
|
||||||
| ERB | `HTML (Ruby - ERB)`, `HTML (Rails)` |`.erb` | [`HTML Beautifier`](https://github.com/threedaymonk/htmlbeautifier), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
| ERB | `HTML (Ruby - ERB)`, `HTML (Rails)` |`.erb` | [`HTML Beautifier`](https://github.com/threedaymonk/htmlbeautifier), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
||||||
| Erlang | `Erlang` |`.erl` | [`erl_tidy`](http://erlang.org/doc/man/erl_tidy.html) (Default) |
|
| Erlang | `Erlang` |`.erl` | [`erl_tidy`](http://erlang.org/doc/man/erl_tidy.html) (Default) |
|
||||||
| Fortran | `Fortran - Modern` |`.f90`, `.F90`, `.f95`, `.F95` | [`Fortran Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/fortran-beautifier/emacs-fortran-formating-script.lisp) (Default) |
|
| Fortran | `Fortran - Modern` |`.f90`, `.F90`, `.f95`, `.F95` | [`Fortran Beautifier`](https://www.gnu.org/software/emacs/) (Default) |
|
||||||
| gherkin | `Gherkin` |`.feature` | [`Gherkin formatter`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee) (Default) |
|
| gherkin | `Gherkin` |`.feature` | [`Gherkin formatter`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee) (Default) |
|
||||||
| GLSL | `C`, `opencl`, `GLSL` |`.vert`, `.frag` | [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) (Default) |
|
| GLSL | `C`, `opencl`, `GLSL` |`.vert`, `.frag` | [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) (Default) |
|
||||||
| Go | `Go` |`.go` | [`gofmt`](https://golang.org/cmd/gofmt/) (Default) |
|
| Go | `Go` |`.go` | [`gofmt`](https://golang.org/cmd/gofmt/) (Default) |
|
||||||
|
@ -87,12 +136,12 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
|
||||||
| HTML | `HTML` |`.html` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
|
| HTML | `HTML` |`.html` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
|
||||||
| Jade | `Jade`, `Pug` |`.jade`, `.pug` | [`Pug Beautify`](https://github.com/vingorius/pug-beautify) (Default) |
|
| Jade | `Jade`, `Pug` |`.jade`, `.pug` | [`Pug Beautify`](https://github.com/vingorius/pug-beautify) (Default) |
|
||||||
| Java | `Java` |`.java` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
|
| Java | `Java` |`.java` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
|
||||||
| JavaScript | `JavaScript` |`.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
|
| JavaScript | `JavaScript` |`.js` | [`ESLint Fixer`](https://github.com/eslint/eslint), [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
|
||||||
| JSON | `JSON` |`.json` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
|
| JSON | `JSON` |`.json` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
|
||||||
| JSX | `JSX`, `JavaScript (JSX)`, `Babel ES6 JavaScript`, `JavaScript with JSX` |`.jsx`, `.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
| JSX | `JSX`, `JavaScript (JSX)`, `Babel ES6 JavaScript`, `JavaScript with JSX` |`.jsx`, `.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
||||||
| LaTeX | `LaTeX` |`.tex` | [`Latex Beautify`](https://github.com/cmhughes/latexindent.pl) (Default) |
|
| LaTeX | `LaTeX` |`.tex` | [`Latex Beautify`](https://github.com/cmhughes/latexindent.pl) (Default) |
|
||||||
| LESS | `LESS` |`.less` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
| LESS | `LESS` |`.less` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
||||||
| Lua | `Lua` |`.lua` | [`Lua beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.pl) (Default) |
|
| Lua | `Lua` |`.lua` | [`Lua beautifier`](https://www.perl.org/) (Default) |
|
||||||
| Markdown | `GitHub Markdown` |`.markdown`, `.md` | [`Remark`](https://github.com/wooorm/remark), [`Tidy Markdown`](https://github.com/slang800/tidy-markdown) (Default) |
|
| Markdown | `GitHub Markdown` |`.markdown`, `.md` | [`Remark`](https://github.com/wooorm/remark), [`Tidy Markdown`](https://github.com/slang800/tidy-markdown) (Default) |
|
||||||
| Marko | `Marko` |`.marko` | [`Marko Beautifier`](https://github.com/marko-js/marko-prettyprint) (Default) |
|
| Marko | `Marko` |`.marko` | [`Marko Beautifier`](https://github.com/marko-js/marko-prettyprint) (Default) |
|
||||||
| Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default) |
|
| Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default) |
|
||||||
|
@ -120,7 +169,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
|
||||||
| UX Markup | `UX` |`.ux` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
| UX Markup | `UX` |`.ux` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
||||||
| Vala | `Vala` |`.vala`, `.vapi` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
|
| Vala | `Vala` |`.vala`, `.vapi` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
|
||||||
| Visualforce | `Visualforce` |`.page` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
| Visualforce | `Visualforce` |`.page` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
||||||
| Vue | `Vue Component` |`.vue` | `Vue Beautifier` (Default) |
|
| Vue | `Vue Component` |`.vue` | [`Vue Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee) (Default) |
|
||||||
| XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP`, `GSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp`, `.gsp`, `.plist`, `.recipe` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
| XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP`, `GSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp`, `.gsp`, `.plist`, `.recipe` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
||||||
| XTemplate | `XTemplate` |`.xtemplate` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
| XTemplate | `XTemplate` |`.xtemplate` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ environment:
|
||||||
- PYTHON: "C:\\Python27"
|
- PYTHON: "C:\\Python27"
|
||||||
PYTHON_VERSION: "2.7.8"
|
PYTHON_VERSION: "2.7.8"
|
||||||
PYTHON_ARCH: "32"
|
PYTHON_ARCH: "32"
|
||||||
|
RUBY_VERSION: 23
|
||||||
|
|
||||||
# - PYTHON: "C:\\Python27-x64"
|
# - PYTHON: "C:\\Python27-x64"
|
||||||
# PYTHON_VERSION: "2.7.8"
|
# PYTHON_VERSION: "2.7.8"
|
||||||
|
@ -82,8 +83,7 @@ install:
|
||||||
- "%CMD_IN_ENV% pip install --upgrade sqlparse"
|
- "%CMD_IN_ENV% pip install --upgrade sqlparse"
|
||||||
|
|
||||||
# Ruby & Gem
|
# Ruby & Gem
|
||||||
- cinst ruby -y
|
- SET PATH=C:\Ruby%RUBY_VERSION%\bin;C:\Ruby23-x64\DevKit\mingw\bin;%PATH%
|
||||||
- "SET PATH=C:\\tools\\ruby23\\bin;%PATH%"
|
|
||||||
# Rubocop
|
# Rubocop
|
||||||
- gem install rubocop
|
- gem install rubocop
|
||||||
- where rubocop
|
- where rubocop
|
||||||
|
@ -104,9 +104,10 @@ install:
|
||||||
# FIXME: Enable allowEmptyChecksums, until someone fixes the checksum issue of php
|
# FIXME: Enable allowEmptyChecksums, until someone fixes the checksum issue of php
|
||||||
- choco feature enable -n allowEmptyChecksums
|
- choco feature enable -n allowEmptyChecksums
|
||||||
# PHP
|
# PHP
|
||||||
|
- ps: Set-Service wuauserv -StartupType Manual
|
||||||
- cinst php -y
|
- cinst php -y
|
||||||
- ps: "ls \"C:\\tools\\php\""
|
- ps: "ls \"C:\\tools\\php71\""
|
||||||
- "SET PATH=C:\\tools\\php;%PATH%"
|
- "SET PATH=C:\\tools\\php71;%PATH%"
|
||||||
- where php
|
- where php
|
||||||
# PHP-CS-Fixer
|
# PHP-CS-Fixer
|
||||||
- cinst curl -y # Use cURL to download file from URL
|
- cinst curl -y # Use cURL to download file from URL
|
||||||
|
|
|
@ -150,6 +150,31 @@ Handlebars.registerHelper('language-options-support', (languageOptions, options)
|
||||||
return new Handlebars.SafeString(results)
|
return new Handlebars.SafeString(results)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Handlebars.registerHelper('beautifiers-info', (beautifiers, options) ->
|
||||||
|
|
||||||
|
###
|
||||||
|
| Beautifier | Is Pre-Installed? | Installation Instructions |
|
||||||
|
| --- | ---- |
|
||||||
|
| Pretty Diff | :white_check_mark: | N/A |
|
||||||
|
| AutoPEP8 | :x: | LINK |
|
||||||
|
###
|
||||||
|
|
||||||
|
rows = _.map(beautifiers, (beautifier, k) ->
|
||||||
|
name = beautifier.name
|
||||||
|
isPreInstalled = beautifier.isPreInstalled
|
||||||
|
link = beautifier.link
|
||||||
|
installationInstructions = if isPreInstalled then "Nothing!" else "Go to #{link} and follow the instructions."
|
||||||
|
return "| #{name} | #{if isPreInstalled then ':white_check_mark:' else ':x:'} | #{installationInstructions} |"
|
||||||
|
)
|
||||||
|
results = """
|
||||||
|
| Beautifier | Is Pre-Installed? | Installation Instructions |
|
||||||
|
| --- | --- | --- |
|
||||||
|
#{rows.join('\n')}
|
||||||
|
"""
|
||||||
|
return new Handlebars.SafeString(results)
|
||||||
|
)
|
||||||
|
|
||||||
sortKeysBy = (obj, comparator) ->
|
sortKeysBy = (obj, comparator) ->
|
||||||
keys = _.sortBy(_.keys(obj), (key) ->
|
keys = _.sortBy(_.keys(obj), (key) ->
|
||||||
return if comparator then comparator(obj[key], key) else key
|
return if comparator then comparator(obj[key], key) else key
|
||||||
|
@ -176,6 +201,7 @@ context = {
|
||||||
packageOptions: sortSettings(packageOptions)
|
packageOptions: sortSettings(packageOptions)
|
||||||
languageOptions: sortSettings(languageOptions)
|
languageOptions: sortSettings(languageOptions)
|
||||||
beautifierOptions: sortSettings(beautifierOptions)
|
beautifierOptions: sortSettings(beautifierOptions)
|
||||||
|
beautifiers: _.sortBy(beautifier.beautifiers, (beautifier) -> beautifier.name.toLowerCase())
|
||||||
}
|
}
|
||||||
result = template(context)
|
result = template(context)
|
||||||
readmeResult = readmeTemplate(context)
|
readmeResult = readmeTemplate(context)
|
||||||
|
|
|
@ -4963,32 +4963,32 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
|
||||||
|
|
||||||
#### [JavaScript](#javascript)
|
#### [JavaScript](#javascript)
|
||||||
|
|
||||||
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`JSCS Fixer`](#jscs-fixer) [`Pretty Diff`](#pretty-diff)
|
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`JSCS Fixer`](#jscs-fixer) [`ESLint Fixer`](#eslint-fixer) [`Pretty Diff`](#pretty-diff)
|
||||||
|
|
||||||
| Option | JS Beautify | JSCS Fixer | Pretty Diff |
|
| Option | ESLint Fixer | JS Beautify | JSCS Fixer | Pretty Diff |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| `brace_style` | :white_check_mark: | :x: | :x: |
|
| `brace_style` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `break_chained_methods` | :white_check_mark: | :x: | :white_check_mark: |
|
| `break_chained_methods` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| `end_with_comma` | :white_check_mark: | :x: | :white_check_mark: |
|
| `end_with_comma` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| `end_with_newline` | :white_check_mark: | :x: | :x: |
|
| `end_with_newline` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `eval_code` | :white_check_mark: | :x: | :x: |
|
| `eval_code` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `indent_char` | :white_check_mark: | :x: | :white_check_mark: |
|
| `indent_char` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| `indent_level` | :white_check_mark: | :x: | :x: |
|
| `indent_level` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `indent_size` | :white_check_mark: | :x: | :white_check_mark: |
|
| `indent_size` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| `indent_with_tabs` | :white_check_mark: | :x: | :white_check_mark: |
|
| `indent_with_tabs` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| `jslint_happy` | :white_check_mark: | :x: | :x: |
|
| `jslint_happy` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `keep_array_indentation` | :white_check_mark: | :x: | :x: |
|
| `keep_array_indentation` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `keep_function_indentation` | :white_check_mark: | :x: | :x: |
|
| `keep_function_indentation` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `max_preserve_newlines` | :white_check_mark: | :x: | :x: |
|
| `max_preserve_newlines` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `preserve_newlines` | :white_check_mark: | :x: | :white_check_mark: |
|
| `preserve_newlines` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| `space_after_anon_function` | :white_check_mark: | :x: | :white_check_mark: |
|
| `space_after_anon_function` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| `space_before_conditional` | :white_check_mark: | :x: | :x: |
|
| `space_before_conditional` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `space_in_paren` | :white_check_mark: | :x: | :white_check_mark: |
|
| `space_in_paren` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| `unescape_strings` | :white_check_mark: | :x: | :x: |
|
| `unescape_strings` | :x: | :white_check_mark: | :x: | :x: |
|
||||||
| `wrap_line_length` | :white_check_mark: | :x: | :white_check_mark: |
|
| `wrap_line_length` | :x: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
|
|
||||||
**Description**:
|
**Description**:
|
||||||
|
|
||||||
|
@ -5019,7 +5019,7 @@ Disable JavaScript Beautification
|
||||||
|
|
||||||
**Type**: `string`
|
**Type**: `string`
|
||||||
|
|
||||||
**Enum**: `JS Beautify` `JSCS Fixer` `Pretty Diff`
|
**Enum**: `JS Beautify` `JSCS Fixer` `ESLint Fixer` `Pretty Diff`
|
||||||
|
|
||||||
**Description**:
|
**Description**:
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,34 @@
|
||||||
-- Ensure that that the element at i is in the right position,
|
-- Ensure that that the element at i is in the right position,
|
||||||
-- and return a closure which can be used for continuing the sort.
|
-- and return a closure which can be used for continuing the sort.
|
||||||
|
local a = 'a b c'
|
||||||
|
local b = '12345678'
|
||||||
|
local c = 'a b c' + 'a b c'
|
||||||
|
local t = {
|
||||||
|
a = 1,
|
||||||
|
b = 2,
|
||||||
|
c = 3,
|
||||||
|
}
|
||||||
|
if a ~= 'a' then
|
||||||
|
local b = a
|
||||||
|
end
|
||||||
|
local e = {a = 1, b = 2}
|
||||||
|
function aaa(a, b, c)
|
||||||
|
|
||||||
|
-- comment 1
|
||||||
|
-- comment 2 1231
|
||||||
|
-- comment 1 123 123 123123 12
|
||||||
|
-- [[ comment 1 ]]
|
||||||
|
--[[
|
||||||
|
muli comments
|
||||||
|
ssss
|
||||||
|
@asdasd sad
|
||||||
|
]]
|
||||||
|
local a = -1
|
||||||
|
return a + b - c
|
||||||
|
end
|
||||||
|
local b = {a = 1, b = [[this is two space ;
|
||||||
|
]], c = 2}
|
||||||
|
|
||||||
function quicksorter(i, vec, low, high)
|
function quicksorter(i, vec, low, high)
|
||||||
if low >= high then
|
if low >= high then
|
||||||
return quicksorter
|
return quicksorter
|
||||||
|
|
|
@ -1,5 +1,34 @@
|
||||||
-- Ensure that that the element at i is in the right position,
|
-- Ensure that that the element at i is in the right position,
|
||||||
-- and return a closure which can be used for continuing the sort.
|
-- and return a closure which can be used for continuing the sort.
|
||||||
|
local a= 'a b c'
|
||||||
|
local b ='12345678'
|
||||||
|
local c = 'a b c' +'a b c'
|
||||||
|
local t = {
|
||||||
|
a = 1,
|
||||||
|
b =2 ,
|
||||||
|
c= 3,
|
||||||
|
}
|
||||||
|
if a~='a' then
|
||||||
|
local b=a
|
||||||
|
end
|
||||||
|
local e={a=1,b=2}
|
||||||
|
function aaa(a,b,c)
|
||||||
|
|
||||||
|
-- comment 1
|
||||||
|
-- comment 2 1231
|
||||||
|
-- comment 1 123 123 123123 12
|
||||||
|
-- [[ comment 1 ]]
|
||||||
|
--[[
|
||||||
|
muli comments
|
||||||
|
ssss
|
||||||
|
@asdasd sad
|
||||||
|
]]
|
||||||
|
local a = -1
|
||||||
|
return a+b-c
|
||||||
|
end
|
||||||
|
local b = {a=1,b=[[this is two space ;
|
||||||
|
]],c=2}
|
||||||
|
|
||||||
function quicksorter(i, vec, low, high)
|
function quicksorter(i, vec, low, high)
|
||||||
if low >= high then
|
if low >= high then
|
||||||
return quicksorter
|
return quicksorter
|
||||||
|
|
|
@ -118,6 +118,10 @@
|
||||||
{
|
{
|
||||||
"name": "Anton Brok-Volchansky",
|
"name": "Anton Brok-Volchansky",
|
||||||
"url": "https://github.com/re6exp"
|
"url": "https://github.com/re6exp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Taylon Silmer",
|
||||||
|
"url": "https://github.com/taylon"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -134,6 +138,7 @@
|
||||||
"csscomb": "^3.1.7",
|
"csscomb": "^3.1.7",
|
||||||
"diff": "3.0.0",
|
"diff": "3.0.0",
|
||||||
"editorconfig": "^0.13.2",
|
"editorconfig": "^0.13.2",
|
||||||
|
"eslint": "^3.13.1",
|
||||||
"event-kit": "^2.1.0",
|
"event-kit": "^2.1.0",
|
||||||
"expand-home-dir": "0.0.3",
|
"expand-home-dir": "0.0.3",
|
||||||
"extend": "^3.0.0",
|
"extend": "^3.0.0",
|
||||||
|
@ -263,6 +268,8 @@
|
||||||
"fortran beautifier",
|
"fortran beautifier",
|
||||||
"js beautify",
|
"js beautify",
|
||||||
"jscs fixer",
|
"jscs fixer",
|
||||||
|
"eslint",
|
||||||
|
"eslint fixer",
|
||||||
"lua beautifier",
|
"lua beautifier",
|
||||||
"ocp-indent",
|
"ocp-indent",
|
||||||
"perltidy",
|
"perltidy",
|
||||||
|
|
|
@ -9,6 +9,7 @@ module.exports = class Autopep8 extends Beautifier
|
||||||
|
|
||||||
name: "autopep8"
|
name: "autopep8"
|
||||||
link: "https://github.com/hhatto/autopep8"
|
link: "https://github.com/hhatto/autopep8"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Python: true
|
Python: true
|
||||||
|
|
|
@ -31,6 +31,11 @@ module.exports = class Beautifier
|
||||||
###
|
###
|
||||||
options: {}
|
options: {}
|
||||||
|
|
||||||
|
###
|
||||||
|
Is the beautifier a command-line interface beautifier?
|
||||||
|
###
|
||||||
|
isPreInstalled: true
|
||||||
|
|
||||||
###
|
###
|
||||||
Supported languages by this Beautifier
|
Supported languages by this Beautifier
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class BashBeautify extends Beautifier
|
module.exports = class BashBeautify extends Beautifier
|
||||||
name: "beautysh"
|
name: "beautysh"
|
||||||
link: "https://github.com/bemeurer/beautysh"
|
link: "https://github.com/bemeurer/beautysh"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Bash:
|
Bash:
|
||||||
indent_size: true
|
indent_size: true
|
||||||
|
|
|
@ -11,6 +11,7 @@ module.exports = class ClangFormat extends Beautifier
|
||||||
|
|
||||||
name: "clang-format"
|
name: "clang-format"
|
||||||
link: "https://clang.llvm.org/docs/ClangFormat.html"
|
link: "https://clang.llvm.org/docs/ClangFormat.html"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
"C++": false
|
"C++": false
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class Crystal extends Beautifier
|
module.exports = class Crystal extends Beautifier
|
||||||
name: "Crystal"
|
name: "Crystal"
|
||||||
link: "http://crystal-lang.org"
|
link: "http://crystal-lang.org"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Crystal: false
|
Crystal: false
|
||||||
|
|
|
@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class Dfmt extends Beautifier
|
module.exports = class Dfmt extends Beautifier
|
||||||
name: "dfmt"
|
name: "dfmt"
|
||||||
link: "https://github.com/Hackerpilot/dfmt"
|
link: "https://github.com/Hackerpilot/dfmt"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
D: false
|
D: false
|
||||||
|
|
|
@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class ElmFormat extends Beautifier
|
module.exports = class ElmFormat extends Beautifier
|
||||||
name: "elm-format"
|
name: "elm-format"
|
||||||
link: "https://github.com/avh4/elm-format"
|
link: "https://github.com/avh4/elm-format"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Elm: true
|
Elm: true
|
||||||
|
|
|
@ -9,6 +9,7 @@ module.exports = class ErlTidy extends Beautifier
|
||||||
|
|
||||||
name: "erl_tidy"
|
name: "erl_tidy"
|
||||||
link: "http://erlang.org/doc/man/erl_tidy.html"
|
link: "http://erlang.org/doc/man/erl_tidy.html"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Erlang: true
|
Erlang: true
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
"use strict"
|
||||||
|
|
||||||
|
Beautifier = require('./beautifier')
|
||||||
|
Path = require('path')
|
||||||
|
{allowUnsafeNewFunction} = require 'loophole'
|
||||||
|
|
||||||
|
module.exports = class ESLintFixer extends Beautifier
|
||||||
|
name: "ESLint Fixer"
|
||||||
|
link: "https://github.com/eslint/eslint"
|
||||||
|
|
||||||
|
options: {
|
||||||
|
JavaScript: false
|
||||||
|
}
|
||||||
|
|
||||||
|
beautify: (text, language, options) ->
|
||||||
|
return new @Promise((resolve, reject) ->
|
||||||
|
editor = atom.workspace.getActiveTextEditor()
|
||||||
|
filePath = editor.getPath()
|
||||||
|
projectPath = atom.project.relativizePath(filePath)[0]
|
||||||
|
|
||||||
|
result = null
|
||||||
|
allowUnsafeNewFunction ->
|
||||||
|
importPath = Path.join(projectPath, 'node_modules', 'eslint')
|
||||||
|
try
|
||||||
|
CLIEngine = require(importPath).CLIEngine
|
||||||
|
|
||||||
|
cli = new CLIEngine(fix: true, cwd: projectPath)
|
||||||
|
result = cli.executeOnText(text).results[0]
|
||||||
|
|
||||||
|
resolve result.output
|
||||||
|
catch err
|
||||||
|
reject(err)
|
||||||
|
)
|
|
@ -9,6 +9,7 @@ Beautifier = require('../beautifier')
|
||||||
module.exports = class R extends Beautifier
|
module.exports = class R extends Beautifier
|
||||||
name: "formatR"
|
name: "formatR"
|
||||||
link: "https://github.com/yihui/formatR"
|
link: "https://github.com/yihui/formatR"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
R: true
|
R: true
|
||||||
|
|
|
@ -8,7 +8,8 @@ path = require("path")
|
||||||
|
|
||||||
module.exports = class FortranBeautifier extends Beautifier
|
module.exports = class FortranBeautifier extends Beautifier
|
||||||
name: "Fortran Beautifier"
|
name: "Fortran Beautifier"
|
||||||
link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/fortran-beautifier/emacs-fortran-formating-script.lisp"
|
link: "https://www.gnu.org/software/emacs/"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Fortran: true
|
Fortran: true
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class Gofmt extends Beautifier
|
module.exports = class Gofmt extends Beautifier
|
||||||
name: "gofmt"
|
name: "gofmt"
|
||||||
link: "https://golang.org/cmd/gofmt/"
|
link: "https://golang.org/cmd/gofmt/"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Go: true
|
Go: true
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class HhFormat extends Beautifier
|
module.exports = class HhFormat extends Beautifier
|
||||||
name: "hh_format"
|
name: "hh_format"
|
||||||
link: "http://hhvm.com/"
|
link: "http://hhvm.com/"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options:
|
options:
|
||||||
PHP: false
|
PHP: false
|
||||||
|
|
|
@ -8,6 +8,8 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class HTMLBeautifier extends Beautifier
|
module.exports = class HTMLBeautifier extends Beautifier
|
||||||
name: "HTML Beautifier"
|
name: "HTML Beautifier"
|
||||||
link: "https://github.com/threedaymonk/htmlbeautifier"
|
link: "https://github.com/threedaymonk/htmlbeautifier"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
ERB:
|
ERB:
|
||||||
indent_size: true
|
indent_size: true
|
||||||
|
|
|
@ -52,6 +52,7 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
'fortran-beautifier'
|
'fortran-beautifier'
|
||||||
'js-beautify'
|
'js-beautify'
|
||||||
'jscs'
|
'jscs'
|
||||||
|
'eslint'
|
||||||
'lua-beautifier'
|
'lua-beautifier'
|
||||||
'ocp-indent'
|
'ocp-indent'
|
||||||
'perltidy'
|
'perltidy'
|
||||||
|
@ -140,20 +141,32 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
) or beautifiers[0]
|
) or beautifiers[0]
|
||||||
return beautifier
|
return beautifier
|
||||||
|
|
||||||
getLanguage : (grammar, filePath) ->
|
getExtension : (filePath) ->
|
||||||
|
if filePath
|
||||||
|
return path.extname(filePath).substr(1)
|
||||||
|
|
||||||
|
getLanguages : (grammar, filePath) ->
|
||||||
# Get language
|
# Get language
|
||||||
fileExtension = path.extname(filePath)
|
fileExtension = @getExtension(filePath)
|
||||||
# Remove prefix "." (period) in fileExtension
|
|
||||||
fileExtension = fileExtension.substr(1)
|
if fileExtension
|
||||||
languages = @languages.getLanguages({grammar, extension: fileExtension})
|
languages = @languages.getLanguages({grammar, extension: fileExtension})
|
||||||
logger.verbose(languages, grammar, fileExtension)
|
|
||||||
# Check if unsupported language
|
|
||||||
if languages.length < 1
|
|
||||||
return null
|
|
||||||
else
|
else
|
||||||
# TODO: select appropriate language
|
languages = @languages.getLanguages({grammar})
|
||||||
|
|
||||||
|
logger.verbose(languages, grammar, fileExtension)
|
||||||
|
|
||||||
|
return languages
|
||||||
|
|
||||||
|
getLanguage : (grammar, filePath) ->
|
||||||
|
languages = @getLanguages(grammar, filePath)
|
||||||
|
|
||||||
|
# Check if unsupported language
|
||||||
|
if languages.length > 0
|
||||||
language = languages[0]
|
language = languages[0]
|
||||||
|
|
||||||
|
return language
|
||||||
|
|
||||||
getOptionsForLanguage : (allOptions, language) ->
|
getOptionsForLanguage : (allOptions, language) ->
|
||||||
# Options for Language
|
# Options for Language
|
||||||
selections = (language.fallback or []).concat([language.namespace])
|
selections = (language.fallback or []).concat([language.namespace])
|
||||||
|
@ -241,15 +254,10 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
logger.info('beautify', text, allOptions, grammar, filePath, onSave)
|
logger.info('beautify', text, allOptions, grammar, filePath, onSave)
|
||||||
logger.verbose(allOptions)
|
logger.verbose(allOptions)
|
||||||
|
|
||||||
# Get language
|
language = @getLanguage(grammar, filePath)
|
||||||
fileExtension = path.extname(filePath)
|
|
||||||
# Remove prefix "." (period) in fileExtension
|
|
||||||
fileExtension = fileExtension.substr(1)
|
|
||||||
languages = @languages.getLanguages({grammar, extension: fileExtension})
|
|
||||||
logger.verbose(languages, grammar, fileExtension)
|
|
||||||
|
|
||||||
# Check if unsupported language
|
# Check if unsupported language
|
||||||
if languages.length < 1
|
if !language
|
||||||
unsupportedGrammar = true
|
unsupportedGrammar = true
|
||||||
|
|
||||||
logger.verbose('Unsupported language')
|
logger.verbose('Unsupported language')
|
||||||
|
@ -260,19 +268,14 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
# not intended to be beautified
|
# not intended to be beautified
|
||||||
return resolve( null )
|
return resolve( null )
|
||||||
else
|
else
|
||||||
# TODO: select appropriate language
|
|
||||||
language = languages[0]
|
|
||||||
|
|
||||||
logger.verbose("Language #{language.name} supported")
|
logger.verbose("Language #{language.name} supported")
|
||||||
|
|
||||||
# Get language config
|
# Get language config
|
||||||
langDisabled = atom.config.get("atom-beautify.#{language.namespace}.disabled")
|
langDisabled = atom.config.get("atom-beautify.#{language.namespace}.disabled")
|
||||||
|
|
||||||
|
|
||||||
# Beautify!
|
# Beautify!
|
||||||
unsupportedGrammar = false
|
unsupportedGrammar = false
|
||||||
|
|
||||||
|
|
||||||
# Check if Language is disabled
|
# Check if Language is disabled
|
||||||
if langDisabled
|
if langDisabled
|
||||||
logger.verbose("Language #{language.name} is disabled")
|
logger.verbose("Language #{language.name} is disabled")
|
||||||
|
@ -370,6 +373,7 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors")
|
if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors")
|
||||||
return resolve( null )
|
return resolve( null )
|
||||||
else
|
else
|
||||||
|
fileExtension = @getExtension(filePath)
|
||||||
repoBugsUrl = pkg.bugs.url
|
repoBugsUrl = pkg.bugs.url
|
||||||
title = "Atom Beautify could not find a supported beautifier for this file"
|
title = "Atom Beautify could not find a supported beautifier for this file"
|
||||||
detail = """
|
detail = """
|
||||||
|
|
|
@ -8,6 +8,7 @@ temp = require("temp").track()
|
||||||
module.exports = class LatexBeautify extends Beautifier
|
module.exports = class LatexBeautify extends Beautifier
|
||||||
name: "Latex Beautify"
|
name: "Latex Beautify"
|
||||||
link: "https://github.com/cmhughes/latexindent.pl"
|
link: "https://github.com/cmhughes/latexindent.pl"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
LaTeX: true
|
LaTeX: true
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
DEFAULT_INDENT = ' '
|
||||||
|
|
||||||
|
adjust_space = (line) ->
|
||||||
|
string_list = line.match /(['"])[^\1]*?\1/g
|
||||||
|
muli_string = line.match /\[(=*)\[([^\]\1\]]*)/
|
||||||
|
comment = line.match /\-{2}[^\[].*$/
|
||||||
|
line = line.replace /\s+/g, ' '
|
||||||
|
# replace all whitespaces inside the string with one space, WARNING: the whitespaces in string will be replace too!
|
||||||
|
line = line.replace /\s?(==|>=|<=|~=|[=><\+\*\/])\s?/g, ' $1 '
|
||||||
|
# add whitespace around the operator
|
||||||
|
line = line.replace /([^=|\-|(|\s])\s?\-\s?([^\-|\[])/g, '$1 - $2'
|
||||||
|
# just format minus, not for -- or negative number or commentary.
|
||||||
|
line = line.replace /,([^\s])/g, ', $1'
|
||||||
|
# adjust ','
|
||||||
|
line = line.replace /\s+,/g, ','
|
||||||
|
# recover the whitespaces in string.
|
||||||
|
line = line.replace /(['"])[^\1]*?\1/g, ->
|
||||||
|
string_list.shift()
|
||||||
|
if muli_string and muli_string[0]
|
||||||
|
line = line.replace /\[(=*)\[([^\]\1\]]*)/, muli_string[0]
|
||||||
|
if comment and comment[0]
|
||||||
|
line = line.replace /\-{2}[^\[].*$/, comment[0]
|
||||||
|
line
|
||||||
|
|
||||||
|
DEFAULT_WARN_FN = (msg) ->
|
||||||
|
console.log('WARNING:', msg)
|
||||||
|
|
||||||
|
module.exports = (str, indent, warn_fn) ->
|
||||||
|
indent = indent or DEFAULT_INDENT
|
||||||
|
warn_fn = if typeof warn_fn == 'function' then warn_fn else DEFAULT_WARN_FN
|
||||||
|
indent = ' '.repeat(indent) if Number.isInteger(indent)
|
||||||
|
$currIndent = 0
|
||||||
|
$nextIndent = 0
|
||||||
|
$prevLength = 0
|
||||||
|
$extIndent = 0
|
||||||
|
$lastIndent = 0
|
||||||
|
$template = 0
|
||||||
|
new_code = str.split(/\r?\n/g).map (line, line_number) ->
|
||||||
|
$template_flag = false
|
||||||
|
if $template
|
||||||
|
res2 = line.match(/\](=*)\]/)
|
||||||
|
if res2 and $template == res2[1].length + 1
|
||||||
|
$template_flag = true
|
||||||
|
if $template and !/]=*]$/.test(line)
|
||||||
|
arr = line.split(/\]=*\]/, 2)
|
||||||
|
comment = arr[0]
|
||||||
|
code = arr[1]
|
||||||
|
line = comment + ']' + '='.repeat($template - 1) + ']' + adjust_space(code)
|
||||||
|
$template = 0
|
||||||
|
$template = 0
|
||||||
|
else
|
||||||
|
return line
|
||||||
|
res1 = line.match(/\[(=*)\[/)
|
||||||
|
if res1
|
||||||
|
$template = res1[1].length + 1
|
||||||
|
if !$template_flag
|
||||||
|
line = line.trim()
|
||||||
|
# remote all spaces on both ends
|
||||||
|
line = adjust_space(line)
|
||||||
|
if !line.length
|
||||||
|
return ''
|
||||||
|
raw_line = line
|
||||||
|
line = line.replace(/(['"])[^\1]*?\1/, '')
|
||||||
|
# remove all quoted fragments for proper bracket processing
|
||||||
|
line = line.replace(/\s*--.+/, '')
|
||||||
|
# remove all comments; this ignores long bracket style comments
|
||||||
|
if /^((local )?function|repeat|while)\b/.test(line) and !/\bend\s*[\),;]*$/.test(line) or /\b(then|do)$/.test(line) and !/^elseif\b/.test(line) or /^if\b/.test(line) and /\bthen\b/.test(line) and !/\bend$/.test(line) or /\bfunction ?(?:\w+ )?\([^\)]*\)$/.test(line) and !/\bend$/.test(line)
|
||||||
|
$nextIndent = $currIndent + 1
|
||||||
|
else if /^until\b/.test(line) or /^end\s*[\),;]*$/.test(line) or /^end\s*\)\s*\.\./.test(line) or /^else(if)?\b/.test(line) and /\bend$/.test(line)
|
||||||
|
$nextIndent = --$currIndent
|
||||||
|
else if /^else\b/.test(line) or /^elseif\b/.test(line)
|
||||||
|
$nextIndent = $currIndent
|
||||||
|
$currIndent = $currIndent - 1
|
||||||
|
$brackets = (line.match(/\(/g) or []).length - ((line.match(/\)/g) or []).length)
|
||||||
|
# capture unbalanced brackets
|
||||||
|
$curly = (line.match(/\{/g) or []).length - ((line.match(/\}/g) or []).length)
|
||||||
|
# capture unbalanced curly brackets
|
||||||
|
# close (curly) brackets if needed
|
||||||
|
if $curly < 0
|
||||||
|
$currIndent += $curly
|
||||||
|
if $brackets < 0
|
||||||
|
$currIndent += $brackets
|
||||||
|
$nextIndent += $brackets + $curly
|
||||||
|
# console.log({last: $lastIndent, curr: $currIndent, next: $nextIndent, ext: $extIndent})
|
||||||
|
if $currIndent - $lastIndent > 1
|
||||||
|
$extIndent += $nextIndent - $lastIndent - 1
|
||||||
|
$nextIndent = $currIndent = 1 + $lastIndent
|
||||||
|
if $currIndent - $lastIndent < -1 and $extIndent > 0
|
||||||
|
$extIndent += $currIndent - $lastIndent + 1
|
||||||
|
$currIndent = -1 + $lastIndent
|
||||||
|
if $nextIndent < $currIndent
|
||||||
|
$nextIndent = $currIndent
|
||||||
|
# console.log({last: $lastIndent, curr: $currIndent, next: $nextIndent, ext: $extIndent})
|
||||||
|
warn_fn """negative indentation at line #{line_number}: #{raw_line}""" if $currIndent < 0
|
||||||
|
new_line = (if raw_line.length and $currIndent > 0 and !$template_flag then indent.repeat($currIndent) else '') + raw_line
|
||||||
|
$useful = $prevLength > 0 or raw_line.length > 0
|
||||||
|
$lastIndent = $currIndent
|
||||||
|
$currIndent = $nextIndent
|
||||||
|
$prevLength = raw_line.length
|
||||||
|
new_line or undefined
|
||||||
|
|
||||||
|
warn_fn 'positive indentation at the end' if $currIndent > 0
|
||||||
|
new_code.join '\n'
|
|
@ -1,57 +0,0 @@
|
||||||
# Copyright 2011 Paul Kulchenko
|
|
||||||
# Credits: http://notebook.kulchenko.com/programming/lua-beautifier-in-55-lines-of-perl
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
use constant INDENT => ' ';
|
|
||||||
my($currIndent, $nextIndent, $prevLength) = (0, 0, 0);
|
|
||||||
|
|
||||||
while (<>) {
|
|
||||||
chomp;
|
|
||||||
s/^\s+|\s+$//g; # remote all spaces on both ends
|
|
||||||
s/\s+/ /g; # replace all whitespaces inside the string with one space
|
|
||||||
|
|
||||||
my $orig = $_;
|
|
||||||
|
|
||||||
s/(['"])[^\1]*?\1//g; # remove all quoted fragments for proper bracket processing
|
|
||||||
s/\s*--.+//; # remove all comments; this ignores long bracket style comments
|
|
||||||
|
|
||||||
# open a level; increase next indentation; don't change current one
|
|
||||||
if (/^((local )?function|repeat|while)\b/ && !/\bend\s*[\),;]*$/
|
|
||||||
|| /\b(then|do)$/ && !/^elseif\b/ # only open on 'then' if there is no 'elseif'
|
|
||||||
|| /^if\b/ && /\bthen\b/ && !/\bend$/ # only open on 'if' if there is no 'end' at the end
|
|
||||||
|| /\bfunction\s*\([^\)]*\)$/) {
|
|
||||||
$nextIndent = $currIndent + 1;
|
|
||||||
}
|
|
||||||
# close the level; change both current and next indentation
|
|
||||||
elsif (/^until\b/
|
|
||||||
|| /^end\s*[\),;]*$/
|
|
||||||
|| /^end\s*\)\s*\.\./ # this is a special case of 'end).."some string"'
|
|
||||||
|| /^else(if)?\b/ && /\bend$/) {
|
|
||||||
$nextIndent = $currIndent = $currIndent - 1;
|
|
||||||
}
|
|
||||||
# keep the level; decrease the current indentation; keep the next one
|
|
||||||
elsif (/^else\b/
|
|
||||||
|| /^elseif\b/) {
|
|
||||||
($nextIndent, $currIndent) = ($currIndent, $currIndent-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $brackets = y/(// - y/)//; # capture unbalanced brackets
|
|
||||||
my $curly = y/{// - y/}//; # capture unbalanced curly brackets
|
|
||||||
|
|
||||||
# close (curly) brackets if needed
|
|
||||||
$currIndent += $curly if $curly < 0 && /^\}/;
|
|
||||||
$currIndent += $brackets if $brackets < 0 && /^\)/;
|
|
||||||
|
|
||||||
warn "WARNING: negative indentation at line $.: $orig\n" if $currIndent < 0;
|
|
||||||
|
|
||||||
print((length($orig) ? (INDENT x $currIndent) : ''), $orig, "\n")
|
|
||||||
if $prevLength > 0 || length($orig) > 0; # this is to collapse empty lines
|
|
||||||
|
|
||||||
$nextIndent += $brackets + $curly;
|
|
||||||
|
|
||||||
$currIndent = $nextIndent;
|
|
||||||
$prevLength = length($orig);
|
|
||||||
}
|
|
||||||
|
|
||||||
warn "WARNING: positive indentation at the end\n" if $nextIndent > 0;
|
|
|
@ -4,19 +4,20 @@ path = require("path")
|
||||||
|
|
||||||
"use strict"
|
"use strict"
|
||||||
Beautifier = require('../beautifier')
|
Beautifier = require('../beautifier')
|
||||||
|
format = require './beautifier'
|
||||||
|
|
||||||
module.exports = class Lua extends Beautifier
|
module.exports = class Lua extends Beautifier
|
||||||
name: "Lua beautifier"
|
name: "Lua beautifier"
|
||||||
link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.pl"
|
link: "https://www.perl.org/"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Lua: true
|
Lua: true
|
||||||
}
|
}
|
||||||
|
|
||||||
beautify: (text, language, options) ->
|
beautify: (text, language, options) ->
|
||||||
lua_beautifier = path.resolve(__dirname, "beautifier.pl")
|
new @Promise (resolve, reject) ->
|
||||||
@run("perl", [
|
try
|
||||||
lua_beautifier,
|
resolve format text, options.indent_char.repeat options.indent_size
|
||||||
'<',
|
catch error
|
||||||
@tempFile("input", text)
|
reject error
|
||||||
])
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class OCPIndent extends Beautifier
|
module.exports = class OCPIndent extends Beautifier
|
||||||
name: "ocp-indent"
|
name: "ocp-indent"
|
||||||
link: "https://www.typerex.org/ocp-indent.html"
|
link: "https://www.typerex.org/ocp-indent.html"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
OCaml: true
|
OCaml: true
|
||||||
|
|
|
@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class PerlTidy extends Beautifier
|
module.exports = class PerlTidy extends Beautifier
|
||||||
name: "Perltidy"
|
name: "Perltidy"
|
||||||
link: "http://perltidy.sourceforge.net/"
|
link: "http://perltidy.sourceforge.net/"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Perl: true
|
Perl: true
|
||||||
|
|
|
@ -10,6 +10,7 @@ module.exports = class PHPCSFixer extends Beautifier
|
||||||
|
|
||||||
name: 'PHP-CS-Fixer'
|
name: 'PHP-CS-Fixer'
|
||||||
link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer"
|
link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options:
|
options:
|
||||||
PHP: true
|
PHP: true
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class PHPCBF extends Beautifier
|
module.exports = class PHPCBF extends Beautifier
|
||||||
name: "PHPCBF"
|
name: "PHPCBF"
|
||||||
link: "http://php.net/manual/en/install.php"
|
link: "http://php.net/manual/en/install.php"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
_:
|
_:
|
||||||
|
|
|
@ -8,6 +8,7 @@ module.exports = class PuppetFix extends Beautifier
|
||||||
# this is what displays as your Default Beautifier in Language Config
|
# this is what displays as your Default Beautifier in Language Config
|
||||||
name: "puppet-lint"
|
name: "puppet-lint"
|
||||||
link: "http://puppet-lint.com/"
|
link: "http://puppet-lint.com/"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Puppet: true
|
Puppet: true
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class Rubocop extends Beautifier
|
module.exports = class Rubocop extends Beautifier
|
||||||
name: "Rubocop"
|
name: "Rubocop"
|
||||||
link: "https://github.com/bbatsov/rubocop"
|
link: "https://github.com/bbatsov/rubocop"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Ruby:
|
Ruby:
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class RubyBeautify extends Beautifier
|
module.exports = class RubyBeautify extends Beautifier
|
||||||
name: "Ruby Beautify"
|
name: "Ruby Beautify"
|
||||||
link: "https://github.com/erniebrodeur/ruby-beautify"
|
link: "https://github.com/erniebrodeur/ruby-beautify"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Ruby:
|
Ruby:
|
||||||
|
|
|
@ -11,6 +11,7 @@ versionCheckState = false
|
||||||
module.exports = class Rustfmt extends Beautifier
|
module.exports = class Rustfmt extends Beautifier
|
||||||
name: "rustfmt"
|
name: "rustfmt"
|
||||||
link: "https://github.com/nrc/rustfmt"
|
link: "https://github.com/nrc/rustfmt"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Rust: true
|
Rust: true
|
||||||
|
|
|
@ -4,6 +4,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class SassConvert extends Beautifier
|
module.exports = class SassConvert extends Beautifier
|
||||||
name: "SassConvert"
|
name: "SassConvert"
|
||||||
link: "http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax"
|
link: "http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options:
|
options:
|
||||||
# TODO: Add support for options
|
# TODO: Add support for options
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class Sqlformat extends Beautifier
|
module.exports = class Sqlformat extends Beautifier
|
||||||
name: "sqlformat"
|
name: "sqlformat"
|
||||||
link: "https://github.com/andialbrecht/sqlparse"
|
link: "https://github.com/andialbrecht/sqlparse"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
SQL: true
|
SQL: true
|
||||||
|
|
|
@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
|
||||||
module.exports = class StylishHaskell extends Beautifier
|
module.exports = class StylishHaskell extends Beautifier
|
||||||
name: "stylish-haskell"
|
name: "stylish-haskell"
|
||||||
link: "https://github.com/jaspervdj/stylish-haskell"
|
link: "https://github.com/jaspervdj/stylish-haskell"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Haskell: true
|
Haskell: true
|
||||||
|
|
|
@ -11,6 +11,8 @@ _ = require('lodash')
|
||||||
module.exports = class Uncrustify extends Beautifier
|
module.exports = class Uncrustify extends Beautifier
|
||||||
name: "Uncrustify"
|
name: "Uncrustify"
|
||||||
link: "https://github.com/uncrustify/uncrustify"
|
link: "https://github.com/uncrustify/uncrustify"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Apex: true
|
Apex: true
|
||||||
C: true
|
C: true
|
||||||
|
|
|
@ -5,6 +5,7 @@ _ = require('lodash')
|
||||||
|
|
||||||
module.exports = class VueBeautifier extends Beautifier
|
module.exports = class VueBeautifier extends Beautifier
|
||||||
name: "Vue Beautifier"
|
name: "Vue Beautifier"
|
||||||
|
link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee"
|
||||||
|
|
||||||
options:
|
options:
|
||||||
Vue: true
|
Vue: true
|
||||||
|
|
|
@ -9,6 +9,7 @@ module.exports = class Yapf extends Beautifier
|
||||||
|
|
||||||
name: "yapf"
|
name: "yapf"
|
||||||
link: "https://github.com/google/yapf"
|
link: "https://github.com/google/yapf"
|
||||||
|
isPreInstalled: false
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
Python: false
|
Python: false
|
||||||
|
|
Loading…
Reference in New Issue