From 2c6d6b613b1cff63645fb125c240e5c2a8a42d4e Mon Sep 17 00:00:00 2001 From: Sebastian DiLorenzo Date: Wed, 10 Aug 2016 15:00:38 +0200 Subject: [PATCH] afaik a working version of atom-beautify with r language implemented! Includes examples --- README.md | 6 +- docs/options.md | 622 +++++++++++++----- .../nested-jsbeautifyrc/r/expected/test.r | 20 + package.json | 5 +- 4 files changed, 480 insertions(+), 173 deletions(-) create mode 100644 examples/nested-jsbeautifyrc/r/expected/test.r diff --git a/README.md b/README.md index 3a39ed6..fe4107f 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ See [all supported options in the documentation at `docs/options.md`](https://g | 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) | | Erlang | `Erlang` |`.erl` | [`erl_tidy`](http://erlang.org/doc/man/erl_tidy.html) (Default) | -| Fortran | `Fortran - Modern` |`.f90` | [`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` | [`Fortran Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/fortran-beautifier/emacs-fortran-formating-script.lisp) (Default) | | gherkin | `Gherkin` |`.feature` | [`Gherkin formatter`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee) (Default) | | Go | `Go` |`.go` | [`gofmt`](https://golang.org/cmd/gofmt/) (Default) | | Handlebars | `Handlebars`, `HTML (Handlebars)` |`.hbs`, `.handlebars` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | @@ -87,9 +87,9 @@ See [all supported options in the documentation at `docs/options.md`](https://g | PHP | `PHP` |`.php`, `.module`, `.inc` | [`PHP-CS-Fixer`](http://php.net/manual/en/install.php) (Default), [`PHPCBF`](http://php.net/manual/en/install.php) | | Puppet | `Puppet` |`.pp` | [`puppet-lint`](http://puppet-lint.com/) (Default) | | Python | `Python` |`.py` | [`autopep8`](https://github.com/hhatto/autopep8) (Default), [`yapf`](https://github.com/google/yapf) | +| R | `R` |`.r`, `.R` | [`R beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/r-beautifier/r-beautifier.r) (Default) | | Riot.js | `Riot.js`, `HTML (Riot Tag)` |`.tag` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Ruby | `Ruby`, `Ruby on Rails` |`.rb` | [`Rubocop`](https://github.com/bbatsov/rubocop) (Default), [`Ruby Beautify`](https://github.com/erniebrodeur/ruby-beautify) | -| R | `R` |`.r` | [`formatR`](https://github.com/yihui/formatR) (Default) | | Rust | `Rust` |`.rs`, `.rlib` | [`rustfmt`](https://github.com/nrc/rustfmt) (Default) | | Sass | `Sass` |`.sass` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | SCSS | `SCSS` |`.scss` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | @@ -102,7 +102,7 @@ See [all supported options in the documentation at `docs/options.md`](https://g | TypeScript | `TypeScript` |`.ts` | [`TypeScript Formatter`](https://github.com/vvakame/typescript-formatter) (Default) | | Vala | `Vala` |`.vala`, `.vapi` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | | Visualforce | `Visualforce` |`.page` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | -| XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp` | [`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` | [`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) | ## Usage diff --git a/docs/options.md b/docs/options.md index 7fa34f9..7729cdc 100644 --- a/docs/options.md +++ b/docs/options.md @@ -3232,7 +3232,7 @@ Preserve line-breaks (Supported by JS Beautify, Pretty Diff) **Key**: `unformatted` -**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6` +**Default**: `a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,keygen,label,map,mark,math,meter,noscript,object,output,progress,q,ruby,s,samp,select,small,span,strong,sub,sup,svg,template,textarea,time,u,var,video,wbr,text,acronym,address,big,dt,ins,small,strike,tt,pre,h1,h2,h3,h4,h5,h6` **Type**: `array` @@ -3249,36 +3249,67 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J "html": { "unformatted": [ "a", - "span", - "img", - "bdo", - "em", - "strong", - "dfn", - "code", - "samp", - "kbd", - "var", - "cite", "abbr", - "acronym", + "area", + "audio", + "b", + "bdi", + "bdo", + "br", + "button", + "canvas", + "cite", + "code", + "data", + "datalist", + "del", + "dfn", + "em", + "embed", + "i", + "iframe", + "img", + "input", + "ins", + "kbd", + "keygen", + "label", + "map", + "mark", + "math", + "meter", + "noscript", + "object", + "output", + "progress", "q", + "ruby", + "s", + "samp", + "select", + "small", + "span", + "strong", "sub", "sup", - "tt", - "i", - "b", - "big", - "small", + "svg", + "template", + "textarea", + "time", "u", - "s", - "strike", - "font", - "ins", - "del", - "pre", + "var", + "video", + "wbr", + "text", + "acronym", "address", + "big", "dt", + "ins", + "small", + "strike", + "tt", + "pre", "h1", "h2", "h3", @@ -3765,7 +3796,7 @@ Preserve line-breaks (Supported by JS Beautify, Pretty Diff) **Key**: `unformatted` -**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6` +**Default**: `a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,keygen,label,map,mark,math,meter,noscript,object,output,progress,q,ruby,s,samp,select,small,span,strong,sub,sup,svg,template,textarea,time,u,var,video,wbr,text,acronym,address,big,dt,ins,small,strike,tt,pre,h1,h2,h3,h4,h5,h6` **Type**: `array` @@ -3782,36 +3813,67 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J "html": { "unformatted": [ "a", - "span", - "img", - "bdo", - "em", - "strong", - "dfn", - "code", - "samp", - "kbd", - "var", - "cite", "abbr", - "acronym", + "area", + "audio", + "b", + "bdi", + "bdo", + "br", + "button", + "canvas", + "cite", + "code", + "data", + "datalist", + "del", + "dfn", + "em", + "embed", + "i", + "iframe", + "img", + "input", + "ins", + "kbd", + "keygen", + "label", + "map", + "mark", + "math", + "meter", + "noscript", + "object", + "output", + "progress", "q", + "ruby", + "s", + "samp", + "select", + "small", + "span", + "strong", "sub", "sup", - "tt", - "i", - "b", - "big", - "small", + "svg", + "template", + "textarea", + "time", "u", - "s", - "strike", - "font", - "ins", - "del", - "pre", + "var", + "video", + "wbr", + "text", + "acronym", "address", + "big", "dt", + "ins", + "small", + "strike", + "tt", + "pre", "h1", "h2", "h3", @@ -6725,7 +6787,7 @@ Preserve line-breaks (Supported by Marko Beautifier) **Key**: `unformatted` -**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6` +**Default**: `a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,keygen,label,map,mark,math,meter,noscript,object,output,progress,q,ruby,s,samp,select,small,span,strong,sub,sup,svg,template,textarea,time,u,var,video,wbr,text,acronym,address,big,dt,ins,small,strike,tt,pre,h1,h2,h3,h4,h5,h6` **Type**: `array` @@ -6742,36 +6804,67 @@ List of tags (defaults to inline) that should not be reformatted (Supported by M "html": { "unformatted": [ "a", - "span", - "img", - "bdo", - "em", - "strong", - "dfn", - "code", - "samp", - "kbd", - "var", - "cite", "abbr", - "acronym", + "area", + "audio", + "b", + "bdi", + "bdo", + "br", + "button", + "canvas", + "cite", + "code", + "data", + "datalist", + "del", + "dfn", + "em", + "embed", + "i", + "iframe", + "img", + "input", + "ins", + "kbd", + "keygen", + "label", + "map", + "mark", + "math", + "meter", + "noscript", + "object", + "output", + "progress", "q", + "ruby", + "s", + "samp", + "select", + "small", + "span", + "strong", "sub", "sup", - "tt", - "i", - "b", - "big", - "small", + "svg", + "template", + "textarea", + "time", "u", - "s", - "strike", - "font", - "ins", - "del", - "pre", + "var", + "video", + "wbr", + "text", + "acronym", "address", + "big", "dt", + "ins", + "small", + "strike", + "tt", + "pre", "h1", "h2", "h3", @@ -7189,7 +7282,7 @@ Preserve line-breaks (Supported by JS Beautify) **Key**: `unformatted` -**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6` +**Default**: `a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,keygen,label,map,mark,math,meter,noscript,object,output,progress,q,ruby,s,samp,select,small,span,strong,sub,sup,svg,template,textarea,time,u,var,video,wbr,text,acronym,address,big,dt,ins,small,strike,tt,pre,h1,h2,h3,h4,h5,h6` **Type**: `array` @@ -7206,36 +7299,67 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J "html": { "unformatted": [ "a", - "span", - "img", - "bdo", - "em", - "strong", - "dfn", - "code", - "samp", - "kbd", - "var", - "cite", "abbr", - "acronym", + "area", + "audio", + "b", + "bdi", + "bdo", + "br", + "button", + "canvas", + "cite", + "code", + "data", + "datalist", + "del", + "dfn", + "em", + "embed", + "i", + "iframe", + "img", + "input", + "ins", + "kbd", + "keygen", + "label", + "map", + "mark", + "math", + "meter", + "noscript", + "object", + "output", + "progress", "q", + "ruby", + "s", + "samp", + "select", + "small", + "span", + "strong", "sub", "sup", - "tt", - "i", - "b", - "big", - "small", + "svg", + "template", + "textarea", + "time", "u", - "s", - "strike", - "font", - "ins", - "del", - "pre", + "var", + "video", + "wbr", + "text", + "acronym", "address", + "big", "dt", + "ins", + "small", + "strike", + "tt", + "pre", "h1", "h2", "h3", @@ -8118,6 +8242,75 @@ sort imports (requires isort installed) (Supported by autopep8) } ``` +#### [R](#r) + +**Supported Beautifiers**: [`R beautifier`](#r-beautifier) + +| Option | R beautifier | +| --- | --- | +| `disabled` | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | + +**Description**: + +Options for language R + +##### [Disable Beautifying Language](#disable-beautifying-language) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Disable R 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 "*Disable Beautifying Language*" and change it to your desired configuration. + +##### [Default Beautifier](#default-beautifier) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Default**: `R beautifier` + +**Type**: `string` + +**Enum**: `R beautifier` + +**Description**: + +Default Beautifier to be used for R + +**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 "*Default Beautifier*" and change it to your desired configuration. + +##### [Beautify On Save](#beautify-on-save) + +**Important**: This option is only configurable from within Atom Beautify's setting panel. + +**Type**: `boolean` + +**Description**: + +Automatically beautify R 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 "*Beautify On Save*" and change it to your desired configuration. + #### [Riot.js](#riot.js) **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) @@ -11757,7 +11950,7 @@ Preserve line-breaks (Supported by JS Beautify, Pretty Diff) **Key**: `unformatted` -**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6` +**Default**: `a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,keygen,label,map,mark,math,meter,noscript,object,output,progress,q,ruby,s,samp,select,small,span,strong,sub,sup,svg,template,textarea,time,u,var,video,wbr,text,acronym,address,big,dt,ins,small,strike,tt,pre,h1,h2,h3,h4,h5,h6` **Type**: `array` @@ -11774,36 +11967,67 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J "html": { "unformatted": [ "a", - "span", - "img", - "bdo", - "em", - "strong", - "dfn", - "code", - "samp", - "kbd", - "var", - "cite", "abbr", - "acronym", + "area", + "audio", + "b", + "bdi", + "bdo", + "br", + "button", + "canvas", + "cite", + "code", + "data", + "datalist", + "del", + "dfn", + "em", + "embed", + "i", + "iframe", + "img", + "input", + "ins", + "kbd", + "keygen", + "label", + "map", + "mark", + "math", + "meter", + "noscript", + "object", + "output", + "progress", "q", + "ruby", + "s", + "samp", + "select", + "small", + "span", + "strong", "sub", "sup", - "tt", - "i", - "b", - "big", - "small", + "svg", + "template", + "textarea", + "time", "u", - "s", - "strike", - "font", - "ins", - "del", - "pre", + "var", + "video", + "wbr", + "text", + "acronym", "address", + "big", "dt", + "ins", + "small", + "strike", + "tt", + "pre", "h1", "h2", "h3", @@ -13088,7 +13312,7 @@ Number of line-breaks to be preserved in one chunk (Supported by JS Beautify) **Key**: `unformatted` -**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6` +**Default**: `a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,keygen,label,map,mark,math,meter,noscript,object,output,progress,q,ruby,s,samp,select,small,span,strong,sub,sup,svg,template,textarea,time,u,var,video,wbr,text,acronym,address,big,dt,ins,small,strike,tt,pre,h1,h2,h3,h4,h5,h6` **Type**: `array` @@ -13105,36 +13329,67 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J "html": { "unformatted": [ "a", - "span", - "img", - "bdo", - "em", - "strong", - "dfn", - "code", - "samp", - "kbd", - "var", - "cite", "abbr", - "acronym", + "area", + "audio", + "b", + "bdi", + "bdo", + "br", + "button", + "canvas", + "cite", + "code", + "data", + "datalist", + "del", + "dfn", + "em", + "embed", + "i", + "iframe", + "img", + "input", + "ins", + "kbd", + "keygen", + "label", + "map", + "mark", + "math", + "meter", + "noscript", + "object", + "output", + "progress", "q", + "ruby", + "s", + "samp", + "select", + "small", + "span", + "strong", "sub", "sup", - "tt", - "i", - "b", - "big", - "small", + "svg", + "template", + "textarea", + "time", "u", - "s", - "strike", - "font", - "ins", - "del", - "pre", + "var", + "video", + "wbr", + "text", + "acronym", "address", + "big", "dt", + "ins", + "small", + "strike", + "tt", + "pre", "h1", "h2", "h3", @@ -13951,7 +14206,7 @@ Number of line-breaks to be preserved in one chunk (Supported by Marko Beautifie **Key**: `unformatted` -**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6` +**Default**: `a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,keygen,label,map,mark,math,meter,noscript,object,output,progress,q,ruby,s,samp,select,small,span,strong,sub,sup,svg,template,textarea,time,u,var,video,wbr,text,acronym,address,big,dt,ins,small,strike,tt,pre,h1,h2,h3,h4,h5,h6` **Type**: `array` @@ -13968,36 +14223,67 @@ List of tags (defaults to inline) that should not be reformatted (Supported by M "html": { "unformatted": [ "a", - "span", - "img", - "bdo", - "em", - "strong", - "dfn", - "code", - "samp", - "kbd", - "var", - "cite", "abbr", - "acronym", + "area", + "audio", + "b", + "bdi", + "bdo", + "br", + "button", + "canvas", + "cite", + "code", + "data", + "datalist", + "del", + "dfn", + "em", + "embed", + "i", + "iframe", + "img", + "input", + "ins", + "kbd", + "keygen", + "label", + "map", + "mark", + "math", + "meter", + "noscript", + "object", + "output", + "progress", "q", + "ruby", + "s", + "samp", + "select", + "small", + "span", + "strong", "sub", "sup", - "tt", - "i", - "b", - "big", - "small", + "svg", + "template", + "textarea", + "time", "u", - "s", - "strike", - "font", - "ins", - "del", - "pre", + "var", + "video", + "wbr", + "text", + "acronym", "address", + "big", "dt", + "ins", + "small", + "strike", + "tt", + "pre", "h1", "h2", "h3", diff --git a/examples/nested-jsbeautifyrc/r/expected/test.r b/examples/nested-jsbeautifyrc/r/expected/test.r new file mode 100644 index 0000000..f9a08b8 --- /dev/null +++ b/examples/nested-jsbeautifyrc/r/expected/test.r @@ -0,0 +1,20 @@ +# a single line of comments is preserved +1 + 1 + +if (TRUE) { + x = 1 # inline comments +} else { + x = 2 + print("Oh no... ask the right bracket to go away!") +} +1 * 3 # one space before this comment will become two! +2 + 2 + 2 # 'short comments' + +# only 'single quotes' are allowed in comments +df = data.frame(y = rnorm(100), x1 = rnorm(100), x2 = rnorm(100)) +lm(y ~ x1 + x2, data = df) +1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + 1 + 1 ## comments after a long line + +## here is a long long long long long long long long long long long long long long +## long long long long long long comment diff --git a/package.json b/package.json index 1680102..c742745 100644 --- a/package.json +++ b/package.json @@ -262,7 +262,8 @@ "typescript formatter", "yapf", "erl_tidy", - "marko beautifier" + "marko beautifier", + "r beautifier" ], "devDependencies": { "coffeelint": "^1.10.1", @@ -275,4 +276,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file