diff --git a/README.md b/README.md index ae32105..4c8173f 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ 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/yihui/formatR) (Default) | +| R | `R` |`.r`, `.R` | [`formatR`](https://github.com/yihui/formatR) (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) | | Rust | `Rust` |`.rs`, `.rlib` | [`rustfmt`](https://github.com/nrc/rustfmt) (Default) | diff --git a/docs/options.md b/docs/options.md index 623f7af..9742236 100644 --- a/docs/options.md +++ b/docs/options.md @@ -8242,6 +8242,102 @@ sort imports (requires isort installed) (Supported by autopep8) } ``` +#### [R](#r) + +**Supported Beautifiers**: [`formatR`](#formatr) + +| Option | formatR | +| --- | --- | +| `disabled` | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | +| `indent_size` | :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**: `formatR` + +**Type**: `string` + +**Enum**: `formatR` + +**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. + +##### [Indent size](#indent-size) + +**Namespace**: `r` + +**Key**: `indent_size` + +**Default**: `4` + +**Type**: `integer` + +**Supported Beautifiers**: [`formatR`](#formatr) + +**Description**: + +Indentation size/length (Supported by formatR) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "r": { + "indent_size": 4 + } +} +``` + #### [Riot.js](#riot.js) **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) @@ -16338,6 +16434,35 @@ Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by C ``` +### formatR + +##### [Indent size](#indent-size) + +**Namespace**: `r` + +**Key**: `indent_size` + +**Default**: `4` + +**Type**: `integer` + +**Supported Beautifiers**: [`formatR`](#formatr) + +**Description**: + +Indentation size/length (Supported by formatR) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "r": { + "indent_size": 4 + } +} +``` + + ### rustfmt ##### [Rustfmt path](#rustfmt-path) diff --git a/package.json b/package.json index 5d7528c..187c22a 100644 --- a/package.json +++ b/package.json @@ -270,7 +270,8 @@ "r beautifier", "vue", "vue beautifier", - "sassconvert" + "sassconvert", + "formatr" ], "devDependencies": { "coffeelint": "^1.10.1", @@ -283,4 +284,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} +} \ No newline at end of file diff --git a/src/beautifiers/formatR/r-beautifier.r b/src/beautifiers/formatR/formatR.r similarity index 100% rename from src/beautifiers/formatR/r-beautifier.r rename to src/beautifiers/formatR/formatR.r diff --git a/src/beautifiers/formatR/index.coffee b/src/beautifiers/formatR/index.coffee index 7b7ebb6..7bfcee3 100644 --- a/src/beautifiers/formatR/index.coffee +++ b/src/beautifiers/formatR/index.coffee @@ -7,7 +7,7 @@ path = require("path") Beautifier = require('../beautifier') module.exports = class R extends Beautifier - name: "R beautifier" + name: "formatR" link: "https://github.com/yihui/formatR" options: { @@ -15,7 +15,7 @@ module.exports = class R extends Beautifier } beautify: (text, language, options) -> - r_beautifier = path.resolve(__dirname, "r-beautifier.r") + r_beautifier = path.resolve(__dirname, "formatR.r") @run("Rscript", [ r_beautifier, options.indent_size, diff --git a/src/beautifiers/r-beautifier/index.coffee b/src/beautifiers/r-beautifier/index.coffee deleted file mode 100644 index 3f7b688..0000000 --- a/src/beautifiers/r-beautifier/index.coffee +++ /dev/null @@ -1,25 +0,0 @@ -### -Requires [formatR](https://github.com/yihui/formatR) -### -path = require("path") - -"use strict" -Beautifier = require('../beautifier') - -module.exports = class R extends Beautifier - name: "formatR" - link: "https://github.com/yihui/formatR" - - options: { - R: true - } - - beautify: (text, language, options) -> - r_beautifier = path.resolve(__dirname, "r-beautifier.r") - @run("Rscript", [ - r_beautifier, - options.indent_size, - @tempFile("input", text), - '>', - @tempFile("input", text) - ])