Format all internal CoffeeScript code to indent_size=2

- Using Atom Beautify's Beautify Directory feature
- Using coffee-fmt
  - Only has one bug: https://github.com/sterpe/coffee-fmt/issues/16
This commit is contained in:
Glavin Wiechert 2015-06-11 21:59:00 -03:00
parent 72e4384cf8
commit b0d8dfa6fb
70 changed files with 2996 additions and 2848 deletions

View File

@ -1,7 +1,7 @@
{ {
"indentation" : { "indentation" : {
"level" : "error", "level" : "error",
"value" : 4 "value" : 2
}, },
"line_endings" : { "line_endings" : {
"value" : "unix", "value" : "unix",

View File

@ -144,10 +144,12 @@
], ],
"devDependencies": { "devDependencies": {
"coffee-script": "^1.9.3", "coffee-script": "^1.9.3",
"coffeelint": "^1.10.1",
"handlebars": "^3.0.3" "handlebars": "^3.0.3"
}, },
"scripts": { "scripts": {
"prepublish": "npm run docs", "prepublish": "npm run docs",
"docs": "coffee docs/" "docs": "coffee docs/",
"lint": "coffeelint src/"
} }
} }

View File

@ -9,171 +9,171 @@ Beautifier = require "../src/beautifiers/beautifier"
describe "Atom-Beautify", -> describe "Atom-Beautify", ->
beforeEach -> beforeEach ->
# Activate package # Activate package
waitsForPromise -> waitsForPromise ->
activationPromise = atom.packages.activatePackage('atom-beautify') activationPromise = atom.packages.activatePackage('atom-beautify')
# Force activate package # Force activate package
pack = atom.packages.getLoadedPackage("atom-beautify") pack = atom.packages.getLoadedPackage("atom-beautify")
pack.activateNow() pack.activateNow()
# Change logger level # Change logger level
# atom.config.set('atom-beautify._loggerLevel', 'verbose') # atom.config.set('atom-beautify._loggerLevel', 'verbose')
# Return promise # Return promise
return activationPromise return activationPromise
describe "Beautifiers", -> describe "Beautifiers", ->
describe "Beautifier::run", -> describe "Beautifier::run", ->
beautifier = null beautifier = null
beforeEach -> beforeEach ->
beautifier = new Beautifier() beautifier = new Beautifier()
it "should error when beautifier's program not found", -> it "should error when beautifier's program not found", ->
expect(beautifier).not.toBe(null) expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true) expect(beautifier instanceof Beautifier).toBe(true)
# waitsForRuns = (fn, message, timeout) -> # waitsForRuns = (fn, message, timeout) ->
# isCompleted = false # isCompleted = false
# completed = -> # completed = ->
# console.log('completed') # console.log('completed')
# isCompleted = true # isCompleted = true
# runs -> # runs ->
# console.log('runs') # console.log('runs')
# fn(completed) # fn(completed)
# waitsFor(-> # waitsFor(->
# console.log('waitsFor', isCompleted) # console.log('waitsFor', isCompleted)
# isCompleted # isCompleted
# , message, timeout) # , message, timeout)
# #
# waitsForRuns((cb) -> # waitsForRuns((cb) ->
# console.log('waitsForRuns', cb) # console.log('waitsForRuns', cb)
# setTimeout(cb, 2000) # setTimeout(cb, 2000)
# , "Waiting for beautification to complete", 5000) # , "Waiting for beautification to complete", 5000)
waitsForPromise shouldReject: true, -> waitsForPromise shouldReject: true, ->
p = beautifier.run("program", []) p = beautifier.run("program", [])
expect(p).not.toBe(null) expect(p).not.toBe(null)
expect(p instanceof beautifier.Promise).toBe(true) expect(p instanceof beautifier.Promise).toBe(true)
cb = (v) -> cb = (v) ->
# console.log(v) # console.log(v)
expect(v).not.toBe(null) expect(v).not.toBe(null)
expect(v instanceof Error).toBe(true) expect(v instanceof Error).toBe(true)
expect(v.code).toBe("CommandNotFound") expect(v.code).toBe("CommandNotFound")
expect(v.description).toBe(undefined, \ expect(v.description).toBe(undefined, \
'Error should not have a description.') 'Error should not have a description.')
return v return v
p.then(cb, cb) p.then(cb, cb)
return p return p
it "should error with help description \ it "should error with help description \
when beautifier's program not found", -> when beautifier's program not found", ->
expect(beautifier).not.toBe(null) expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true) expect(beautifier instanceof Beautifier).toBe(true)
waitsForPromise shouldReject: true, -> waitsForPromise shouldReject: true, ->
help = { help = {
link: "http://test.com" link: "http://test.com"
program: "test-program" program: "test-program"
pathOption: "Lang - Test Program Path" pathOption: "Lang - Test Program Path"
} }
p = beautifier.run("program", [], help: help) p = beautifier.run("program", [], help: help)
expect(p).not.toBe(null) expect(p).not.toBe(null)
expect(p instanceof beautifier.Promise).toBe(true) expect(p instanceof beautifier.Promise).toBe(true)
cb = (v) -> cb = (v) ->
# console.log(v) # console.log(v)
expect(v).not.toBe(null) expect(v).not.toBe(null)
expect(v instanceof Error).toBe(true) expect(v instanceof Error).toBe(true)
expect(v.code).toBe("CommandNotFound") expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null) expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1) expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1) expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description expect(v.description
.indexOf(help.pathOption)).not.toBe(-1, \ .indexOf(help.pathOption)).not.toBe(-1, \
"Error should have a description.") "Error should have a description.")
return v return v
p.then(cb, cb) p.then(cb, cb)
return p return p
it "should error with Windows-specific help description \ it "should error with Windows-specific help description \
when beautifier's program not found", -> when beautifier's program not found", ->
expect(beautifier).not.toBe(null) expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true) expect(beautifier instanceof Beautifier).toBe(true)
waitsForPromise shouldReject: true, -> waitsForPromise shouldReject: true, ->
help = { help = {
link: "http://test.com" link: "http://test.com"
program: "test-program" program: "test-program"
pathOption: "Lang - Test Program Path" pathOption: "Lang - Test Program Path"
} }
# Force to be Windows # Force to be Windows
beautifier.isWindows = true beautifier.isWindows = true
terminal = 'CMD prompt' terminal = 'CMD prompt'
whichCmd = "where.exe" whichCmd = "where.exe"
# Process # Process
p = beautifier.run("program", [], help: help) p = beautifier.run("program", [], help: help)
expect(p).not.toBe(null) expect(p).not.toBe(null)
expect(p instanceof beautifier.Promise).toBe(true) expect(p instanceof beautifier.Promise).toBe(true)
cb = (v) -> cb = (v) ->
# console.log(v) # console.log(v)
expect(v).not.toBe(null) expect(v).not.toBe(null)
expect(v instanceof Error).toBe(true) expect(v instanceof Error).toBe(true)
expect(v.code).toBe("CommandNotFound") expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null) expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1) expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1) expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description expect(v.description
.indexOf(help.pathOption)).not.toBe(-1, \ .indexOf(help.pathOption)).not.toBe(-1, \
"Error should have a description.") "Error should have a description.")
expect(v.description expect(v.description
.indexOf(terminal)).not.toBe(-1, \ .indexOf(terminal)).not.toBe(-1, \
"Error should have a description including \ "Error should have a description including \
'#{terminal}' in message.") '#{terminal}' in message.")
expect(v.description expect(v.description
.indexOf(whichCmd)).not.toBe(-1, \ .indexOf(whichCmd)).not.toBe(-1, \
"Error should have a description including \ "Error should have a description including \
'#{whichCmd}' in message.") '#{whichCmd}' in message.")
return v return v
p.then(cb, cb) p.then(cb, cb)
return p return p
it "should error with Mac/Linux-specific help description \ it "should error with Mac/Linux-specific help description \
when beautifier's program not found", -> when beautifier's program not found", ->
expect(beautifier).not.toBe(null) expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true) expect(beautifier instanceof Beautifier).toBe(true)
waitsForPromise shouldReject: true, -> waitsForPromise shouldReject: true, ->
help = { help = {
link: "http://test.com" link: "http://test.com"
program: "test-program" program: "test-program"
pathOption: "Lang - Test Program Path" pathOption: "Lang - Test Program Path"
} }
# Force to be Mac/Linux (not Windows) # Force to be Mac/Linux (not Windows)
beautifier.isWindows = false beautifier.isWindows = false
terminal = "Terminal" terminal = "Terminal"
whichCmd = "which" whichCmd = "which"
# Process # Process
p = beautifier.run("program", [], help: help) p = beautifier.run("program", [], help: help)
expect(p).not.toBe(null) expect(p).not.toBe(null)
expect(p instanceof beautifier.Promise).toBe(true) expect(p instanceof beautifier.Promise).toBe(true)
cb = (v) -> cb = (v) ->
# console.log(v) # console.log(v)
expect(v).not.toBe(null) expect(v).not.toBe(null)
expect(v instanceof Error).toBe(true) expect(v instanceof Error).toBe(true)
expect(v.code).toBe("CommandNotFound") expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null) expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1) expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1) expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description expect(v.description
.indexOf(terminal)).not.toBe(-1, \ .indexOf(terminal)).not.toBe(-1, \
"Error should have a description including \ "Error should have a description including \
'#{terminal}' in message.") '#{terminal}' in message.")
expect(v.description expect(v.description
.indexOf(whichCmd)).not.toBe(-1, \ .indexOf(whichCmd)).not.toBe(-1, \
"Error should have a description including \ "Error should have a description including \
'#{whichCmd}' in message.") '#{whichCmd}' in message.")
return v return v
p.then(cb, cb) p.then(cb, cb)
return p return p

View File

@ -9,128 +9,128 @@ path = require 'path'
describe "PHP-CS-Fixer Beautifier", -> describe "PHP-CS-Fixer Beautifier", ->
beforeEach ->
# Activate package
waitsForPromise ->
activationPromise = atom.packages.activatePackage('atom-beautify')
# Force activate package
pack = atom.packages.getLoadedPackage("atom-beautify")
pack.activateNow()
# Change logger level
# atom.config.set('atom-beautify._loggerLevel', 'verbose')
# Return promise
return activationPromise
describe "Beautifier::beautify", ->
beautifier = null
beforeEach -> beforeEach ->
beautifier = new PHPCSFixer()
# console.log('new beautifier')
# Activate package OSSpecificSpecs = ->
waitsForPromise -> text = "<?php echo \"test\"; ?>"
activationPromise = atom.packages.activatePackage('atom-beautify')
# Force activate package
pack = atom.packages.getLoadedPackage("atom-beautify")
pack.activateNow()
# Change logger level
# atom.config.set('atom-beautify._loggerLevel', 'verbose')
# Return promise
return activationPromise
describe "Beautifier::beautify", -> it "should error when beautifier's program not found", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
beautifier = null waitsForPromise shouldReject: true, ->
language = "PHP"
options = {
fixers: ""
levels: ""
}
# Mock PATH
beautifier.getShellEnvironment = -> Promise.resolve({
PATH: ''
})
#
p = beautifier.beautify(text, language, options)
expect(p).not.toBe(null)
expect(p instanceof beautifier.Promise).toBe(true)
cb = (v) ->
# console.log(v)
expect(v).not.toBe(null)
expect(v instanceof Error).toBe(true, \
"Expected '#{v}' to be instance of Error")
expect(v.code).toBe("CommandNotFound", \
"Expected to be CommandNotFound")
return v
p.then(cb, cb)
return p
beforeEach -> failWhichProgram = (failingProgram) ->
beautifier = new PHPCSFixer() it "should error when '#{failingProgram}' not found", ->
# console.log('new beautifier') expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
OSSpecificSpecs = -> if not beautifier.isWindows and failingProgram is "php"
text = "<?php echo \"test\"; ?>" # Only applicable on Windows
return
it "should error when beautifier's program not found", -> waitsForPromise shouldReject: true, ->
expect(beautifier).not.toBe(null) language = "PHP"
expect(beautifier instanceof Beautifier).toBe(true) options = {
fixers: ""
levels: ""
}
cb = (v) ->
# console.log('cb value', v)
expect(v).not.toBe(null)
expect(v instanceof Error).toBe(true, \
"Expected '#{v}' to be instance of Error")
expect(v.code).toBe("CommandNotFound", \
"Expected to be CommandNotFound")
expect(v.file).toBe(failingProgram)
return v
# which = beautifier.which.bind(beautifier)
beautifier.which = (exe, options) ->
return beautifier.Promise.resolve(null) \
if not exe?
if exe is failingProgram
beautifier.Promise.resolve(failingProgram)
else
# which(exe, options)
# console.log('fake exe path', exe)
beautifier.Promise.resolve("/#{exe}")
waitsForPromise shouldReject: true, -> oldSpawn = beautifier.spawn.bind(beautifier)
language = "PHP" beautifier.spawn = (exe, args, options) ->
options = { # console.log('spawn', exe, args, options)
fixers: "" if exe is failingProgram
levels: "" er = new Error('ENOENT')
} er.code = 'ENOENT'
# Mock PATH return beautifier.Promise.reject(er)
beautifier.getShellEnvironment = -> Promise.resolve({ else
PATH: '' return beautifier.Promise.resolve({
}) returnCode: 0,
# stdout: 'stdout',
p = beautifier.beautify(text, language, options) stderr: ''
expect(p).not.toBe(null) })
expect(p instanceof beautifier.Promise).toBe(true) p = beautifier.beautify(text, language, options)
cb = (v) -> expect(p).not.toBe(null)
# console.log(v) expect(p instanceof beautifier.Promise).toBe(true)
expect(v).not.toBe(null) p.then(cb, cb)
expect(v instanceof Error).toBe(true, \ return p
"Expected '#{v}' to be instance of Error")
expect(v.code).toBe("CommandNotFound", \
"Expected to be CommandNotFound")
return v
p.then(cb, cb)
return p
failWhichProgram = (failingProgram) -> failWhichProgram('php')
it "should error when '#{failingProgram}' not found", -> failWhichProgram('php-cs-fixer')
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
if not beautifier.isWindows and failingProgram is "php" describe "Mac/Linux", ->
# Only applicable on Windows
return
waitsForPromise shouldReject: true, -> beforeEach ->
language = "PHP" # console.log('mac/linx')
options = { beautifier.isWindows = false
fixers: ""
levels: ""
}
cb = (v) ->
# console.log('cb value', v)
expect(v).not.toBe(null)
expect(v instanceof Error).toBe(true, \
"Expected '#{v}' to be instance of Error")
expect(v.code).toBe("CommandNotFound", \
"Expected to be CommandNotFound")
expect(v.file).toBe(failingProgram)
return v
# which = beautifier.which.bind(beautifier)
beautifier.which = (exe, options) ->
return beautifier.Promise.resolve(null) \
if not exe?
if exe is failingProgram
beautifier.Promise.resolve(failingProgram)
else
# which(exe, options)
# console.log('fake exe path', exe)
beautifier.Promise.resolve("/#{exe}")
oldSpawn = beautifier.spawn.bind(beautifier) do OSSpecificSpecs
beautifier.spawn = (exe, args, options) ->
# console.log('spawn', exe, args, options)
if exe is failingProgram
er = new Error('ENOENT')
er.code = 'ENOENT'
return beautifier.Promise.reject(er)
else
return beautifier.Promise.resolve({
returnCode: 0,
stdout: 'stdout',
stderr: ''
})
p = beautifier.beautify(text, language, options)
expect(p).not.toBe(null)
expect(p instanceof beautifier.Promise).toBe(true)
p.then(cb, cb)
return p
failWhichProgram('php') describe "Windows", ->
failWhichProgram('php-cs-fixer')
describe "Mac/Linux", -> beforeEach ->
# console.log('windows')
beautifier.isWindows = true
beforeEach -> do OSSpecificSpecs
# console.log('mac/linx')
beautifier.isWindows = false
do OSSpecificSpecs
describe "Windows", ->
beforeEach ->
# console.log('windows')
beautifier.isWindows = true
do OSSpecificSpecs

View File

@ -25,8 +25,8 @@ describe "BeautifyLanguages", ->
] ]
# All Atom packages that Atom Beautify is dependent on # All Atom packages that Atom Beautify is dependent on
dependentPackages = [ dependentPackages = [
'autocomplete-plus' 'autocomplete-plus'
'linter' # 'linter'
# 'atom-typescript' # it logs too much... # 'atom-typescript' # it logs too much...
] ]
# Add language packages to dependentPackages # Add language packages to dependentPackages
@ -43,28 +43,28 @@ describe "BeautifyLanguages", ->
# Activate package # Activate package
waitsForPromise -> waitsForPromise ->
activationPromise = atom.packages.activatePackage('atom-beautify') activationPromise = atom.packages.activatePackage('atom-beautify')
# Force activate package # Force activate package
pack = atom.packages.getLoadedPackage("atom-beautify") pack = atom.packages.getLoadedPackage("atom-beautify")
pack.activateNow() pack.activateNow()
# Check if Windows # Check if Windows
isWindows = process.platform is 'win32' or isWindows = process.platform is 'win32' or
process.env.OSTYPE is 'cygwin' or process.env.OSTYPE is 'cygwin' or
process.env.OSTYPE is 'msys' process.env.OSTYPE is 'msys'
# Need more debugging on Windows # Need more debugging on Windows
if isWindows if isWindows
# Change logger level # Change logger level
atom.config.set('atom-beautify._loggerLevel', 'verbose') atom.config.set('atom-beautify._loggerLevel', 'verbose')
# Return promise # Return promise
return activationPromise return activationPromise
# Set Uncrustify config path # Set Uncrustify config path
# uncrustifyConfigPath = path.resolve(__dirname, "../examples/nested-jsbeautifyrc/uncrustify.cfg") # uncrustifyConfigPath = path.resolve(__dirname, "../examples/nested-jsbeautifyrc/uncrustify.cfg")
# uncrustifyLangs = ["c", "cpp", "objectivec", "cs", "d", "java", "pawn", "vala"] # uncrustifyLangs = ["c", "cpp", "objectivec", "cs", "d", "java", "pawn", "vala"]
# for lang in uncrustifyLangs # for lang in uncrustifyLangs
# do (lang) -> # do (lang) ->
# atom.config.set("atom-beautify.#{lang}_configPath", uncrustifyConfigPath) # atom.config.set("atom-beautify.#{lang}_configPath", uncrustifyConfigPath)
# expect(atom.config.get("atom-beautify.#{lang}_configPath")).toEqual("TEST") # expect(atom.config.get("atom-beautify.#{lang}_configPath")).toEqual("TEST")
### ###
Directory structure: Directory structure:
@ -103,13 +103,13 @@ describe "BeautifyLanguages", ->
originalDir = path.resolve(testsDir, "original") originalDir = path.resolve(testsDir, "original")
if not fs.existsSync(originalDir) if not fs.existsSync(originalDir)
console.warn("Directory for test originals/inputs not found." + console.warn("Directory for test originals/inputs not found." +
" Making it at #{originalDir}.") " Making it at #{originalDir}.")
fs.mkdirSync(originalDir) fs.mkdirSync(originalDir)
# Expected # Expected
expectedDir = path.resolve(testsDir, "expected") expectedDir = path.resolve(testsDir, "expected")
if not fs.existsSync(expectedDir) if not fs.existsSync(expectedDir)
console.warn("Directory for test expected/results not found." + console.warn("Directory for test expected/results not found." +
"Making it at #{expectedDir}.") "Making it at #{expectedDir}.")
fs.mkdirSync(expectedDir) fs.mkdirSync(expectedDir)
# Language group tests # Language group tests
@ -136,7 +136,7 @@ describe "BeautifyLanguages", ->
# Check if there is a matching expected test resut # Check if there is a matching expected test resut
if not fs.existsSync(expectedTestPath) if not fs.existsSync(expectedTestPath)
throw new Error("No matching expected test result found for '#{testName}' " + throw new Error("No matching expected test result found for '#{testName}' " +
"at '#{expectedTestPath}'.") "at '#{expectedTestPath}'.")
# err = fs.writeFileSync(expectedTestPath, originalContents) # err = fs.writeFileSync(expectedTestPath, originalContents)
# throw err if err # throw err if err
# Get contents of expected test file # Get contents of expected test file

View File

@ -1,5 +1,5 @@
{ {
"indent_size": 4, "indent_size": 2,
"indent_char": " ", "indent_char": " ",
"indent_level": 0, "indent_level": 0,
"indent_with_tabs": false, "indent_with_tabs": false,

View File

@ -7,19 +7,19 @@ Beautifier = require('./beautifier')
module.exports = class autopep8 extends Beautifier module.exports = class autopep8 extends Beautifier
name: "autopep8" name: "autopep8"
options: { options: {
Python: true Python: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
# console.log('autopep8', options, text, language) # console.log('autopep8', options, text, language)
@run("autopep8", [ @run("autopep8", [
@tempFile("input", text) @tempFile("input", text)
["--max-line-length", "#{options.max_line_length}"] if options.max_line_length? ["--max-line-length", "#{options.max_line_length}"] if options.max_line_length?
["--indent-size","#{options.indent_size}"] if options.indent_size? ["--indent-size","#{options.indent_size}"] if options.indent_size?
["--ignore","#{options.ignore.join(',')}"] if options.ignore? ["--ignore","#{options.ignore.join(',')}"] if options.ignore?
], help: { ], help: {
link: "https://github.com/hhatto/autopep8" link: "https://github.com/hhatto/autopep8"
}) })

View File

@ -9,193 +9,193 @@ which = require('which')
module.exports = class Beautifier module.exports = class Beautifier
### ###
Promise Promise
### ###
Promise: Promise Promise: Promise
### ###
Name of Beautifier Name of Beautifier
### ###
name: 'Beautifier' name: 'Beautifier'
### ###
Supported Options Supported Options
Enable options for supported languages. Enable options for supported languages.
- <string:language>:<boolean:all_options_enabled> - <string:language>:<boolean:all_options_enabled>
- <string:language>:<string:option_key>:<boolean:enabled> - <string:language>:<string:option_key>:<boolean:enabled>
- <string:language>:<string:option_key>:<string:rename> - <string:language>:<string:option_key>:<string:rename>
- <string:language>:<string:option_key>:<function:transform> - <string:language>:<string:option_key>:<function:transform>
- <string:language>:<string:option_key>:<array:mapper> - <string:language>:<string:option_key>:<array:mapper>
### ###
options: {} options: {}
### ###
Supported languages by this Beautifier Supported languages by this Beautifier
Extracted from the keys of the `options` field. Extracted from the keys of the `options` field.
### ###
languages: null languages: null
### ###
Beautify text Beautify text
Override this method in subclasses Override this method in subclasses
### ###
beautify: null beautify: null
### ###
Show deprecation warning to user. Show deprecation warning to user.
### ###
deprecate: (warning) -> deprecate: (warning) ->
atom.notifications?.addWarning(warning) atom.notifications?.addWarning(warning)
### ###
Create temporary file Create temporary file
### ###
tempFile: (name = "atom-beautify-temp", contents = "") -> tempFile: (name = "atom-beautify-temp", contents = "") ->
return new Promise((resolve, reject) => return new Promise((resolve, reject) =>
# create temp file # create temp file
temp.open(name, (err, info) => temp.open(name, (err, info) =>
@debug('tempFile', name, err, info) @debug('tempFile', name, err, info)
return reject(err) if err return reject(err) if err
fs.write(info.fd, contents, (err) => fs.write(info.fd, contents, (err) =>
return reject(err) if err return reject(err) if err
fs.close(info.fd, (err) => fs.close(info.fd, (err) =>
return reject(err) if err return reject(err) if err
resolve(info.path) resolve(info.path)
) )
)
)
) )
)
)
### ###
Read file Read file
### ###
readFile: (filePath) -> readFile: (filePath) ->
Promise.resolve(filePath) Promise.resolve(filePath)
.then((filePath) -> .then((filePath) ->
return readFile(filePath, "utf8") return readFile(filePath, "utf8")
)
###
If platform is Windows
###
isWindows: do ->
return new RegExp('^win').test(process.platform)
###
Get Shell Environment variables
Special thank you to @ioquatix
See https://github.com/ioquatix/script-runner/blob/v1.5.0/lib/script-runner.coffee#L45-L63
###
_envCache: null
_envCacheDate: null
_envCacheExpiry: 10000 # 10 seconds
getShellEnvironment: ->
return new @Promise((resolve, reject) =>
# Check Cache
if @_envCache? and @_envCacheDate?
# Check if Cache is old
if (new Date() - @_envCacheDate) < @_envCacheExpiry
# Still fresh
return resolve(@_envCache)
# Check if Windows
if @isWindows
# Windows
# Use default
resolve(process.env)
else
# Mac & Linux
# I tried using ChildProcess.execFile but there is no way to set detached and
# this causes the child shell to lock up.
# This command runs an interactive login shell and
# executes the export command to get a list of environment variables.
# We then use these to run the script:
child = spawn process.env.SHELL, ['-ilc', 'env'],
# This is essential for interactive shells, otherwise it never finishes:
detached: true,
# We don't care about stdin, stderr can go out the usual way:
stdio: ['ignore', 'pipe', process.stderr]
# We buffer stdout:
buffer = ''
child.stdout.on 'data', (data) -> buffer += data
# When the process finishes, extract the environment variables and pass them to the callback:
child.on 'close', (code, signal) =>
if code isnt 0
return reject(new Error("Could not get Shell Environment. Exit code: "+code+", Signal: "+signal))
environment = {}
for definition in buffer.split('\n')
[key, value] = definition.split('=', 2)
environment[key] = value if key != ''
# Cache Environment
@_envCache = environment
@_envCacheDate = new Date()
resolve(environment)
)
###
Like the unix which utility.
Finds the first instance of a specified executable in the PATH environment variable.
Does not cache the results,
so hash -r is not needed when the PATH changes.
See https://github.com/isaacs/node-which
###
which: (exe, options = {}) ->
# Get PATH and other environment variables
@getShellEnvironment()
.then((env) ->
new Promise((resolve, reject) ->
options.path ?= env.PATH
which(exe, options, (err, path) ->
resolve(exe) if err
resolve(path)
) )
)
)
### ###
If platform is Windows Add help to error.description
###
isWindows: do ->
return /^win/.test(process.platform)
### Note: error.description is not officially used in JavaScript,
Get Shell Environment variables however it is used internally for Atom Beautify when displaying errors.
###
Special thank you to @ioquatix commandNotFoundError: (exe, help) ->
See https://github.com/ioquatix/script-runner/blob/v1.5.0/lib/script-runner.coffee#L45-L63 # Create new improved error
### # notify user that it may not be
_envCache: null # installed or in path
_envCacheDate: null message = "Could not find '#{exe}'. \
_envCacheExpiry: 10000 # 10 seconds
getShellEnvironment: ->
return new @Promise((resolve, reject) =>
# Check Cache
if @_envCache? and @_envCacheDate?
# Check if Cache is old
if (new Date() - @_envCacheDate) < @_envCacheExpiry
# Still fresh
return resolve(@_envCache)
# Check if Windows
if @isWindows
# Windows
# Use default
resolve(process.env)
else
# Mac & Linux
# I tried using ChildProcess.execFile but there is no way to set detached and
# this causes the child shell to lock up.
# This command runs an interactive login shell and
# executes the export command to get a list of environment variables.
# We then use these to run the script:
child = spawn process.env.SHELL, ['-ilc', 'env'],
# This is essential for interactive shells, otherwise it never finishes:
detached: true,
# We don't care about stdin, stderr can go out the usual way:
stdio: ['ignore', 'pipe', process.stderr]
# We buffer stdout:
buffer = ''
child.stdout.on 'data', (data) -> buffer += data
# When the process finishes, extract the environment variables and pass them to the callback:
child.on 'close', (code, signal) =>
if code isnt 0
return reject(new Error("Could not get Shell Environment. Exit code: "+code+", Signal: "+signal))
environment = {}
for definition in buffer.split('\n')
[key, value] = definition.split('=', 2)
environment[key] = value if key != ''
# Cache Environment
@_envCache = environment
@_envCacheDate = new Date()
resolve(environment)
)
###
Like the unix which utility.
Finds the first instance of a specified executable in the PATH environment variable.
Does not cache the results,
so hash -r is not needed when the PATH changes.
See https://github.com/isaacs/node-which
###
which: (exe, options = {}) ->
# Get PATH and other environment variables
@getShellEnvironment()
.then((env) ->
new Promise((resolve, reject) ->
options.path ?= env.PATH
which(exe, options, (err, path) ->
resolve(exe) if err
resolve(path)
)
)
)
###
Add help to error.description
Note: error.description is not officially used in JavaScript,
however it is used internally for Atom Beautify when displaying errors.
###
commandNotFoundError: (exe, help) ->
# Create new improved error
# notify user that it may not be
# installed or in path
message = "Could not find '#{exe}'. \
The program may not be installed." The program may not be installed."
er = new Error(message) er = new Error(message)
er.code = 'CommandNotFound' er.code = 'CommandNotFound'
er.errno = er.code er.errno = er.code
er.syscall = 'beautifier::run' er.syscall = 'beautifier::run'
er.file = exe er.file = exe
if help? if help?
if typeof help is "object" if typeof help is "object"
# Basic notice # Basic notice
helpStr = "See #{help.link} for program \ helpStr = "See #{help.link} for program \
installation instructions.\n" installation instructions.\n"
# Help to configure Atom Beautify for program's path # Help to configure Atom Beautify for program's path
helpStr += "You can configure Atom Beautify \ helpStr += "You can configure Atom Beautify \
with the absolute path \ with the absolute path \
to '#{help.program or exe}' by setting \ to '#{help.program or exe}' by setting \
'#{help.pathOption}' in \ '#{help.pathOption}' in \
the Atom Beautify package settings.\n" if help.pathOption the Atom Beautify package settings.\n" if help.pathOption
# Optional, additional help # Optional, additional help
helpStr += help.additional if help.additional helpStr += help.additional if help.additional
# Common Help # Common Help
issueSearchLink = issueSearchLink =
"https://github.com/Glavin001/atom-beautify/\ "https://github.com/Glavin001/atom-beautify/\
search?q=#{exe}&type=Issues" search?q=#{exe}&type=Issues"
docsLink = "https://github.com/Glavin001/\ docsLink = "https://github.com/Glavin001/\
atom-beautify/tree/master/docs" atom-beautify/tree/master/docs"
helpStr += "Your program is properly installed if running \ helpStr += "Your program is properly installed if running \
'#{if @isWindows then 'where.exe' \ '#{if @isWindows then 'where.exe' \
else 'which'} #{exe}' \ else 'which'} #{exe}' \
in your #{if @isWindows then 'CMD prompt' \ in your #{if @isWindows then 'CMD prompt' \
@ -218,121 +218,121 @@ module.exports = class Beautifier
If you are still unable to resolve this issue on \ If you are still unable to resolve this issue on \
your own then please create a new issue and \ your own then please create a new issue and \
ask for help.\n" ask for help.\n"
er.description = helpStr er.description = helpStr
else #if typeof help is "string" else #if typeof help is "string"
er.description = help er.description = help
return er return er
### ###
Run command-line interface command Run command-line interface command
### ###
run: (executable, args, {ignoreReturnCode, help} = {}) -> run: (executable, args, {ignoreReturnCode, help} = {}) ->
# Flatten args first # Flatten args first
args = _.flatten(args) args = _.flatten(args)
# Resolve executable and all args # Resolve executable and all args
Promise.all([executable, Promise.all(args)]) Promise.all([executable, Promise.all(args)])
.then(([exeName, args]) => .then(([exeName, args]) =>
@debug('exeName, args:', exeName, args) @debug('exeName, args:', exeName, args)
return new Promise((resolve, reject) => return new Promise((resolve, reject) =>
# Remove undefined/null values # Remove undefined/null values
args = _.without(args, undefined) args = _.without(args, undefined)
args = _.without(args, null) args = _.without(args, null)
# Get PATH and other environment variables # Get PATH and other environment variables
Promise.all([@getShellEnvironment(), @which(exeName)]) Promise.all([@getShellEnvironment(), @which(exeName)])
.then(([env, exePath]) => .then(([env, exePath]) =>
@debug('exePath, env:', exePath, env) @debug('exePath, env:', exePath, env)
exe = exePath ? exeName exe = exePath ? exeName
# Spawn command # Spawn command
options = { options = {
env: env env: env
} }
cmd = @spawn(exe, args, options) cmd = @spawn(exe, args, options)
.then(({returnCode, stdout, stderr}) -> .then(({returnCode, stdout, stderr}) ->
# If return code is not 0 then error occured # If return code is not 0 then error occured
if not ignoreReturnCode and returnCode isnt 0 if not ignoreReturnCode and returnCode isnt 0
reject(stderr) reject(stderr)
else else
resolve(stdout) resolve(stdout)
)
.catch((err) =>
@debug('error', err)
# Check if error is ENOENT
# (command could not be found)
if err.code is 'ENOENT' or err.errno is 'ENOENT'
reject(@commandNotFoundError(exeName, help))
else
# continue as normal error
reject(err)
)
)
) )
) .catch((err) =>
@debug('error', err)
### # Check if error is ENOENT
Spawn # (command could not be found)
### if err.code is 'ENOENT' or err.errno is 'ENOENT'
spawn: (exe, args, options) -> reject(@commandNotFoundError(exeName, help))
return new Promise((resolve, reject) => else
@debug('spawn', exe, args) # continue as normal error
cmd = spawn(exe, args, options)
# add a 'data' event listener for the spawn instance
stdout = ""
stderr = ""
cmd.stdout.on('data', (data) -> stdout += data )
cmd.stderr.on('data', (data) -> stderr += data )
# when the spawn child process exits,
# check if there were any errors and
# close the writeable stream
cmd.on('exit', (returnCode) =>
@debug('spawn done', returnCode, stderr, stdout)
resolve({returnCode, stdout, stderr})
)
cmd.on('error', (err) =>
@debug('error', err)
reject(err) reject(err)
) )
) )
)
)
### ###
Logger instance Spawn
### ###
logger: null spawn: (exe, args, options) ->
### return new Promise((resolve, reject) =>
Initialize and configure Logger @debug('spawn', exe, args)
### cmd = spawn(exe, args, options)
setupLogger: -> # add a 'data' event listener for the spawn instance
@logger = require('../logger')(__filename) stdout = ""
# @verbose(@logger) stderr = ""
# Merge logger methods into beautifier class cmd.stdout.on('data', (data) -> stdout += data )
for key, method of @logger cmd.stderr.on('data', (data) -> stderr += data )
# @verbose(key, method) # when the spawn child process exits,
@[key] = method # check if there were any errors and
@verbose("Beautifier logger has been initialized.") # close the writeable stream
cmd.on('exit', (returnCode) =>
@debug('spawn done', returnCode, stderr, stdout)
resolve({returnCode, stdout, stderr})
)
cmd.on('error', (err) =>
@debug('error', err)
reject(err)
)
)
### ###
Constructor to setup beautifer Logger instance
### ###
constructor: () -> logger: null
# Setup logger ###
@setupLogger() Initialize and configure Logger
# Handle global options ###
if @options._? setupLogger: ->
globalOptions = @options._ @logger = require('../logger')(__filename)
delete @options._ # @verbose(@logger)
# Only merge if globalOptions is an object # Merge logger methods into beautifier class
if typeof globalOptions is "object" for key, method of @logger
# Iterate over all supported languages # @verbose(key, method)
for lang, options of @options @[key] = method
# @verbose("Beautifier logger has been initialized.")
if typeof options is "boolean"
if options is true ###
@options[lang] = globalOptions Constructor to setup beautifer
else if typeof options is "object" ###
@options[lang] = _.merge(globalOptions, options) constructor: () ->
else # Setup logger
@warn("Unsupported options type #{typeof options} for language #{lang}: "+ options) @setupLogger()
@verbose("Options for #{@name}:", @options) # Handle global options
# Set supported languages if @options._?
@languages = _.keys(@options) globalOptions = @options._
delete @options._
# Only merge if globalOptions is an object
if typeof globalOptions is "object"
# Iterate over all supported languages
for lang, options of @options
#
if typeof options is "boolean"
if options is true
@options[lang] = globalOptions
else if typeof options is "object"
@options[lang] = _.merge(globalOptions, options)
else
@warn("Unsupported options type #{typeof options} for language #{lang}: "+ options)
@verbose("Options for #{@name}:", @options)
# Set supported languages
@languages = _.keys(@options)

View File

@ -2,29 +2,31 @@
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class CoffeeFmt extends Beautifier module.exports = class CoffeeFmt extends Beautifier
name: "coffee-fmt" name: "coffee-fmt"
options: { options: {
# Apply language-specific options # Apply language-specific options
CoffeeScript: CoffeeScript:
tab: ["indent_size", "indent_char", "indent_with_tabs", (indentSize, indentChar, indentWithTabs) -> tab: ["indent_size", \
return "\t" if indentWithTabs "indent_char", "indent_with_tabs", \
Array(indentSize+1).join(indentChar) (indentSize, indentChar, indentWithTabs) ->
] return "\t" if indentWithTabs
} Array(indentSize+1).join(indentChar)
]
}
beautify: (text, language, options) -> beautify: (text, language, options) ->
@verbose('beautify', language, options) @verbose('beautify', language, options)
return new @Promise((resolve, reject) -> return new @Promise((resolve, reject) ->
# Add newLine option # Add newLine option
options.newLine = "\n" options.newLine = "\n"
# Require # Require
fmt = require('coffee-fmt') fmt = require('coffee-fmt')
# Format! # Format!
try try
results = fmt.format(text, options) results = fmt.format(text, options)
# Return beautified CoffeeScript code # Return beautified CoffeeScript code
resolve(results) resolve(results)
catch e catch e
reject(e) reject(e)
) )

View File

@ -3,30 +3,30 @@ Beautifier = require('./beautifier')
module.exports = class CoffeeFormatter extends Beautifier module.exports = class CoffeeFormatter extends Beautifier
name: "Coffee Formatter" name: "Coffee Formatter"
options: { options: {
CoffeeScript: true CoffeeScript: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
return new @Promise((resolve, reject) -> return new @Promise((resolve, reject) ->
CF = require("coffee-formatter") CF = require("coffee-formatter")
lines = text.split("\n") lines = text.split("\n")
resultArr = [] resultArr = []
i = 0 i = 0
len = lines.length len = lines.length
while i < len while i < len
curr = lines[i] curr = lines[i]
p = CF.formatTwoSpaceOperator(curr) p = CF.formatTwoSpaceOperator(curr)
p = CF.formatOneSpaceOperator(p) p = CF.formatOneSpaceOperator(p)
p = CF.shortenSpaces(p) p = CF.shortenSpaces(p)
resultArr.push p resultArr.push p
i++ i++
result = resultArr.join("\n") result = resultArr.join("\n")
resolve result resolve result
) )

View File

@ -2,50 +2,50 @@
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class JSBeautify extends Beautifier module.exports = class JSBeautify extends Beautifier
name: "CSScomb" name: "CSScomb"
options: { options: {
# TODO: Add support for options # TODO: Add support for options
CSS: false CSS: false
LESS: false LESS: false
Sass: false Sass: false
SCSS: false SCSS: false
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
return new @Promise((resolve, reject) -> return new @Promise((resolve, reject) ->
# console.log('CSSComb', text, language, options) # console.log('CSSComb', text, language, options)
# Require # Require
Comb = require('csscomb') Comb = require('csscomb')
config = null config = null
try try
# Load from Project's .csscomb.json # Load from Project's .csscomb.json
projectConfigPath = atom.project.getDirectories()?[0]?.resolve('.csscomb.json') projectConfigPath = atom.project.getDirectories()?[0]?.resolve('.csscomb.json')
config = require(projectConfigPath) # Will throw error if does not exist config = require(projectConfigPath) # Will throw error if does not exist
catch e catch e
# Fallback to csscomb # Fallback to csscomb
config = Comb.getConfig('csscomb') config = Comb.getConfig('csscomb')
# TODO: Add support to select CSSComb predefined config's name # TODO: Add support to select CSSComb predefined config's name
# console.log('config', config, options) # console.log('config', config, options)
# Configure # Configure
comb = new Comb(config) comb = new Comb(config)
# Determine syntax from Language # Determine syntax from Language
syntax = "css" # Default syntax = "css" # Default
switch language switch language
when "LESS" when "LESS"
syntax = "less" syntax = "less"
when "SCSS" when "SCSS"
syntax = "scss" syntax = "scss"
when "Sass" when "Sass"
syntax = "sass" syntax = "sass"
# Use # Use
processedCSS = comb.processString(text, { processedCSS = comb.processString(text, {
syntax: syntax syntax: syntax
}) })
# console.log('processedCSS', processedCSS, syntax) # console.log('processedCSS', processedCSS, syntax)
resolve(processedCSS) resolve(processedCSS)
) )

View File

@ -7,41 +7,41 @@ Beautifier = require('../beautifier')
path = require("path") path = require("path")
module.exports = class FortranBeautifier extends Beautifier module.exports = class FortranBeautifier extends Beautifier
name: "Fortran Beautifier" name: "Fortran Beautifier"
options: { options: {
Fortran: true Fortran: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
@debug('fortran-beautifier', options) @debug('fortran-beautifier', options)
emacs_path = options.emacs_path emacs_path = options.emacs_path
emacs_script_path = options.emacs_script_path emacs_script_path = options.emacs_script_path
if not emacs_script_path if not emacs_script_path
emacs_script_path = path.resolve(__dirname, "emacs-fortran-formating-script.lisp") emacs_script_path = path.resolve(__dirname, "emacs-fortran-formating-script.lisp")
@debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path) @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)
args = [ args = [
'--batch' '--batch'
'-l' '-l'
emacs_script_path emacs_script_path
'-f' '-f'
'f90-batch-indent-region' 'f90-batch-indent-region'
tempFile = @tempFile("temp", text) tempFile = @tempFile("temp", text)
] ]
if emacs_path if emacs_path
args.unshift("#{emacs_path}") args.unshift("#{emacs_path}")
@run("python", args, {ignoreReturnCode: true}) @run("python", args, {ignoreReturnCode: true})
.then(=> .then(=>
@readFile(tempFile) @readFile(tempFile)
) )
else else
@run("emacs", args, {ignoreReturnCode: true}) @run("emacs", args, {ignoreReturnCode: true})
.then(=> .then(=>
@readFile(tempFile) @readFile(tempFile)
) )

View File

@ -6,13 +6,13 @@ Requires http://golang.org/cmd/gofmt/
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class gofmt extends Beautifier module.exports = class gofmt extends Beautifier
name: "gofmt" name: "gofmt"
options: { options: {
Go: true Go: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run("gofmt", [ @run("gofmt", [
@tempFile("input", text) @tempFile("input", text)
]) ])

View File

@ -6,18 +6,18 @@ Requires https://github.com/threedaymonk/htmlbeautifier
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class HTMLBeautifier extends Beautifier module.exports = class HTMLBeautifier extends Beautifier
name: "HTML Beautifier" name: "HTML Beautifier"
options: { options: {
ERB: ERB:
indent_size: true indent_size: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
console.log('erb', options) console.log('erb', options)
@run("htmlbeautifier", [ @run("htmlbeautifier", [
"--tab-stops", options.indent_size "--tab-stops", options.indent_size
tempFile = @tempFile("temp", text) tempFile = @tempFile("temp", text)
]) ])
.then(=> .then(=>
@readFile(tempFile) @readFile(tempFile)
) )

File diff suppressed because it is too large Load Diff

View File

@ -2,52 +2,52 @@
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class JSBeautify extends Beautifier module.exports = class JSBeautify extends Beautifier
name: "JS Beautify" name: "JS Beautify"
options: { options: {
HTML: true HTML: true
XML: true XML: true
Handlebars: true Handlebars: true
Mustache: true Mustache: true
Marko: true Marko: true
JavaScript: true JavaScript: true
JSON: true JSON: true
CSS: CSS:
indent_size: true indent_size: true
indent_char: true indent_char: true
selector_separator_newline: true selector_separator_newline: true
newline_between_rules: true newline_between_rules: true
preserve_newlines: true preserve_newlines: true
wrap_line_length: true wrap_line_length: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
@verbose("JS Beautify language #{language}") @verbose("JS Beautify language #{language}")
return new @Promise((resolve, reject) => return new @Promise((resolve, reject) =>
try try
switch language switch language
when "JSON", "JavaScript" when "JSON", "JavaScript"
beautifyJS = require("js-beautify") beautifyJS = require("js-beautify")
text = beautifyJS(text, options) text = beautifyJS(text, options)
resolve text resolve text
when "Handlebars", "Mustache" when "Handlebars", "Mustache"
# jshint ignore: start # jshint ignore: start
options.indent_handlebars = true # Force jsbeautify to indent_handlebars options.indent_handlebars = true # Force jsbeautify to indent_handlebars
# jshint ignore: end # jshint ignore: end
beautifyHTML = require("js-beautify").html beautifyHTML = require("js-beautify").html
text = beautifyHTML(text, options) text = beautifyHTML(text, options)
resolve text resolve text
when "HTML (Liquid)", "HTML", "XML", "Marko", "Web Form/Control (C#)", "Web Handler (C#)" when "HTML (Liquid)", "HTML", "XML", "Marko", "Web Form/Control (C#)", "Web Handler (C#)"
beautifyHTML = require("js-beautify").html beautifyHTML = require("js-beautify").html
text = beautifyHTML(text, options) text = beautifyHTML(text, options)
@debug("Beautified HTML: #{text}") @debug("Beautified HTML: #{text}")
resolve text resolve text
when "CSS" when "CSS"
beautifyCSS = require("js-beautify").css beautifyCSS = require("js-beautify").css
text = beautifyCSS(text, options) text = beautifyCSS(text, options)
resolve text resolve text
catch err catch err
@error("JS Beautify error: #{err}") @error("JS Beautify error: #{err}")
reject(err) reject(err)
) )

View File

@ -5,26 +5,26 @@ Requires [perltidy](http://perltidy.sourceforge.net)
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class PerlTidy extends Beautifier module.exports = class PerlTidy extends Beautifier
name: "Perltidy" name: "Perltidy"
options: { options: {
Perl: true Perl: true
} }
cli: (options) -> cli: (options) ->
if not options.perltidy_path? if not options.perltidy_path?
return new Error("'Perl Perltidy Path' not set!" + return new Error("'Perl Perltidy Path' not set!" +
" Please set this in the Atom Beautify package settings.") " Please set this in the Atom Beautify package settings.")
else else
return options.perltidy_path return options.perltidy_path
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run("perltidy", [ @run("perltidy", [
'--standard-output' '--standard-output'
'--standard-error-output' '--standard-error-output'
'--quiet' '--quiet'
"--profile=#{options.perltidy_profile}" if options.perltidy_profile? "--profile=#{options.perltidy_profile}" if options.perltidy_profile?
@tempFile("input", text) @tempFile("input", text)
], help: { ], help: {
link: "http://perltidy.sourceforge.net/" link: "http://perltidy.sourceforge.net/"
}) })

View File

@ -6,70 +6,70 @@ Requires https://github.com/FriendsOfPHP/PHP-CS-Fixer
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class PHPCSFixer extends Beautifier module.exports = class PHPCSFixer extends Beautifier
name: "PHP-CS-Fixer" name: "PHP-CS-Fixer"
options: { options: {
PHP: true PHP: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
@debug('php-cs-fixer', options) @debug('php-cs-fixer', options)
isWin = @isWindows isWin = @isWindows
if isWin if isWin
# Find php-cs-fixer.phar script # Find php-cs-fixer.phar script
@Promise.all([ @Promise.all([
@which(options.cs_fixer_path) if options.cs_fixer_path @which(options.cs_fixer_path) if options.cs_fixer_path
@which('php-cs-fixer') @which('php-cs-fixer')
]).then((paths) => ]).then((paths) =>
@debug('php-cs-fixer paths', paths) @debug('php-cs-fixer paths', paths)
_ = require('lodash') _ = require('lodash')
# Get first valid, absolute path # Get first valid, absolute path
phpCSFixerPath = _.find(paths, (p) -> p and p.charAt(0) is '/' ) phpCSFixerPath = _.find(paths, (p) -> p and p.charAt(0) is '/' )
@verbose('phpCSFixerPath', phpCSFixerPath) @verbose('phpCSFixerPath', phpCSFixerPath)
@debug('phpCSFixerPath', phpCSFixerPath, paths) @debug('phpCSFixerPath', phpCSFixerPath, paths)
# Check if PHP-CS-Fixer path was found # Check if PHP-CS-Fixer path was found
if phpCSFixerPath? if phpCSFixerPath?
# Found PHP-CS-Fixer path # Found PHP-CS-Fixer path
@run("php", [ @run("php", [
phpCSFixerPath phpCSFixerPath
"fix" "fix"
"--level=#{options.level}" if options.level "--level=#{options.level}" if options.level
"--fixers=#{options.fixers}" if options.fixers "--fixers=#{options.fixers}" if options.fixers
tempFile = @tempFile("temp", text) tempFile = @tempFile("temp", text)
], { ], {
ignoreReturnCode: true ignoreReturnCode: true
help: { help: {
link: "http://php.net/manual/en/install.php" link: "http://php.net/manual/en/install.php"
} }
}) })
.then(=> .then(=>
@readFile(tempFile) @readFile(tempFile)
)
else
@verbose('php-cs-fixer not found!')
# Could not find PHP-CS-Fixer path
@Promise.reject(@commandNotFoundError(
'php-cs-fixer'
{
link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer"
program: "php-cs-fixer.phar"
pathOption: "PHP - CS Fixer Path"
})
)
) )
else else
@run("php-cs-fixer", [ @verbose('php-cs-fixer not found!')
"fix" # Could not find PHP-CS-Fixer path
"--level=#{options.level}" if options.level @Promise.reject(@commandNotFoundError(
"--fixers=#{options.fixers}" if options.fixers 'php-cs-fixer'
tempFile = @tempFile("temp", text) {
], { link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer"
ignoreReturnCode: true program: "php-cs-fixer.phar"
help: { pathOption: "PHP - CS Fixer Path"
link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer" })
} )
}) )
.then(=> else
@readFile(tempFile) @run("php-cs-fixer", [
) "fix"
"--level=#{options.level}" if options.level
"--fixers=#{options.fixers}" if options.fixers
tempFile = @tempFile("temp", text)
], {
ignoreReturnCode: true
help: {
link: "https://github.com/FriendsOfPHP/PHP-CS-Fixer"
}
})
.then(=>
@readFile(tempFile)
)

View File

@ -2,107 +2,107 @@
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class PrettyDiff extends Beautifier module.exports = class PrettyDiff extends Beautifier
name: "Pretty Diff" name: "Pretty Diff"
options: { options: {
# Apply these options first / globally, for all languages # Apply these options first / globally, for all languages
_: _:
inchar: "indent_char" inchar: "indent_char"
insize: "indent_size" insize: "indent_size"
objsort: (objsort) -> objsort: (objsort) ->
objsort or false objsort or false
preserve: ['preserve_newlines', (preserve_newlines) -> preserve: ['preserve_newlines', (preserve_newlines) ->
if (preserve_newlines is true ) then \ if (preserve_newlines is true ) then \
"all" else "none" "all" else "none"
] ]
cssinsertlines: "newline_between_rules" cssinsertlines: "newline_between_rules"
comments: ["indent_comments", (indent_comments) -> comments: ["indent_comments", (indent_comments) ->
if (indent_comments is true) then \ if (indent_comments is true) then \
"indent" else "noindent" "indent" else "noindent"
] ]
force: "force_indentation" force: "force_indentation"
quoteConvert: "convert_quotes" quoteConvert: "convert_quotes"
vertical: ['align_assignments', (align_assignments) -> vertical: ['align_assignments', (align_assignments) ->
if (align_assignments is true ) then \ if (align_assignments is true ) then \
"all" else "none" "all" else "none"
] ]
wrap: "wrap_line_length" wrap: "wrap_line_length"
# Apply language-specific options # Apply language-specific options
CSV: true CSV: true
ERB: true ERB: true
EJS: true EJS: true
HTML: true HTML: true
XML: true XML: true
Spacebars: true Spacebars: true
JSX: true JSX: true
JavaScript: true JavaScript: true
CSS: true CSS: true
SCSS: true SCSS: true
Sass: true Sass: true
JSON: true JSON: true
TSS: true TSS: true
Twig: true Twig: true
LESS: true LESS: true
Swig: true Swig: true
Visualforce: true Visualforce: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
return new @Promise((resolve, reject) => return new @Promise((resolve, reject) =>
prettydiff = require("prettydiff") prettydiff = require("prettydiff")
_ = require('lodash') _ = require('lodash')
# Select Prettydiff language # Select Prettydiff language
lang = "auto" lang = "auto"
switch language switch language
when "CSV" when "CSV"
lang = "csv" lang = "csv"
when "EJS", "Twig" when "EJS", "Twig"
lang = "ejs" lang = "ejs"
when "ERB" when "ERB"
lang = "html_ruby" lang = "html_ruby"
when "Handlebars", "Mustache", "Spacebars" when "Handlebars", "Mustache", "Spacebars"
lang = "handlebars" lang = "handlebars"
when "SGML", "Swig" when "SGML", "Swig"
lang = "markup" lang = "markup"
when "XML", "Visualforce" when "XML", "Visualforce"
lang = "xml" lang = "xml"
when "HTML" when "HTML"
lang = "html" lang = "html"
when "JavaScript" when "JavaScript"
lang = "javascript" lang = "javascript"
when "JSON" when "JSON"
lang = "json" lang = "json"
when "JSX" when "JSX"
lang = "jsx" lang = "jsx"
when "JSTL" when "JSTL"
lang = "jsp" lang = "jsp"
when "CSS" when "CSS"
lang = "css" lang = "css"
when "LESS" when "LESS"
lang = "less" lang = "less"
when "SCSS", "Sass" when "SCSS", "Sass"
lang = "scss" lang = "scss"
when "TSS" when "TSS"
lang = "tss" lang = "tss"
else else
lang = "auto" lang = "auto"
# Prettydiff Arguments # Prettydiff Arguments
args = args =
source: text source: text
lang: lang lang: lang
mode: "beautify" mode: "beautify"
# Merge args intos options # Merge args intos options
_.merge(options, args) _.merge(options, args)
# Beautify # Beautify
@verbose('prettydiff', options) @verbose('prettydiff', options)
output = prettydiff.api(options) output = prettydiff.api(options)
result = output[0] result = output[0]
# Return beautified text # Return beautified text
resolve(result) resolve(result)
) )

View File

@ -6,35 +6,35 @@ Requires https://github.com/bbatsov/rubocop
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class Rubocop extends Beautifier module.exports = class Rubocop extends Beautifier
name: "Rubocop" name: "Rubocop"
options: { options: {
Ruby: Ruby:
indent_size: true indent_size: true
}
beautify: (text, language, options) ->
# Generate config file
yaml = require("yaml-front-matter")
config = {
"Style/IndentationWidth":
"Width": options.indent_size
} }
configStr = yaml.safeDump(config)
@debug("rubocop", config, configStr)
beautify: (text, language, options) -> @run("rubocop", [
"--auto-correct"
# Generate config file "--config", @tempFile("rubocop-config", configStr)
yaml = require("yaml-front-matter") tempFile = @tempFile("temp", text)
], {ignoreReturnCode: true})
config = { .then(=>
"Style/IndentationWidth": # console.log('rubocop', arguments, tempFile)
"Width": options.indent_size @readFile(tempFile)
} # .then((text) ->
configStr = yaml.safeDump(config) # console.log('rubocop', text)
@debug("rubocop", config, configStr) # return text
# )
@run("rubocop", [ )
"--auto-correct"
"--config", @tempFile("rubocop-config", configStr)
tempFile = @tempFile("temp", text)
], {ignoreReturnCode: true})
.then(=>
# console.log('rubocop', arguments, tempFile)
@readFile(tempFile)
# .then((text) ->
# console.log('rubocop', text)
# return text
# )
)

View File

@ -6,19 +6,19 @@ Requires https://github.com/erniebrodeur/ruby-beautify
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class RubyBeautify extends Beautifier module.exports = class RubyBeautify extends Beautifier
name: "Ruby Beautify" name: "Ruby Beautify"
options: { options: {
Ruby: Ruby:
indent_size: true indent_size: true
indent_char: true indent_char: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run("rbeautify", [ @run("rbeautify", [
if options.indent_char is '\t' then "--tabs" else "--spaces" if options.indent_char is '\t' then "--tabs" else "--spaces"
"--indent_count", options.indent_count "--indent_count", options.indent_count
@tempFile("input", text) @tempFile("input", text)
], help: { ], help: {
link: "https://github.com/erniebrodeur/ruby-beautify" link: "https://github.com/erniebrodeur/ruby-beautify"
}) })

View File

@ -7,21 +7,21 @@ Beautifier = require('./beautifier')
module.exports = class rustfmt extends Beautifier module.exports = class rustfmt extends Beautifier
name: "rustfmt" name: "rustfmt"
options: { options: {
Rust: true Rust: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
program = options.rustfmt_path or "rustfmt" program = options.rustfmt_path or "rustfmt"
@run(program, [ @run(program, [
tmpFile = @tempFile("tmp", text) tmpFile = @tempFile("tmp", text)
], help: { ], help: {
link: "https://github.com/nrc/rustfmt" link: "https://github.com/nrc/rustfmt"
program: "rustfmt" program: "rustfmt"
pathOption: "Rust - Rustfmt Path" pathOption: "Rust - Rustfmt Path"
}) })
.then(=> .then(=>
@readFile(tmpFile) @readFile(tmpFile)
) )

View File

@ -6,19 +6,19 @@ Requires https://github.com/andialbrecht/sqlparse
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class sqlformat extends Beautifier module.exports = class sqlformat extends Beautifier
name: "sqlformat" name: "sqlformat"
options: { options: {
SQL: true SQL: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
@run("sqlformat", [ @run("sqlformat", [
@tempFile("input", text) @tempFile("input", text)
"--reindent" "--reindent"
"--indent_width=#{options.indent_size}" if options.indent_size? "--indent_width=#{options.indent_size}" if options.indent_size?
"--keywords=#{options.keywords}" if options.keywords? "--keywords=#{options.keywords}" if options.keywords?
"--identifiers=#{options.identifiers}" if options.identifiers? "--identifiers=#{options.identifiers}" if options.identifiers?
], help: { ], help: {
link: "https://github.com/andialbrecht/sqlparse" link: "https://github.com/andialbrecht/sqlparse"
}) })

View File

@ -2,14 +2,14 @@
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class TidyMarkdown extends Beautifier module.exports = class TidyMarkdown extends Beautifier
name: "Tidy Markdown" name: "Tidy Markdown"
options: { options: {
Markdown: false Markdown: false
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
return new @Promise((resolve, reject) -> return new @Promise((resolve, reject) ->
tidyMarkdown = require 'tidy-markdown' tidyMarkdown = require 'tidy-markdown'
cleanMarkdown = tidyMarkdown(text) cleanMarkdown = tidyMarkdown(text)
resolve(cleanMarkdown) resolve(cleanMarkdown)
) )

View File

@ -2,28 +2,28 @@
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
module.exports = class TypeScriptFormatter extends Beautifier module.exports = class TypeScriptFormatter extends Beautifier
name: "TypeScript Formatter" name: "TypeScript Formatter"
options: { options: {
TypeScript: true TypeScript: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
return new @Promise((resolve, reject) => return new @Promise((resolve, reject) =>
format = require("typescript-formatter/lib/formatter") format = require("typescript-formatter/lib/formatter")
formatterUtils = require("typescript-formatter/lib/utils") formatterUtils = require("typescript-formatter/lib/utils")
opts = formatterUtils.createDefaultFormatCodeOptions() opts = formatterUtils.createDefaultFormatCodeOptions()
opts.TabSize = options.tab_width or options.indent_size opts.TabSize = options.tab_width or options.indent_size
opts.IndentSize = options.indent_size opts.IndentSize = options.indent_size
opts.IndentStyle = 'space' opts.IndentStyle = 'space'
opts.convertTabsToSpaces = true opts.convertTabsToSpaces = true
@verbose('typescript', text, opts) @verbose('typescript', text, opts)
try try
result = format(text, opts) result = format(text, opts)
@verbose(result) @verbose(result)
resolve result resolve result
catch e catch e
return reject(e) return reject(e)
) )

View File

@ -65,11 +65,11 @@ module.exports = (options, cb) ->
fs.write info.fd, text or "", (err) -> fs.write info.fd, text or "", (err) ->
# console.log(err); # console.log(err);
return cb(err) if err return cb(err) if err
fs.close info.fd, (err) -> fs.close info.fd, (err) ->
# console.log(err); # console.log(err);
return cb(err) if err return cb(err) if err
cb null, info.path cb null, info.path

View File

@ -9,76 +9,76 @@ expandHomeDir = require('expand-home-dir')
_ = require('lodash') _ = require('lodash')
module.exports = class Uncrustify extends Beautifier module.exports = class Uncrustify extends Beautifier
name: "Uncrustify" name: "Uncrustify"
options: { options: {
C: true C: true
"C++": true "C++": true
"C#": true "C#": true
"Objective-C": true "Objective-C": true
D: true D: true
Pawn: true Pawn: true
Vala: true Vala: true
Java: true Java: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
# console.log('uncrustify.beautify', language, options) # console.log('uncrustify.beautify', language, options)
return new @Promise((resolve, reject) => return new @Promise((resolve, reject) =>
configPath = options.configPath configPath = options.configPath
unless configPath unless configPath
# No custom config path # No custom config path
cfg options, (error, cPath) -> cfg options, (error, cPath) ->
throw error if error throw error if error
resolve cPath resolve cPath
else else
# Has custom config path # Has custom config path
editor = atom.workspace.getActiveTextEditor() editor = atom.workspace.getActiveTextEditor()
if editor? if editor?
basePath = path.dirname(editor.getPath()) basePath = path.dirname(editor.getPath())
# console.log(basePath); # console.log(basePath);
configPath = path.resolve(basePath, configPath) configPath = path.resolve(basePath, configPath)
resolve configPath resolve configPath
else else
reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.")) reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
) )
.then((configPath) => .then((configPath) =>
# Expand Home Directory in Config Path # Expand Home Directory in Config Path
configPath = expandHomeDir(configPath) configPath = expandHomeDir(configPath)
# Select Uncrustify language # Select Uncrustify language
lang = "C" # Default is C lang = "C" # Default is C
switch language switch language
when "C" when "C"
lang = "C" lang = "C"
when "C++" when "C++"
lang = "CPP" lang = "CPP"
when "C#" when "C#"
lang = "CS" lang = "CS"
when "Objective-C", "Objective-C++" when "Objective-C", "Objective-C++"
lang = "OC+" lang = "OC+"
when "D" when "D"
lang = "D" lang = "D"
when "Pawn" when "Pawn"
lang = "PAWN" lang = "PAWN"
when "Vala" when "Vala"
lang = "VALA" lang = "VALA"
when "Java" when "Java"
lang = "JAVA" lang = "JAVA"
@run("uncrustify", [ @run("uncrustify", [
"-c" "-c"
configPath configPath
"-f" "-f"
@tempFile("input", text) @tempFile("input", text)
"-o" "-o"
outputFile = @tempFile("output", text) outputFile = @tempFile("output", text)
"-l" "-l"
lang lang
], help: { ], help: {
link: "http://sourceforge.net/projects/uncrustify/" link: "http://sourceforge.net/projects/uncrustify/"
}) })
.then(=> .then(=>
@readFile(outputFile) @readFile(outputFile)
)
) )
)

File diff suppressed because one or more lines are too long

View File

@ -1,27 +1,27 @@
module.exports = { module.exports = {
name: "C#" name: "C#"
namespace: "cs" namespace: "cs"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"C#" "C#"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
'cs' 'cs'
] ]
options: options:
configPath: configPath:
title: "Config Path" title: "Config Path"
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
} }

View File

@ -1,26 +1,26 @@
module.exports = { module.exports = {
name: "C" name: "C"
namespace: "c" namespace: "c"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"C" "C"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"c" "c"
] ]
options: options:
configPath: configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "CoffeeScript" name: "CoffeeScript"
namespace: "coffeescript" namespace: "coffeescript"
fallback: ['js'] fallback: ['js']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"CoffeeScript" "CoffeeScript"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"coffee" "coffee"
] ]
defaultBeautifier: "coffee-fmt" defaultBeautifier: "coffee-fmt"
} }

View File

@ -1,36 +1,36 @@
module.exports = { module.exports = {
name: "C++" name: "C++"
namespace: "cpp" namespace: "cpp"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"C++" "C++"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"h" "h"
"hh" "hh"
"cc" "cc"
"cpp" "cpp"
"cxx" "cxx"
"C" "C"
"c++" "c++"
"hpp" "hpp"
"hxx" "hxx"
"h++" "h++"
] ]
options: options:
configPath: configPath:
title: "Config Path" title: "Config Path"
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
} }

View File

@ -7,75 +7,75 @@ defaultIndentWithTabs = not softTabs
module.exports = { module.exports = {
name: "CSS" name: "CSS"
namespace: "css" namespace: "css"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"CSS" "CSS"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"css" "css"
] ]
defaultBeautifier: "JS Beautify" defaultBeautifier: "JS Beautify"
options: options:
# CSS # CSS
indent_size: indent_size:
type: 'integer' type: 'integer'
default: defaultIndentSize default: defaultIndentSize
minimum: 0 minimum: 0
description: "Indentation size/length" description: "Indentation size/length"
indent_char: indent_char:
type: 'string' type: 'string'
default: defaultIndentChar default: defaultIndentChar
minimum: 0 minimum: 0
description: "Indentation character" description: "Indentation character"
selector_separator_newline: selector_separator_newline:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Add a newline between multiple selectors" description: "Add a newline between multiple selectors"
newline_between_rules: newline_between_rules:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Add a newline between CSS rules" description: "Add a newline between CSS rules"
preserve_newlines: preserve_newlines:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Retain empty lines. "+ description: "Retain empty lines. "+
"Consecutive empty lines will be converted to \ "Consecutive empty lines will be converted to \
a single empty line." a single empty line."
wrap_line_length: wrap_line_length:
type: 'integer' type: 'integer'
default: 0 default: 0
description: "Maximum amount of characters per line (0 = disable)" description: "Maximum amount of characters per line (0 = disable)"
indent_comments: indent_comments:
type: 'boolean' type: 'boolean'
default: true default: true
description: "Determines whether comments should be indented." description: "Determines whether comments should be indented."
force_indentation: force_indentation:
type: 'boolean' type: 'boolean'
default: false default: false
description: "if indentation should be forcefully applied to\ description: "if indentation should be forcefully applied to\
markup even if it disruptively adds unintended whitespace \ markup even if it disruptively adds unintended whitespace \
to the documents rendered output" to the documents rendered output"
convert_quotes: convert_quotes:
type: 'string' type: 'string'
default: "none" default: "none"
description: "Convert the quote characters delimiting strings \ description: "Convert the quote characters delimiting strings \
from either double or single quotes to the other." from either double or single quotes to the other."
enum: ["none", "double", "single"] enum: ["none", "double", "single"]
align_assignments: align_assignments:
type: 'boolean' type: 'boolean'
default: false default: false
description: "If lists of assignments or properties should be \ description: "If lists of assignments or properties should be \
vertically aligned for faster and easier reading." vertically aligned for faster and easier reading."
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "CSV" name: "CSV"
description: "Comma-Separated Values" description: "Comma-Separated Values"
namespace: "csv" namespace: "csv"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"CSV" "CSV"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
'csv' 'csv'
] ]
options: [] options: []
} }

View File

@ -1,25 +1,25 @@
module.exports = { module.exports = {
name: "D" name: "D"
namespace: "d" namespace: "d"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"D" "D"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
] ]
options: options:
configPath: configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "EJS" name: "EJS"
description: "Embedded JavaScript" description: "Embedded JavaScript"
namespace: "ejs" namespace: "ejs"
fallback: ['html', 'js'] fallback: ['html', 'js']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"JavaScript Template" "JavaScript Template"
"HTML (Angular)" "HTML (Angular)"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [] extensions: []
options: [] options: []
} }

View File

@ -1,26 +1,26 @@
module.exports = { module.exports = {
name: "ERB" name: "ERB"
namespace: "erb" namespace: "erb"
fallback: ['html'] fallback: ['html']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"HTML (Ruby - ERB)" "HTML (Ruby - ERB)"
"HTML (Rails)" "HTML (Rails)"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
'erb' 'erb'
] ]
defaultBeautifier: "Pretty Diff" defaultBeautifier: "Pretty Diff"
options: [] options: []
} }

View File

@ -1,34 +1,34 @@
module.exports = { module.exports = {
name: "Fortran" name: "Fortran"
namespace: "fortran" namespace: "fortran"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Fortran - Modern" "Fortran - Modern"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"f90" "f90"
] ]
### ###
### ###
options: options:
# JavaScript # JavaScript
emacs_path: emacs_path:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to the `emacs` executable" description: "Path to the `emacs` executable"
emacs_script_path: emacs_script_path:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to the emacs script" description: "Path to the emacs script"
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "Go" name: "Go"
description: "Golang" description: "Golang"
namespace: "go" namespace: "go"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Go" "Go"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"go" "go"
] ]
options: [] options: []
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "Handlebars" name: "Handlebars"
namespace: "handlebars" namespace: "handlebars"
fallback: ['html','mustache'] fallback: ['html','mustache']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Handlebars" "Handlebars"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"hbs" "hbs"
] ]
options: [] options: []
} }

View File

@ -7,79 +7,79 @@ defaultIndentWithTabs = not softTabs
module.exports = { module.exports = {
name: "HTML" name: "HTML"
namespace: "html" namespace: "html"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"HTML" "HTML"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"html" "html"
] ]
options: options:
indent_inner_html: indent_inner_html:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Indent <head> and <body> sections." description: "Indent <head> and <body> sections."
indent_size: indent_size:
type: 'integer' type: 'integer'
default: defaultIndentSize default: defaultIndentSize
minimum: 0 minimum: 0
description: "Indentation size/length" description: "Indentation size/length"
indent_char: indent_char:
type: 'string' type: 'string'
default: defaultIndentChar default: defaultIndentChar
minimum: 0 minimum: 0
description: "Indentation character" description: "Indentation character"
brace_style: brace_style:
type: 'string' type: 'string'
default: "collapse" default: "collapse"
enum: ["collapse", "expand", "end-expand", "none"] enum: ["collapse", "expand", "end-expand", "none"]
description: "[collapse|expand|end-expand|none]" description: "[collapse|expand|end-expand|none]"
indent_scripts: indent_scripts:
type: 'string' type: 'string'
default: "normal" default: "normal"
enum: ["keep", "separate", "normal"] enum: ["keep", "separate", "normal"]
description: "[keep|separate|normal]" description: "[keep|separate|normal]"
wrap_line_length: wrap_line_length:
type: 'integer' type: 'integer'
default: 250 default: 250
description: "Maximum characters per line (0 disables)" description: "Maximum characters per line (0 disables)"
wrap_attributes: wrap_attributes:
type: 'string' type: 'string'
default: "auto" default: "auto"
enum: ["auto", "force"] enum: ["auto", "force"]
description: "Wrap attributes to new lines [auto|force]" description: "Wrap attributes to new lines [auto|force]"
wrap_attributes_indent_size: wrap_attributes_indent_size:
type: 'integer' type: 'integer'
default: defaultIndentSize default: defaultIndentSize
minimum: 0 minimum: 0
description: "Indent wrapped attributes to after N characters" description: "Indent wrapped attributes to after N characters"
preserve_newlines: preserve_newlines:
type: 'boolean' type: 'boolean'
default: true default: true
description: "Preserve line-breaks" description: "Preserve line-breaks"
max_preserve_newlines: max_preserve_newlines:
type: 'integer' type: 'integer'
default: 10 default: 10
description: "Number of line-breaks to be preserved in one chunk" description: "Number of line-breaks to be preserved in one chunk"
unformatted: unformatted:
type: 'array' type: 'array'
default: ['a', 'sub', 'sup', 'b', 'i', 'u'] default: ['a', 'sub', 'sup', 'b', 'i', 'u']
items: items:
type: 'string' type: 'string'
description: "List of tags (defaults to inline) that should not be reformatted" description: "List of tags (defaults to inline) that should not be reformatted"
end_with_newline: end_with_newline:
type: 'boolean' type: 'boolean'
default: false default: false
description: "End output with newline" description: "End output with newline"
} }

View File

@ -67,10 +67,10 @@ module.exports = class Languages
Constructor Constructor
### ###
constructor: -> constructor: ->
@languages = _.map(@languageNames, (name) -> @languages = _.map(@languageNames, (name) ->
require("./#{name}") require("./#{name}")
) )
@namespaces = _.map(@languages, (language) -> language.namespace) @namespaces = _.map(@languages, (language) -> language.namespace)
### ###
Get language for grammar and extension Get language for grammar and extension
@ -78,8 +78,8 @@ module.exports = class Languages
getLanguages: ({name, namespace, grammar, extension}) -> getLanguages: ({name, namespace, grammar, extension}) ->
# console.log('getLanguages', name, namespace, grammar, extension, @languages) # console.log('getLanguages', name, namespace, grammar, extension, @languages)
_.union( _.union(
_.filter(@languages, (language) -> _.isEqual(language.name, name)) _.filter(@languages, (language) -> _.isEqual(language.name, name))
_.filter(@languages, (language) -> _.isEqual(language.namespace, namespace)) _.filter(@languages, (language) -> _.isEqual(language.namespace, namespace))
_.filter(@languages, (language) -> _.contains(language.grammars, grammar)) _.filter(@languages, (language) -> _.contains(language.grammars, grammar))
_.filter(@languages, (language) -> _.contains(language.extensions, extension)) _.filter(@languages, (language) -> _.contains(language.extensions, extension))
) )

View File

@ -1,26 +1,26 @@
module.exports = { module.exports = {
name: "Java" name: "Java"
namespace: "java" namespace: "java"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Java" "Java"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"java" "java"
] ]
options: options:
configPath: configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
} }

View File

@ -7,103 +7,103 @@ defaultIndentWithTabs = not softTabs
module.exports = { module.exports = {
name: "JavaScript" name: "JavaScript"
namespace: "js" namespace: "js"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"JavaScript" "JavaScript"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"js" "js"
] ]
defaultBeautifier: "JS Beautify" defaultBeautifier: "JS Beautify"
### ###
### ###
options: options:
# JavaScript # JavaScript
indent_size: indent_size:
type: 'integer' type: 'integer'
default: defaultIndentSize default: defaultIndentSize
minimum: 0 minimum: 0
description: "Indentation size/length" description: "Indentation size/length"
indent_char: indent_char:
type: 'string' type: 'string'
default: defaultIndentChar default: defaultIndentChar
description: "Indentation character" description: "Indentation character"
indent_level: indent_level:
type: 'integer' type: 'integer'
default: 0 default: 0
description: "Initial indentation level" description: "Initial indentation level"
indent_with_tabs: indent_with_tabs:
type: 'boolean' type: 'boolean'
default: defaultIndentWithTabs default: defaultIndentWithTabs
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`" description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
preserve_newlines: preserve_newlines:
type: 'boolean' type: 'boolean'
default: true default: true
description: "Preserve line-breaks" description: "Preserve line-breaks"
max_preserve_newlines: max_preserve_newlines:
type: 'integer' type: 'integer'
default: 10 default: 10
description: "Number of line-breaks to be preserved in one chunk" description: "Number of line-breaks to be preserved in one chunk"
space_in_paren: space_in_paren:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Add padding spaces within paren, ie. f( a, b )" description: "Add padding spaces within paren, ie. f( a, b )"
jslint_happy: jslint_happy:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Enable jslint-stricter mode" description: "Enable jslint-stricter mode"
space_after_anon_function: space_after_anon_function:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Add a space before an anonymous function's parens, ie. function ()" description: "Add a space before an anonymous function's parens, ie. function ()"
brace_style: brace_style:
type: 'string' type: 'string'
default: "collapse" default: "collapse"
enum: ["collapse", "expand", "end-expand", "none"] enum: ["collapse", "expand", "end-expand", "none"]
description: "[collapse|expand|end-expand|none]" description: "[collapse|expand|end-expand|none]"
break_chained_methods: break_chained_methods:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Break chained method calls across subsequent lines" description: "Break chained method calls across subsequent lines"
keep_array_indentation: keep_array_indentation:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Preserve array indentation" description: "Preserve array indentation"
keep_function_indentation: keep_function_indentation:
type: 'boolean' type: 'boolean'
default: false default: false
description: "" description: ""
space_before_conditional: space_before_conditional:
type: 'boolean' type: 'boolean'
default: true default: true
description: "" description: ""
eval_code: eval_code:
type: 'boolean' type: 'boolean'
default: false default: false
description: "" description: ""
unescape_strings: unescape_strings:
type: 'boolean' type: 'boolean'
default: false default: false
description: "Decode printable characters encoded in xNN notation" description: "Decode printable characters encoded in xNN notation"
wrap_line_length: wrap_line_length:
type: 'integer' type: 'integer'
default: 0 default: 0
description: "Wrap lines at next opportunity after N characters" description: "Wrap lines at next opportunity after N characters"
end_with_newline: end_with_newline:
type: 'boolean' type: 'boolean'
default: false default: false
description: "End output with newline" description: "End output with newline"
} }

View File

@ -1,21 +1,21 @@
module.exports = { module.exports = {
name: "JSON" name: "JSON"
namespace: "json" namespace: "json"
fallback: ['js'] fallback: ['js']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"JSON" "JSON"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"json" "json"
] ]
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "JSX" name: "JSX"
namespace: "jsx" namespace: "jsx"
fallback: ['js'] fallback: ['js']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"JSX" "JSX"
"JavaScript (JSX)" "JavaScript (JSX)"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"jsx", "jsx",
"js" "js"
] ]
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "LESS" name: "LESS"
namespace: "less" namespace: "less"
fallback: ['css','scss','sass'] fallback: ['css','scss','sass']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"LESS" "LESS"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
'less' 'less'
] ]
defaultBeautifier: "Pretty Diff" defaultBeautifier: "Pretty Diff"
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "Markdown" name: "Markdown"
namespace: "markdown" namespace: "markdown"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"GitHub Markdown" "GitHub Markdown"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"markdown" "markdown"
"md" "md"
] ]
options: [] options: []
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "Marko" name: "Marko"
namespace: "marko" namespace: "marko"
fallback: ['html'] fallback: ['html']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Marko" "Marko"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"marko" "marko"
] ]
options: [] options: []
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "Mustache" name: "Mustache"
namespace: "mustache" namespace: "mustache"
fallback: ['html','handlebars'] fallback: ['html','handlebars']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"HTML (Mustache)" "HTML (Mustache)"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"mustache" "mustache"
] ]
options: [] options: []
} }

View File

@ -1,31 +1,31 @@
module.exports = { module.exports = {
name: "Objective-C" name: "Objective-C"
namespace: "objectivec" namespace: "objectivec"
fallback: [] fallback: []
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Objective-C" "Objective-C"
"Objective-C++" "Objective-C++"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"m" "m"
"mm" "mm"
"h" "h"
] ]
options: options:
configPath: configPath:
title: "Config Path" title: "Config Path"
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
} }

View File

@ -1,24 +1,24 @@
module.exports = { module.exports = {
name: "Pawn" name: "Pawn"
namespace: "pawn" namespace: "pawn"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Pawn" "Pawn"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [] extensions: []
options: options:
configPath: configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
} }

View File

@ -1,26 +1,26 @@
module.exports = { module.exports = {
name: "Perl" name: "Perl"
namespace: "perl" namespace: "perl"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Perl", "Perl 6" "Perl", "Perl 6"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"pl" "pl"
] ]
options: options:
perltidy_profile: perltidy_profile:
type: 'string' type: 'string'
default: "" default: ""
description: "Specify a configuration file which will override the default name of .perltidyrc" description: "Specify a configuration file which will override the default name of .perltidyrc"
} }

View File

@ -1,35 +1,35 @@
module.exports = { module.exports = {
name: "PHP" name: "PHP"
namespace: "php" namespace: "php"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"PHP" "PHP"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"php" "php"
] ]
options: options:
cs_fixer_path: cs_fixer_path:
title: "PHP-CS-Fixer Path" title: "PHP-CS-Fixer Path"
type: 'string' type: 'string'
default: "" default: ""
description: "Path to the `php-cs-fixer` CLI executable" description: "Path to the `php-cs-fixer` CLI executable"
fixers: fixers:
type: 'string' type: 'string'
default: "" default: ""
description: "Add fixer(s). i.e. linefeed,-short_tag,indentation" description: "Add fixer(s). i.e. linefeed,-short_tag,indentation"
level: level:
type: 'string' type: 'string'
default: "" default: ""
description: "By default, all PSR-2 fixers and some additional ones are run." description: "By default, all PSR-2 fixers and some additional ones are run."
} }

View File

@ -7,38 +7,38 @@ defaultIndentWithTabs = not softTabs
module.exports = { module.exports = {
name: "Python" name: "Python"
namespace: "python" namespace: "python"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Python" "Python"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"py" "py"
] ]
options: options:
max_line_length: max_line_length:
type: 'integer' type: 'integer'
default: 79 default: 79
description: "set maximum allowed line length" description: "set maximum allowed line length"
indent_size: indent_size:
type: 'integer' type: 'integer'
default: defaultIndentSize default: defaultIndentSize
minimum: 0 minimum: 0
description: "Indentation size/length" description: "Indentation size/length"
ignore: ignore:
type: 'array' type: 'array'
default: ["E24"] default: ["E24"]
items: items:
type: 'string' type: 'string'
description: "do not fix these errors/warnings" description: "do not fix these errors/warnings"
} }

View File

@ -7,35 +7,35 @@ defaultIndentWithTabs = not softTabs
module.exports = { module.exports = {
name: "Ruby" name: "Ruby"
namespace: "ruby" namespace: "ruby"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Ruby" "Ruby"
"Ruby on Rails" "Ruby on Rails"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"rb" "rb"
] ]
options: options:
indent_size: indent_size:
type: 'integer' type: 'integer'
default: defaultIndentSize default: defaultIndentSize
minimum: 0 minimum: 0
description: "Indentation size/length" description: "Indentation size/length"
indent_char: indent_char:
type: 'string' type: 'string'
default: defaultIndentChar default: defaultIndentChar
description: "Indentation character" description: "Indentation character"
enum: [" ", "\t"] enum: [" ", "\t"]
} }

View File

@ -1,27 +1,27 @@
module.exports = { module.exports = {
name: "Rust" name: "Rust"
namespace: "rust" namespace: "rust"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Rust" "Rust"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"rs" "rs"
"rlib" "rlib"
] ]
options: options:
rustfmt_path: rustfmt_path:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to rustfmt program" description: "Path to rustfmt program"
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "Sass" name: "Sass"
namespace: "sass" namespace: "sass"
fallback: ['css', 'scss'] fallback: ['css', 'scss']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Sass" "Sass"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"sass" "sass"
] ]
defaultBeautifier: "Pretty Diff" defaultBeautifier: "Pretty Diff"
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "SCSS" name: "SCSS"
namespace: "scss" namespace: "scss"
fallback: ['css', 'sass'] fallback: ['css', 'sass']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"SCSS" "SCSS"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"scss" "scss"
] ]
defaultBeautifier: "Pretty Diff" defaultBeautifier: "Pretty Diff"
} }

View File

@ -1,22 +1,22 @@
module.exports = { module.exports = {
name: "Spacebars" name: "Spacebars"
description: "Spacebars" description: "Spacebars"
namespace: "spacebars" namespace: "spacebars"
fallback: ['html'] fallback: ['html']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Spacebars" "Spacebars"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [] extensions: []
options: [] options: []
} }

View File

@ -7,40 +7,40 @@ defaultIndentWithTabs = not softTabs
module.exports = { module.exports = {
name: "SQL" name: "SQL"
namespace: "sql" namespace: "sql"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"SQL (Rails)" "SQL (Rails)"
"SQL" "SQL"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"sql" "sql"
] ]
options: options:
# SQL # SQL
indent_size: indent_size:
type: 'integer' type: 'integer'
default: defaultIndentSize default: defaultIndentSize
minimum: 0 minimum: 0
description: "Indentation size/length" description: "Indentation size/length"
keywords: keywords:
type: 'string' type: 'string'
default: "upper" default: "upper"
description: "Change case of keywords" description: "Change case of keywords"
enum: ["lower","upper","capitalize"] enum: ["lower","upper","capitalize"]
identifiers: identifiers:
type: 'string' type: 'string'
default: "lower" default: "lower"
description: "Change case of identifiers" description: "Change case of identifiers"
enum: ["lower","upper","capitalize"] enum: ["lower","upper","capitalize"]
} }

View File

@ -1,24 +1,24 @@
module.exports = { module.exports = {
name: "Swig" name: "Swig"
namespace: "swig" namespace: "swig"
fallback: ['html'] fallback: ['html']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"HTML (Swig)" "HTML (Swig)"
"SWIG" "SWIG"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
'swig' 'swig'
] ]
options: [] options: []
} }

View File

@ -1,22 +1,22 @@
module.exports = { module.exports = {
name: "TSS" name: "TSS"
description: "Titanium Style Sheets" description: "Titanium Style Sheets"
namespace: "tss" namespace: "tss"
fallback: ['css', 'sass'] fallback: ['css', 'sass']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"TSS" "TSS"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"tss" "tss"
] ]
} }

View File

@ -1,24 +1,24 @@
module.exports = { module.exports = {
name: "Twig" name: "Twig"
description: "Twig" description: "Twig"
namespace: "twig" namespace: "twig"
fallback: ['html', 'js', 'php'] fallback: ['html', 'js', 'php']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"HTML (Twig)" "HTML (Twig)"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
'twig' 'twig'
] ]
options: [] options: []
} }

View File

@ -1,21 +1,21 @@
module.exports = { module.exports = {
name: "TypeScript" name: "TypeScript"
namespace: "typescript" namespace: "typescript"
fallback: ['js'] fallback: ['js']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"TypeScript" "TypeScript"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"ts" "ts"
] ]
} }

View File

@ -1,27 +1,27 @@
module.exports = { module.exports = {
name: "Vala" name: "Vala"
namespace: "vala" namespace: "vala"
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Vala" "Vala"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"vala" "vala"
"vapi" "vapi"
] ]
options: options:
configPath: configPath:
type: 'string' type: 'string'
default: "" default: ""
description: "Path to uncrustify config file. i.e. uncrustify.cfg" description: "Path to uncrustify config file. i.e. uncrustify.cfg"
} }

View File

@ -1,23 +1,23 @@
module.exports = { module.exports = {
name: "Visualforce" name: "Visualforce"
namespace: "visualforce" namespace: "visualforce"
fallback: ['html','xml'] fallback: ['html','xml']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"Visualforce" "Visualforce"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
"page" "page"
] ]
options: [] options: []
} }

View File

@ -1,26 +1,26 @@
module.exports = { module.exports = {
name: "XML" name: "XML"
description: "XML" description: "XML"
namespace: "xml" namespace: "xml"
fallback: ['html'] fallback: ['html']
### ###
Supported Grammars Supported Grammars
### ###
grammars: [ grammars: [
"XML" "XML"
] ]
### ###
Supported extensions Supported extensions
### ###
extensions: [ extensions: [
'xml' 'xml'
] ]
defaultBeautifier: "Pretty Diff" defaultBeautifier: "Pretty Diff"
options: [] options: []
} }

View File

@ -2,37 +2,37 @@
module.exports = module.exports =
class LoadingView extends View class LoadingView extends View
@content: -> @content: ->
@div
class: 'atom-beautify message-panel', =>
@div @div
class: 'atom-beautify message-panel', => class: 'overlay from-top', =>
@div class: "tool-panel panel-bottom", =>
@div class: "inset-panel", =>
@div class: "panel-heading", =>
@div class: 'btn-toolbar pull-right', =>
@button
class: 'btn'
click: 'hide'
'Hide'
@span
class: 'text-primary'
outlet: 'title'
'Atom Beautify'
@div @div
class: 'overlay from-top', => class: "panel-body padded select-list text-center"
@div class: "tool-panel panel-bottom", => outlet: 'body'
@div class: "inset-panel", => =>
@div class: "panel-heading", => @div =>
@div class: 'btn-toolbar pull-right', => @span
@button class: 'text-center loading loading-spinner-large inline-block'
class: 'btn' @div
click: 'hide' class: ''
'Hide' 'Beautification in progress.'
@span
class: 'text-primary'
outlet: 'title'
'Atom Beautify'
@div
class: "panel-body padded select-list text-center"
outlet: 'body'
=>
@div =>
@span
class: 'text-center loading loading-spinner-large inline-block'
@div
class: ''
'Beautification in progress.'
hide: (event, element) => hide: (event, element) =>
@detach() @detach()
show: => show: =>
if not @.hasParent() if not @.hasParent()
atom.workspace.addTopPanel(item: @) atom.workspace.addTopPanel(item: @)

View File

@ -2,80 +2,80 @@
module.exports = module.exports =
class MessageView extends View class MessageView extends View
messages: [] messages: []
@content: -> @content: ->
@div
class: 'atom-beautify message-panel', =>
@div @div
class: 'atom-beautify message-panel', => class: 'overlay from-top', =>
@div class: "tool-panel panel-bottom", =>
@div class: "inset-panel", =>
@div class: "panel-heading", =>
@div class: 'btn-toolbar pull-right', =>
@button
class: 'btn'
click: 'clearMessages'
'Clear'
@span
class: ''
outlet: 'title'
'Atom Beautify Message'
@div @div
class: 'overlay from-top', => class: "panel-body padded select-list"
@div class: "tool-panel panel-bottom", => outlet: 'body'
@div class: "inset-panel", => =>
@div class: "panel-heading", => @ol
@div class: 'btn-toolbar pull-right', => class: 'list-group',
@button outlet: 'messageItems'
class: 'btn' =>
click: 'clearMessages' @li class: 'two-lines', =>
'Clear' @div class: 'status status-removed icon icon-diff-added', ''
@span @div class: 'primary-line icon icon-alert', 'This is the title'
class: '' @div class: 'secondary-line no-icon', 'Secondary line'
outlet: 'title' @li class: 'two-lines', =>
'Atom Beautify Message' @div class: 'status status-removed icon icon-diff-added', ''
@div @div class: 'primary-line icon icon-alert', 'This is the title Currently there is no way to display a message to the user, such as errors or warnings or deprecation notices (see #40). Let\'s put a little overlay on the top for displaying such information.'
class: "panel-body padded select-list" @div class: 'secondary-line no-icon', 'This is the title Currently there is no way to display a message to the user, such as errors or warnings or deprecation notices (see #40). Let\'s put a little overlay on the top for displaying such information.'
outlet: 'body' @li class: 'two-lines', =>
=> @div class: 'status status-removed icon icon-diff-added', ''
@ol @div class: 'primary-line icon icon-alert', 'test'
class: 'list-group', @div class: 'secondary-line no-icon', 'Secondary line'
outlet: 'messageItems' @li class: 'two-lines', =>
=> @div class: 'status status-removed icon icon-diff-added', ''
@li class: 'two-lines', => @div class: 'primary-line icon icon-alert', 'This is the title'
@div class: 'status status-removed icon icon-diff-added', '' @div class: 'secondary-line no-icon', 'Secondary line'
@div class: 'primary-line icon icon-alert', 'This is the title' @li class: 'two-lines', =>
@div class: 'secondary-line no-icon', 'Secondary line' @div class: 'status status-removed icon icon-diff-added', ''
@li class: 'two-lines', => @div class: 'primary-line icon icon-alert', 'This is the title'
@div class: 'status status-removed icon icon-diff-added', '' @div class: 'secondary-line no-icon', 'Secondary line'
@div class: 'primary-line icon icon-alert', 'This is the title Currently there is no way to display a message to the user, such as errors or warnings or deprecation notices (see #40). Let\'s put a little overlay on the top for displaying such information.' @li class: 'two-lines', =>
@div class: 'secondary-line no-icon', 'This is the title Currently there is no way to display a message to the user, such as errors or warnings or deprecation notices (see #40). Let\'s put a little overlay on the top for displaying such information.' @div class: 'status status-added icon icon-diff-added', ''
@li class: 'two-lines', => @div class: 'primary-line icon icon-file-text', 'Primary line'
@div class: 'status status-removed icon icon-diff-added', '' @div class: 'secondary-line no-icon', 'Secondary line'
@div class: 'primary-line icon icon-alert', 'test'
@div class: 'secondary-line no-icon', 'Secondary line'
@li class: 'two-lines', =>
@div class: 'status status-removed icon icon-diff-added', ''
@div class: 'primary-line icon icon-alert', 'This is the title'
@div class: 'secondary-line no-icon', 'Secondary line'
@li class: 'two-lines', =>
@div class: 'status status-removed icon icon-diff-added', ''
@div class: 'primary-line icon icon-alert', 'This is the title'
@div class: 'secondary-line no-icon', 'Secondary line'
@li class: 'two-lines', =>
@div class: 'status status-added icon icon-diff-added', ''
@div class: 'primary-line icon icon-file-text', 'Primary line'
@div class: 'secondary-line no-icon', 'Secondary line'
constructor: -> constructor: ->
super super
destroy: -> destroy: ->
addMessage: (message) => addMessage: (message) =>
@messages.push(message); @messages.push(message);
@refresh() @refresh()
clearMessages: => clearMessages: =>
@messages = [] @messages = []
@refresh() @refresh()
close: (event, element) => close: (event, element) =>
@detach() @detach()
show: => show: =>
if not @.hasParent() if not @.hasParent()
atom.workspaceView.appendToTop @ atom.workspaceView.appendToTop @
refresh: => refresh: =>
# If the messages list is empty, view should be closed. # If the messages list is empty, view should be closed.
if @messages.length is 0 if @messages.length is 0
@close() @close()
else else
@show() @show()