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" : {
"level" : "error",
"value" : 4
"value" : 2
},
"line_endings" : {
"value" : "unix",

View File

@ -144,10 +144,12 @@
],
"devDependencies": {
"coffee-script": "^1.9.3",
"coffeelint": "^1.10.1",
"handlebars": "^3.0.3"
},
"scripts": {
"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", ->
beforeEach ->
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
# 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 "Beautifiers", ->
describe "Beautifiers", ->
describe "Beautifier::run", ->
describe "Beautifier::run", ->
beautifier = null
beautifier = null
beforeEach ->
beautifier = new Beautifier()
beforeEach ->
beautifier = new Beautifier()
it "should error when beautifier's program not found", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
it "should error when beautifier's program not found", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
# waitsForRuns = (fn, message, timeout) ->
# isCompleted = false
# completed = ->
# console.log('completed')
# isCompleted = true
# runs ->
# console.log('runs')
# fn(completed)
# waitsFor(->
# console.log('waitsFor', isCompleted)
# isCompleted
# , message, timeout)
#
# waitsForRuns((cb) ->
# console.log('waitsForRuns', cb)
# setTimeout(cb, 2000)
# , "Waiting for beautification to complete", 5000)
# waitsForRuns = (fn, message, timeout) ->
# isCompleted = false
# completed = ->
# console.log('completed')
# isCompleted = true
# runs ->
# console.log('runs')
# fn(completed)
# waitsFor(->
# console.log('waitsFor', isCompleted)
# isCompleted
# , message, timeout)
#
# waitsForRuns((cb) ->
# console.log('waitsForRuns', cb)
# setTimeout(cb, 2000)
# , "Waiting for beautification to complete", 5000)
waitsForPromise shouldReject: true, ->
p = beautifier.run("program", [])
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)
expect(v.code).toBe("CommandNotFound")
expect(v.description).toBe(undefined, \
'Error should not have a description.')
return v
p.then(cb, cb)
return p
waitsForPromise shouldReject: true, ->
p = beautifier.run("program", [])
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)
expect(v.code).toBe("CommandNotFound")
expect(v.description).toBe(undefined, \
'Error should not have a description.')
return v
p.then(cb, cb)
return p
it "should error with help description \
it "should error with help description \
when beautifier's program not found", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
waitsForPromise shouldReject: true, ->
help = {
link: "http://test.com"
program: "test-program"
pathOption: "Lang - Test Program Path"
}
p = beautifier.run("program", [], help: help)
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)
expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description
.indexOf(help.pathOption)).not.toBe(-1, \
"Error should have a description.")
return v
p.then(cb, cb)
return p
waitsForPromise shouldReject: true, ->
help = {
link: "http://test.com"
program: "test-program"
pathOption: "Lang - Test Program Path"
}
p = beautifier.run("program", [], help: help)
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)
expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description
.indexOf(help.pathOption)).not.toBe(-1, \
"Error should have a description.")
return v
p.then(cb, cb)
return p
it "should error with Windows-specific help description \
it "should error with Windows-specific help description \
when beautifier's program not found", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
waitsForPromise shouldReject: true, ->
help = {
link: "http://test.com"
program: "test-program"
pathOption: "Lang - Test Program Path"
}
# Force to be Windows
beautifier.isWindows = true
terminal = 'CMD prompt'
whichCmd = "where.exe"
# Process
p = beautifier.run("program", [], help: help)
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)
expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description
.indexOf(help.pathOption)).not.toBe(-1, \
"Error should have a description.")
expect(v.description
.indexOf(terminal)).not.toBe(-1, \
"Error should have a description including \
waitsForPromise shouldReject: true, ->
help = {
link: "http://test.com"
program: "test-program"
pathOption: "Lang - Test Program Path"
}
# Force to be Windows
beautifier.isWindows = true
terminal = 'CMD prompt'
whichCmd = "where.exe"
# Process
p = beautifier.run("program", [], help: help)
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)
expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description
.indexOf(help.pathOption)).not.toBe(-1, \
"Error should have a description.")
expect(v.description
.indexOf(terminal)).not.toBe(-1, \
"Error should have a description including \
'#{terminal}' in message.")
expect(v.description
.indexOf(whichCmd)).not.toBe(-1, \
"Error should have a description including \
expect(v.description
.indexOf(whichCmd)).not.toBe(-1, \
"Error should have a description including \
'#{whichCmd}' in message.")
return v
p.then(cb, cb)
return p
return v
p.then(cb, cb)
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", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
waitsForPromise shouldReject: true, ->
help = {
link: "http://test.com"
program: "test-program"
pathOption: "Lang - Test Program Path"
}
# Force to be Mac/Linux (not Windows)
beautifier.isWindows = false
terminal = "Terminal"
whichCmd = "which"
# Process
p = beautifier.run("program", [], help: help)
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)
expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description
.indexOf(terminal)).not.toBe(-1, \
"Error should have a description including \
waitsForPromise shouldReject: true, ->
help = {
link: "http://test.com"
program: "test-program"
pathOption: "Lang - Test Program Path"
}
# Force to be Mac/Linux (not Windows)
beautifier.isWindows = false
terminal = "Terminal"
whichCmd = "which"
# Process
p = beautifier.run("program", [], help: help)
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)
expect(v.code).toBe("CommandNotFound")
expect(v.description).not.toBe(null)
expect(v.description.indexOf(help.link)).not.toBe(-1)
expect(v.description.indexOf(help.program)).not.toBe(-1)
expect(v.description
.indexOf(terminal)).not.toBe(-1, \
"Error should have a description including \
'#{terminal}' in message.")
expect(v.description
.indexOf(whichCmd)).not.toBe(-1, \
"Error should have a description including \
expect(v.description
.indexOf(whichCmd)).not.toBe(-1, \
"Error should have a description including \
'#{whichCmd}' in message.")
return v
p.then(cb, cb)
return p
return v
p.then(cb, cb)
return p

View File

@ -9,128 +9,128 @@ path = require 'path'
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 ->
beautifier = new PHPCSFixer()
# console.log('new beautifier')
# 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
OSSpecificSpecs = ->
text = "<?php echo \"test\"; ?>"
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 ->
beautifier = new PHPCSFixer()
# console.log('new beautifier')
failWhichProgram = (failingProgram) ->
it "should error when '#{failingProgram}' not found", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
OSSpecificSpecs = ->
text = "<?php echo \"test\"; ?>"
if not beautifier.isWindows and failingProgram is "php"
# Only applicable on Windows
return
it "should error when beautifier's program not found", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
waitsForPromise shouldReject: true, ->
language = "PHP"
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, ->
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
oldSpawn = beautifier.spawn.bind(beautifier)
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 = (failingProgram) ->
it "should error when '#{failingProgram}' not found", ->
expect(beautifier).not.toBe(null)
expect(beautifier instanceof Beautifier).toBe(true)
failWhichProgram('php')
failWhichProgram('php-cs-fixer')
if not beautifier.isWindows and failingProgram is "php"
# Only applicable on Windows
return
describe "Mac/Linux", ->
waitsForPromise shouldReject: true, ->
language = "PHP"
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}")
beforeEach ->
# console.log('mac/linx')
beautifier.isWindows = false
oldSpawn = beautifier.spawn.bind(beautifier)
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
do OSSpecificSpecs
failWhichProgram('php')
failWhichProgram('php-cs-fixer')
describe "Windows", ->
describe "Mac/Linux", ->
beforeEach ->
# console.log('windows')
beautifier.isWindows = true
beforeEach ->
# console.log('mac/linx')
beautifier.isWindows = false
do OSSpecificSpecs
describe "Windows", ->
beforeEach ->
# console.log('windows')
beautifier.isWindows = true
do OSSpecificSpecs
do OSSpecificSpecs

View File

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

View File

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

View File

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

View File

@ -9,193 +9,193 @@ which = require('which')
module.exports = class Beautifier
###
Promise
###
Promise: Promise
###
Promise
###
Promise: Promise
###
Name of Beautifier
###
name: 'Beautifier'
###
Name of Beautifier
###
name: 'Beautifier'
###
Supported Options
###
Supported Options
Enable options for supported languages.
- <string:language>:<boolean:all_options_enabled>
- <string:language>:<string:option_key>:<boolean:enabled>
- <string:language>:<string:option_key>:<string:rename>
- <string:language>:<string:option_key>:<function:transform>
- <string:language>:<string:option_key>:<array:mapper>
###
options: {}
Enable options for supported languages.
- <string:language>:<boolean:all_options_enabled>
- <string:language>:<string:option_key>:<boolean:enabled>
- <string:language>:<string:option_key>:<string:rename>
- <string:language>:<string:option_key>:<function:transform>
- <string:language>:<string:option_key>:<array:mapper>
###
Supported languages by this Beautifier
Extracted from the keys of the `options` field.
###
languages: null
###
options: {}
###
Beautify text
Override this method in subclasses
###
beautify: null
###
Supported languages by this Beautifier
###
Show deprecation warning to user.
###
deprecate: (warning) ->
atom.notifications?.addWarning(warning)
Extracted from the keys of the `options` field.
###
languages: null
###
Beautify text
Override this method in subclasses
###
beautify: null
###
Show deprecation warning to user.
###
deprecate: (warning) ->
atom.notifications?.addWarning(warning)
###
Create temporary file
###
tempFile: (name = "atom-beautify-temp", contents = "") ->
return new Promise((resolve, reject) =>
# create temp file
temp.open(name, (err, info) =>
@debug('tempFile', name, err, info)
return reject(err) if err
fs.write(info.fd, contents, (err) =>
return reject(err) if err
fs.close(info.fd, (err) =>
return reject(err) if err
resolve(info.path)
)
)
)
###
Create temporary file
###
tempFile: (name = "atom-beautify-temp", contents = "") ->
return new Promise((resolve, reject) =>
# create temp file
temp.open(name, (err, info) =>
@debug('tempFile', name, err, info)
return reject(err) if err
fs.write(info.fd, contents, (err) =>
return reject(err) if err
fs.close(info.fd, (err) =>
return reject(err) if err
resolve(info.path)
)
)
)
)
###
Read file
###
readFile: (filePath) ->
Promise.resolve(filePath)
.then((filePath) ->
return readFile(filePath, "utf8")
###
Read file
###
readFile: (filePath) ->
Promise.resolve(filePath)
.then((filePath) ->
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
###
isWindows: do ->
return /^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)
)
)
)
###
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}'. \
###
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."
er = new Error(message)
er.code = 'CommandNotFound'
er.errno = er.code
er.syscall = 'beautifier::run'
er.file = exe
if help?
if typeof help is "object"
# Basic notice
helpStr = "See #{help.link} for program \
er = new Error(message)
er.code = 'CommandNotFound'
er.errno = er.code
er.syscall = 'beautifier::run'
er.file = exe
if help?
if typeof help is "object"
# Basic notice
helpStr = "See #{help.link} for program \
installation instructions.\n"
# Help to configure Atom Beautify for program's path
helpStr += "You can configure Atom Beautify \
# Help to configure Atom Beautify for program's path
helpStr += "You can configure Atom Beautify \
with the absolute path \
to '#{help.program or exe}' by setting \
'#{help.pathOption}' in \
the Atom Beautify package settings.\n" if help.pathOption
# Optional, additional help
helpStr += help.additional if help.additional
# Common Help
issueSearchLink =
"https://github.com/Glavin001/atom-beautify/\
# Optional, additional help
helpStr += help.additional if help.additional
# Common Help
issueSearchLink =
"https://github.com/Glavin001/atom-beautify/\
search?q=#{exe}&type=Issues"
docsLink = "https://github.com/Glavin001/\
docsLink = "https://github.com/Glavin001/\
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' \
else 'which'} #{exe}' \
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 \
your own then please create a new issue and \
ask for help.\n"
er.description = helpStr
else #if typeof help is "string"
er.description = help
return er
er.description = helpStr
else #if typeof help is "string"
er.description = help
return er
###
Run command-line interface command
###
run: (executable, args, {ignoreReturnCode, help} = {}) ->
# Flatten args first
args = _.flatten(args)
# Resolve executable and all args
Promise.all([executable, Promise.all(args)])
.then(([exeName, args]) =>
@debug('exeName, args:', exeName, args)
return new Promise((resolve, reject) =>
# Remove undefined/null values
args = _.without(args, undefined)
args = _.without(args, null)
# Get PATH and other environment variables
Promise.all([@getShellEnvironment(), @which(exeName)])
.then(([env, exePath]) =>
@debug('exePath, env:', exePath, env)
exe = exePath ? exeName
# Spawn command
options = {
env: env
}
cmd = @spawn(exe, args, options)
.then(({returnCode, stdout, stderr}) ->
# If return code is not 0 then error occured
if not ignoreReturnCode and returnCode isnt 0
reject(stderr)
else
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)
)
)
###
Run command-line interface command
###
run: (executable, args, {ignoreReturnCode, help} = {}) ->
# Flatten args first
args = _.flatten(args)
# Resolve executable and all args
Promise.all([executable, Promise.all(args)])
.then(([exeName, args]) =>
@debug('exeName, args:', exeName, args)
return new Promise((resolve, reject) =>
# Remove undefined/null values
args = _.without(args, undefined)
args = _.without(args, null)
# Get PATH and other environment variables
Promise.all([@getShellEnvironment(), @which(exeName)])
.then(([env, exePath]) =>
@debug('exePath, env:', exePath, env)
exe = exePath ? exeName
# Spawn command
options = {
env: env
}
cmd = @spawn(exe, args, options)
.then(({returnCode, stdout, stderr}) ->
# If return code is not 0 then error occured
if not ignoreReturnCode and returnCode isnt 0
reject(stderr)
else
resolve(stdout)
)
)
###
Spawn
###
spawn: (exe, args, options) ->
return new Promise((resolve, reject) =>
@debug('spawn', exe, args)
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)
.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)
)
)
)
)
###
Logger instance
###
logger: null
###
Initialize and configure Logger
###
setupLogger: ->
@logger = require('../logger')(__filename)
# @verbose(@logger)
# Merge logger methods into beautifier class
for key, method of @logger
# @verbose(key, method)
@[key] = method
@verbose("Beautifier logger has been initialized.")
###
Spawn
###
spawn: (exe, args, options) ->
return new Promise((resolve, reject) =>
@debug('spawn', exe, args)
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)
)
)
###
Constructor to setup beautifer
###
constructor: () ->
# Setup logger
@setupLogger()
# Handle global options
if @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)
###
Logger instance
###
logger: null
###
Initialize and configure Logger
###
setupLogger: ->
@logger = require('../logger')(__filename)
# @verbose(@logger)
# Merge logger methods into beautifier class
for key, method of @logger
# @verbose(key, method)
@[key] = method
@verbose("Beautifier logger has been initialized.")
###
Constructor to setup beautifer
###
constructor: () ->
# Setup logger
@setupLogger()
# Handle global options
if @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')
module.exports = class CoffeeFmt extends Beautifier
name: "coffee-fmt"
name: "coffee-fmt"
options: {
# Apply language-specific options
CoffeeScript:
tab: ["indent_size", "indent_char", "indent_with_tabs", (indentSize, indentChar, indentWithTabs) ->
return "\t" if indentWithTabs
Array(indentSize+1).join(indentChar)
]
}
options: {
# Apply language-specific options
CoffeeScript:
tab: ["indent_size", \
"indent_char", "indent_with_tabs", \
(indentSize, indentChar, indentWithTabs) ->
return "\t" if indentWithTabs
Array(indentSize+1).join(indentChar)
]
}
beautify: (text, language, options) ->
@verbose('beautify', language, options)
return new @Promise((resolve, reject) ->
# Add newLine option
options.newLine = "\n"
# Require
fmt = require('coffee-fmt')
# Format!
try
results = fmt.format(text, options)
# Return beautified CoffeeScript code
resolve(results)
catch e
reject(e)
)
beautify: (text, language, options) ->
@verbose('beautify', language, options)
return new @Promise((resolve, reject) ->
# Add newLine option
options.newLine = "\n"
# Require
fmt = require('coffee-fmt')
# Format!
try
results = fmt.format(text, options)
# Return beautified CoffeeScript code
resolve(results)
catch e
reject(e)
)

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -6,70 +6,70 @@ Requires https://github.com/FriendsOfPHP/PHP-CS-Fixer
Beautifier = require('./beautifier')
module.exports = class PHPCSFixer extends Beautifier
name: "PHP-CS-Fixer"
name: "PHP-CS-Fixer"
options: {
PHP: true
}
options: {
PHP: true
}
beautify: (text, language, options) ->
@debug('php-cs-fixer', options)
beautify: (text, language, options) ->
@debug('php-cs-fixer', options)
isWin = @isWindows
if isWin
# Find php-cs-fixer.phar script
@Promise.all([
@which(options.cs_fixer_path) if options.cs_fixer_path
@which('php-cs-fixer')
]).then((paths) =>
@debug('php-cs-fixer paths', paths)
_ = require('lodash')
# Get first valid, absolute path
phpCSFixerPath = _.find(paths, (p) -> p and p.charAt(0) is '/' )
@verbose('phpCSFixerPath', phpCSFixerPath)
@debug('phpCSFixerPath', phpCSFixerPath, paths)
# Check if PHP-CS-Fixer path was found
if phpCSFixerPath?
# Found PHP-CS-Fixer path
@run("php", [
phpCSFixerPath
"fix"
"--level=#{options.level}" if options.level
"--fixers=#{options.fixers}" if options.fixers
tempFile = @tempFile("temp", text)
], {
ignoreReturnCode: true
help: {
link: "http://php.net/manual/en/install.php"
}
})
.then(=>
@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"
})
)
isWin = @isWindows
if isWin
# Find php-cs-fixer.phar script
@Promise.all([
@which(options.cs_fixer_path) if options.cs_fixer_path
@which('php-cs-fixer')
]).then((paths) =>
@debug('php-cs-fixer paths', paths)
_ = require('lodash')
# Get first valid, absolute path
phpCSFixerPath = _.find(paths, (p) -> p and p.charAt(0) is '/' )
@verbose('phpCSFixerPath', phpCSFixerPath)
@debug('phpCSFixerPath', phpCSFixerPath, paths)
# Check if PHP-CS-Fixer path was found
if phpCSFixerPath?
# Found PHP-CS-Fixer path
@run("php", [
phpCSFixerPath
"fix"
"--level=#{options.level}" if options.level
"--fixers=#{options.fixers}" if options.fixers
tempFile = @tempFile("temp", text)
], {
ignoreReturnCode: true
help: {
link: "http://php.net/manual/en/install.php"
}
})
.then(=>
@readFile(tempFile)
)
else
@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)
)
@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
@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')
module.exports = class PrettyDiff extends Beautifier
name: "Pretty Diff"
options: {
# Apply these options first / globally, for all languages
_:
inchar: "indent_char"
insize: "indent_size"
objsort: (objsort) ->
objsort or false
preserve: ['preserve_newlines', (preserve_newlines) ->
if (preserve_newlines is true ) then \
"all" else "none"
]
cssinsertlines: "newline_between_rules"
comments: ["indent_comments", (indent_comments) ->
if (indent_comments is true) then \
"indent" else "noindent"
]
force: "force_indentation"
quoteConvert: "convert_quotes"
vertical: ['align_assignments', (align_assignments) ->
if (align_assignments is true ) then \
"all" else "none"
]
wrap: "wrap_line_length"
# Apply language-specific options
CSV: true
ERB: true
EJS: true
HTML: true
XML: true
Spacebars: true
JSX: true
JavaScript: true
CSS: true
SCSS: true
Sass: true
JSON: true
TSS: true
Twig: true
LESS: true
Swig: true
Visualforce: true
}
name: "Pretty Diff"
options: {
# Apply these options first / globally, for all languages
_:
inchar: "indent_char"
insize: "indent_size"
objsort: (objsort) ->
objsort or false
preserve: ['preserve_newlines', (preserve_newlines) ->
if (preserve_newlines is true ) then \
"all" else "none"
]
cssinsertlines: "newline_between_rules"
comments: ["indent_comments", (indent_comments) ->
if (indent_comments is true) then \
"indent" else "noindent"
]
force: "force_indentation"
quoteConvert: "convert_quotes"
vertical: ['align_assignments', (align_assignments) ->
if (align_assignments is true ) then \
"all" else "none"
]
wrap: "wrap_line_length"
# Apply language-specific options
CSV: true
ERB: true
EJS: true
HTML: true
XML: true
Spacebars: true
JSX: true
JavaScript: true
CSS: true
SCSS: true
Sass: true
JSON: true
TSS: true
Twig: true
LESS: true
Swig: true
Visualforce: true
}
beautify: (text, language, options) ->
beautify: (text, language, options) ->
return new @Promise((resolve, reject) =>
prettydiff = require("prettydiff")
_ = require('lodash')
return new @Promise((resolve, reject) =>
prettydiff = require("prettydiff")
_ = require('lodash')
# Select Prettydiff language
lang = "auto"
switch language
when "CSV"
lang = "csv"
when "EJS", "Twig"
lang = "ejs"
when "ERB"
lang = "html_ruby"
when "Handlebars", "Mustache", "Spacebars"
lang = "handlebars"
when "SGML", "Swig"
lang = "markup"
when "XML", "Visualforce"
lang = "xml"
when "HTML"
lang = "html"
when "JavaScript"
lang = "javascript"
when "JSON"
lang = "json"
when "JSX"
lang = "jsx"
when "JSTL"
lang = "jsp"
when "CSS"
lang = "css"
when "LESS"
lang = "less"
when "SCSS", "Sass"
lang = "scss"
when "TSS"
lang = "tss"
else
lang = "auto"
# Select Prettydiff language
lang = "auto"
switch language
when "CSV"
lang = "csv"
when "EJS", "Twig"
lang = "ejs"
when "ERB"
lang = "html_ruby"
when "Handlebars", "Mustache", "Spacebars"
lang = "handlebars"
when "SGML", "Swig"
lang = "markup"
when "XML", "Visualforce"
lang = "xml"
when "HTML"
lang = "html"
when "JavaScript"
lang = "javascript"
when "JSON"
lang = "json"
when "JSX"
lang = "jsx"
when "JSTL"
lang = "jsp"
when "CSS"
lang = "css"
when "LESS"
lang = "less"
when "SCSS", "Sass"
lang = "scss"
when "TSS"
lang = "tss"
else
lang = "auto"
# Prettydiff Arguments
args =
source: text
lang: lang
mode: "beautify"
# Prettydiff Arguments
args =
source: text
lang: lang
mode: "beautify"
# Merge args intos options
_.merge(options, args)
# Merge args intos options
_.merge(options, args)
# Beautify
@verbose('prettydiff', options)
output = prettydiff.api(options)
result = output[0]
# Beautify
@verbose('prettydiff', options)
output = prettydiff.api(options)
result = output[0]
# Return beautified text
resolve(result)
# Return beautified text
resolve(result)
)
)

View File

@ -6,35 +6,35 @@ Requires https://github.com/bbatsov/rubocop
Beautifier = require('./beautifier')
module.exports = class Rubocop extends Beautifier
name: "Rubocop"
name: "Rubocop"
options: {
Ruby:
indent_size: true
options: {
Ruby:
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) ->
# Generate config file
yaml = require("yaml-front-matter")
config = {
"Style/IndentationWidth":
"Width": options.indent_size
}
configStr = yaml.safeDump(config)
@debug("rubocop", config, configStr)
@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
# )
)
@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')
module.exports = class RubyBeautify extends Beautifier
name: "Ruby Beautify"
name: "Ruby Beautify"
options: {
Ruby:
indent_size: true
indent_char: true
}
options: {
Ruby:
indent_size: true
indent_char: true
}
beautify: (text, language, options) ->
@run("rbeautify", [
if options.indent_char is '\t' then "--tabs" else "--spaces"
"--indent_count", options.indent_count
@tempFile("input", text)
], help: {
link: "https://github.com/erniebrodeur/ruby-beautify"
})
beautify: (text, language, options) ->
@run("rbeautify", [
if options.indent_char is '\t' then "--tabs" else "--spaces"
"--indent_count", options.indent_count
@tempFile("input", text)
], help: {
link: "https://github.com/erniebrodeur/ruby-beautify"
})

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,37 +2,37 @@
module.exports =
class LoadingView extends View
@content: ->
@content: ->
@div
class: 'atom-beautify message-panel', =>
@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
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
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.'
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) =>
@detach()
hide: (event, element) =>
@detach()
show: =>
if not @.hasParent()
atom.workspace.addTopPanel(item: @)
show: =>
if not @.hasParent()
atom.workspace.addTopPanel(item: @)

View File

@ -2,80 +2,80 @@
module.exports =
class MessageView extends View
messages: []
@content: ->
messages: []
@content: ->
@div
class: 'atom-beautify message-panel', =>
@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
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
class: "panel-body padded select-list"
outlet: 'body'
=>
@ol
class: 'list-group',
outlet: 'messageItems'
=>
@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 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: '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.'
@li class: 'two-lines', =>
@div class: 'status status-removed icon icon-diff-added', ''
@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'
class: "panel-body padded select-list"
outlet: 'body'
=>
@ol
class: 'list-group',
outlet: 'messageItems'
=>
@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 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: '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.'
@li class: 'two-lines', =>
@div class: 'status status-removed icon icon-diff-added', ''
@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: ->
super
constructor: ->
super
destroy: ->
destroy: ->
addMessage: (message) =>
@messages.push(message);
@refresh()
addMessage: (message) =>
@messages.push(message);
@refresh()
clearMessages: =>
@messages = []
@refresh()
clearMessages: =>
@messages = []
@refresh()
close: (event, element) =>
@detach()
close: (event, element) =>
@detach()
show: =>
if not @.hasParent()
atom.workspaceView.appendToTop @
show: =>
if not @.hasParent()
atom.workspaceView.appendToTop @
refresh: =>
# If the messages list is empty, view should be closed.
if @messages.length is 0
@close()
else
@show()
refresh: =>
# If the messages list is empty, view should be closed.
if @messages.length is 0
@close()
else
@show()