Closes #192. Add coffee-fmt beautifier for CoffeeScript language
This commit is contained in:
parent
319ea8b558
commit
1fd94e871b
|
@ -1,2 +1,2 @@
|
|||
value %%= 4000
|
||||
value != true
|
||||
value isnt true
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
hello derek how is it going?
|
||||
for c, i in "Hello World!"
|
||||
k = 1 + 1 - 2 >= 3 <= 4 > 5 < 6
|
||||
|
||||
for c, i in "Hello World"
|
||||
k = (a, b) -> if b? return a
|
||||
|
||||
k = (a, b) -> if b? then return a
|
||||
f = b()[0]
|
||||
for c, i in "Hello World"
|
||||
f(b())
|
||||
|
|
|
@ -3,7 +3,7 @@ for c, i in "Hello World!"
|
|||
k = 1+1- 2>=3<= 4>5 <6
|
||||
|
||||
for c, i in "Hello World"
|
||||
k = (a,b)-> if b? return a
|
||||
k = (a,b)-> if b? then return a
|
||||
|
||||
f = b()[0]
|
||||
for c, i in "Hello World"
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
"atom-message-panel": "^1.1.1",
|
||||
"atom-space-pen-views": "^2.0.3",
|
||||
"bluebird": "^2.9.25",
|
||||
"coffee-fmt": "^0.7.0",
|
||||
"coffee-formatter": "^0.1.2",
|
||||
"csscomb": "^3.0.4",
|
||||
"diff": "^1.3.2",
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class PrettyDiff extends Beautifier
|
||||
name: "coffee-fmt"
|
||||
|
||||
options: {
|
||||
# Apply language-specific options
|
||||
CoffeeScript:
|
||||
tab: ["indent_size", "indent_char", "indent_with_tabs", (indentSize, indentChar, indentWithTabs) ->
|
||||
return "\t" if indentWithTabs
|
||||
Array(indentSize+1).join(indentChar)
|
||||
]
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
return new @Promise((resolve, reject) ->
|
||||
# Add newLine option
|
||||
options.newLine = "\n"
|
||||
# Require
|
||||
fmt = require('coffee-fmt')
|
||||
# Format!
|
||||
results = fmt.format(text, options)
|
||||
# Return beautified CoffeeScript code
|
||||
resolve(results)
|
||||
)
|
|
@ -34,6 +34,7 @@ module.exports = class Beautifiers
|
|||
'uncrustify'
|
||||
'autopep8'
|
||||
'coffee-formatter'
|
||||
'coffee-fmt'
|
||||
'htmlbeautifier'
|
||||
'csscomb'
|
||||
'gofmt'
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
"use strict"
|
||||
prettydiff = require("prettydiff")
|
||||
Beautifier = require('./beautifier')
|
||||
_ = require('lodash')
|
||||
|
||||
module.exports = class PrettyDiff extends Beautifier
|
||||
name: "Pretty Diff"
|
||||
|
@ -36,6 +34,8 @@ module.exports = class PrettyDiff extends Beautifier
|
|||
beautify: (text, language, options) ->
|
||||
|
||||
return new @Promise((resolve, reject) ->
|
||||
prettydiff = require("prettydiff")
|
||||
_ = require('lodash')
|
||||
|
||||
# Select Prettydiff language
|
||||
lang = "auto"
|
||||
|
|
|
@ -18,4 +18,6 @@ module.exports = {
|
|||
"coffee"
|
||||
]
|
||||
|
||||
defaultBeautifier: "coffee-fmt"
|
||||
|
||||
}
|
Loading…
Reference in New Issue