first try adding r to atom-beautify

This commit is contained in:
Sebastian DiLorenzo 2016-08-09 16:06:26 +02:00
parent 06773e35df
commit 1bc8d13f93
8 changed files with 74 additions and 1 deletions

View File

@ -89,6 +89,7 @@ See [all supported options in the documentation at `docs/options.md`](https://g
| Python | `Python` |`.py` | [`autopep8`](https://github.com/hhatto/autopep8) (Default), [`yapf`](https://github.com/google/yapf) |
| 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` | [`R`](https://cran.r-project.org/) (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) |

View File

@ -0,0 +1,16 @@
# 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

View File

@ -94,6 +94,10 @@
{
"name": "Arman Yessenamanov",
"url": "https://github.com/yesenarman"
},
{
"name": "Sebastian DiLorenzo",
"url": "https://github.com/Sebastian-D"
}
],
"engines": {
@ -270,4 +274,4 @@
"lint": "coffeelint src/ spec/",
"code-docs": "codo && open docs/code/index.html"
}
}
}

View File

@ -69,6 +69,7 @@ module.exports = class Beautifiers extends EventEmitter
'yapf'
'erl_tidy'
'marko-beautifier'
'r-beautifier'
]
###

View File

@ -0,0 +1,24 @@
###
Requires [formatR](https://github.com/yihui/formatR)
###
path = require("path")
"use strict"
Beautifier = require('../beautifier')
module.exports = class R extends Beautifier
name: "R beautifier"
link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/r-beautifier/r-beautifier.r"
options: {
R: true
}
beautify: (text, language, options) ->
r_beautifier = path.resolve(__dirname, "r-beautifier.r")
@run("Rscript", [
r_beautifier,
@tempFile("input", text),
'>',
@tempFile("input", text)
])

View File

@ -0,0 +1,3 @@
library(formatR)
file <- commandArgs(trailingOnly = TRUE)[1]
tidy_source(text = readLines(file))

View File

@ -51,6 +51,7 @@ module.exports = class Languages
"php"
"puppet"
"python"
"r"
"riotjs"
"ruby"
"rust"

23
src/languages/r.coffee Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
name: "R"
namespace: "r"
###
Supported Grammars
###
grammars: [
"R"
]
###
Supported extensions
###
extensions: [
"r"
"R"
]
options: []
}