See #282. Restructure internal API
Done: - Create base Beautifier class - All Languages are separate files - Options are separated for each language - Beautifiers reference applicable Languages/Options - Atom Beautify builds and tests can run - 19 failures out of 34 tests TODO: - Render Language Options to Atom Package Settings - Support for Language fallback option namespaces - Support for chosing from multiple applicable beautifiers
This commit is contained in:
parent
4915c38b2a
commit
7432334d08
|
@ -1,18 +0,0 @@
|
|||
"use strict"
|
||||
CF = require("coffee-formatter")
|
||||
module.exports = (text, options, callback) ->
|
||||
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")
|
||||
callback result
|
||||
result
|
|
@ -1,17 +0,0 @@
|
|||
"use strict"
|
||||
prettydiff = require("prettydiff")
|
||||
module.exports = (text, options, callback) ->
|
||||
args =
|
||||
source: text
|
||||
lang: "css"
|
||||
mode: "beautify"
|
||||
inchar: options.indent_char
|
||||
insize: options.indent_size
|
||||
alphasort: options.alphasort or false
|
||||
preserve: (if (options.preserve_newlines is true ) then \
|
||||
"all" else "none")
|
||||
|
||||
output = prettydiff.api(args)
|
||||
result = output[0]
|
||||
callback result
|
||||
result
|
|
@ -1,17 +0,0 @@
|
|||
###
|
||||
Requires https://github.com/hhatto/autopep8
|
||||
###
|
||||
"use strict"
|
||||
cliBeautify = require("./cli-beautify")
|
||||
getCmd = (inputPath, outputPath, options) ->
|
||||
htmlBeautifierPath = options.htmlbeautifier_path # jshint ignore: line
|
||||
|
||||
cmd = "< \"" + inputPath + "\" > \"" + outputPath + "\""
|
||||
if htmlBeautifierPath
|
||||
# Use absolute path
|
||||
"\"#{htmlBeautifierPath}\" #{cmd}"
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"htmlbeautifier #{cmd}"
|
||||
|
||||
module.exports = cliBeautify(getCmd)
|
|
@ -1,68 +0,0 @@
|
|||
###
|
||||
Requires http: //johnmacfarlane.net/pandoc/
|
||||
###
|
||||
fs = null
|
||||
yaml = null
|
||||
allowUnsafeNewFunction = null
|
||||
|
||||
getCmd = (inputPath, outputPath, options, cb) ->
|
||||
optionsStr = " --read markdown --write markdown --output \"" + outputPath + "\" \"" + inputPath + "\""
|
||||
pandocPath = options.pandoc_path # jshint ignore: line
|
||||
yamlFrontMatter = options.yaml_front_matter # jshint ignore: line
|
||||
cmd = ""
|
||||
if not pandocPath
|
||||
# Use command available in $PATH
|
||||
cmd = "pandoc" + optionsStr
|
||||
else
|
||||
# Use absolute path
|
||||
cmd = pandocPath + optionsStr
|
||||
|
||||
if yamlFrontMatter?
|
||||
# console.log("YAML Front Matter!")
|
||||
fs ?= require "fs"
|
||||
fs.readFile(inputPath, (err, contents) ->
|
||||
# console.log('readFile', err, contents)
|
||||
return cb(err) if err
|
||||
|
||||
# Parse with YAML front Matter
|
||||
yaml ?= require "yaml-front-matter"
|
||||
# console.log('Parse YAML Front Matter')
|
||||
allowUnsafeNewFunction ?= require("loophole").allowUnsafeNewFunction
|
||||
results = null
|
||||
try
|
||||
allowUnsafeNewFunction ->
|
||||
results = yaml.loadFront(contents)
|
||||
catch e
|
||||
return cb(e)
|
||||
newContents = results.__content # jshint ignore: line
|
||||
delete results.__content # jshint ignore: line
|
||||
# console.log('newContents', newContents)
|
||||
# Write out new contents to input file
|
||||
fs.writeFile(inputPath, newContents, (err) ->
|
||||
# console.log('writeFile', err)
|
||||
return cb(err) if err
|
||||
|
||||
# Completetion callback to combine YAML Front Matter and Markdown
|
||||
completionCallback = (output, callback) ->
|
||||
# console.log('Completion callback!')
|
||||
try
|
||||
# Pre-pend YAML Front Matter to top of Markdown output
|
||||
front = yaml.dump(results)
|
||||
# Check if there is valid `front` to prepend
|
||||
if front isnt "{}\n"
|
||||
output = "---\n#{front}---\n\n#{output}"
|
||||
# console.log('final output!', output)
|
||||
return callback(output)
|
||||
catch e
|
||||
return callback(e)
|
||||
# Run it all together now!
|
||||
# console.log('Run!')
|
||||
return cb(cmd, completionCallback)
|
||||
)
|
||||
)
|
||||
return # Use Callback
|
||||
else
|
||||
return cmd # Return cmd synchronously
|
||||
"use strict"
|
||||
cliBeautify = require("./cli-beautify")
|
||||
module.exports = cliBeautify(getCmd)
|
|
@ -1,28 +0,0 @@
|
|||
###
|
||||
// Requires [perltidy](http://perltidy.sourceforge.net)
|
||||
###
|
||||
|
||||
"use strict"
|
||||
|
||||
getCmd = (inputPath, outputPath, options) ->
|
||||
# console.debug "[perl-beautify] options: " + JSON.stringify(options)
|
||||
if not options.perltidy_path?
|
||||
return new Error("'Perl Perltidy Path' not set!" +
|
||||
" Please set this in the Atom Beautify package settings.")
|
||||
|
||||
args = [
|
||||
'"' + options.perltidy_path + '"'
|
||||
'--standard-output'
|
||||
'--standard-error-output'
|
||||
'--quiet'
|
||||
]
|
||||
if options.perltidy_profile
|
||||
args.push '"--profile=' + options.perltidy_profile + '"'
|
||||
args.push '"' + inputPath + '"'
|
||||
cmd = args.join(' ')
|
||||
# console.debug "[perl-beautify] cmd: " + cmd
|
||||
return cmd
|
||||
|
||||
cliBeautify = require("./cli-beautify")
|
||||
isStdout = true
|
||||
module.exports = cliBeautify(getCmd, isStdout)
|
|
@ -1,40 +0,0 @@
|
|||
###
|
||||
Requires https://github.com/FriendsOfPHP/PHP-CS-Fixer
|
||||
###
|
||||
getCmd = (inputPath, outputPath, options) ->
|
||||
phpCsFixerPath = options.cs_fixer_path # jshint ignore: line
|
||||
fixers = options.fixers
|
||||
level = options.level # jshint ignore: line
|
||||
|
||||
levelOption = ""
|
||||
fixerOption = ""
|
||||
|
||||
if level
|
||||
levelOption = " --level=#{level} "
|
||||
if fixers
|
||||
fixerOption = " --fixers=#{fixers} "
|
||||
|
||||
if process.platform == 'win32'
|
||||
cmd = "#{levelOption} #{fixerOption} \"#{inputPath}\") & move \"#{inputPath}\" \"#{outputPath}\""
|
||||
else
|
||||
cmd = "#{levelOption} #{fixerOption} \"#{inputPath}\") || (mv \"#{inputPath}\" \"#{outputPath}\")"
|
||||
|
||||
if phpCsFixerPath
|
||||
isWin = /^win/.test(process.platform)
|
||||
# Use absolute path
|
||||
if isWin
|
||||
# Windows does require `php` prefix
|
||||
# See https://github.com/Glavin001/atom-beautify/issues/269
|
||||
"php (\"#{phpCsFixerPath}\" fix #{cmd}"
|
||||
else
|
||||
# Mac & Linux do not require `php` prefix
|
||||
# See https://github.com/Glavin001/atom-beautify/pull/263
|
||||
"(\"#{phpCsFixerPath}\" fix #{cmd}"
|
||||
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"(php-cs-fixer fix #{cmd}"
|
||||
|
||||
"use strict"
|
||||
cliBeautify = require("./cli-beautify")
|
||||
module.exports = cliBeautify(getCmd)
|
|
@ -1,24 +0,0 @@
|
|||
###
|
||||
Requires https://github.com/hhatto/autopep8
|
||||
###
|
||||
getCmd = (inputPath, outputPath, options) ->
|
||||
path = options.autopep8_path # jshint ignore: line
|
||||
# jshint ignore: line
|
||||
# jshint ignore: line
|
||||
optionsStr = ""
|
||||
if options.max_line_length?
|
||||
optionsStr += "--max-line-length #{options.max_line_length}"
|
||||
if options.indent_size?
|
||||
optionsStr += " --indent-size #{options.indent_size}"
|
||||
if options.ignore?
|
||||
optionsStr += " --ignore " + options.ignore.join(",") # jshint ignore: line
|
||||
if path
|
||||
# Use absolute path
|
||||
"#{path} \"#{inputPath}\" #{optionsStr}"
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"autopep8 \"#{inputPath}\" #{optionsStr}"
|
||||
"use strict"
|
||||
cliBeautify = require("./cli-beautify")
|
||||
isStdout = true
|
||||
module.exports = cliBeautify(getCmd, isStdout)
|
|
@ -1,17 +0,0 @@
|
|||
###
|
||||
Requires https://github.com/erniebrodeur/ruby-beautify
|
||||
###
|
||||
getCmd = (inputPath, outputPath, options) ->
|
||||
path = options.rbeautify_path # jshint ignore: line
|
||||
if path
|
||||
|
||||
# Use absolute path
|
||||
"ruby \"" + path + "\" \"" + inputPath + "\""
|
||||
else
|
||||
|
||||
# Use command available in $PATH
|
||||
"rbeautify \"" + inputPath + "\""
|
||||
"use strict"
|
||||
cliBeautify = require("./cli-beautify")
|
||||
isStdout = true
|
||||
module.exports = cliBeautify(getCmd, isStdout)
|
|
@ -1,25 +0,0 @@
|
|||
###
|
||||
Requires https://github.com/andialbrecht/sqlparse
|
||||
###
|
||||
getCmd = (inputPath, outputPath, options) ->
|
||||
path = options.sqlformat_path
|
||||
|
||||
optionsStr = "--reindent"
|
||||
if options.indent_size?
|
||||
optionsStr += " --indent_width=#{options.indent_size}"
|
||||
if options.keywords?
|
||||
optionsStr += " --keywords=#{options.keywords}"
|
||||
if options.identifiers
|
||||
optionsStr += " --identifiers=#{options.identifiers}"
|
||||
|
||||
if path
|
||||
# Use absolute path
|
||||
"python \"" + path + "\" \"" + inputPath + "\" " + optionsStr
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"sqlformat \"" + inputPath + "\" " + optionsStr
|
||||
|
||||
"use strict"
|
||||
cliBeautify = require("./cli-beautify")
|
||||
isStdout = true
|
||||
module.exports = cliBeautify(getCmd, isStdout)
|
|
@ -1,17 +0,0 @@
|
|||
"use strict"
|
||||
prettydiff = require("prettydiff")
|
||||
module.exports = (text, options, callback) ->
|
||||
args =
|
||||
source: text
|
||||
lang: "tss"
|
||||
mode: "beautify"
|
||||
inchar: options.indent_char
|
||||
insize: options.indent_size
|
||||
alphasort: options.alphasort or false
|
||||
preserve: (if (options.preserve_newlines is true ) then \
|
||||
"all" else "none")
|
||||
|
||||
output = prettydiff.api(args)
|
||||
result = output[0]
|
||||
callback result
|
||||
result
|
|
@ -1,12 +0,0 @@
|
|||
"use strict"
|
||||
TF = require("typescript-formatter/typescript-toolbox/lib/formatter")
|
||||
|
||||
module.exports = (text, options, callback) ->
|
||||
opts = TF.createDefaultFormatCodeOptions()
|
||||
|
||||
opts.TabSize = options.tab_width
|
||||
opts.IndentSize = options.indent_size
|
||||
|
||||
result = TF.applyFormatterToContent(text, opts)
|
||||
callback result
|
||||
result
|
|
@ -1,44 +0,0 @@
|
|||
###
|
||||
Requires http://uncrustify.sourceforge.net/
|
||||
###
|
||||
"use strict"
|
||||
cliBeautify = require("../cli-beautify")
|
||||
cfg = require("./cfg")
|
||||
path = require("path")
|
||||
expandHomeDir = require('expand-home-dir')
|
||||
getCmd = (inputPath, outputPath, options, cb) ->
|
||||
uncrustifyPath = options.uncrustifyPath
|
||||
# console.log('Uncrustify options:', options);
|
||||
# console.log("Uncrustify path: #{uncrustifyPath}")
|
||||
# Complete callback
|
||||
done = (configPath) ->
|
||||
# Expand Home Directory in Config Path
|
||||
configPath = expandHomeDir(configPath)
|
||||
# console.log(configPath);
|
||||
if uncrustifyPath
|
||||
# Use path given by user
|
||||
cmd = "#{uncrustifyPath} -c \"#{configPath}\" -f \"#{inputPath}\" -o \"#{outputPath}\" -l \"#{lang}\""
|
||||
else
|
||||
# Use command available in $PATH
|
||||
cmd = "uncrustify -c \"#{configPath}\" -f \"#{inputPath}\" -o \"#{outputPath}\" -l \"#{lang}\""
|
||||
# console.log(cmd);
|
||||
cb cmd
|
||||
configPath = options.configPath
|
||||
lang = options.languageOverride or "C" # Default is C
|
||||
unless configPath
|
||||
# No custom config path
|
||||
cfg options, (error, cPath) ->
|
||||
throw error if error
|
||||
done cPath
|
||||
else
|
||||
# Has custom config path
|
||||
editor = atom.workspace.getActiveEditor()
|
||||
if editor?
|
||||
basePath = path.dirname(editor.getPath())
|
||||
# console.log(basePath);
|
||||
configPath = path.resolve(basePath, configPath)
|
||||
done configPath
|
||||
else
|
||||
cb(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
|
||||
return
|
||||
module.exports = cliBeautify(getCmd)
|
|
@ -1,578 +0,0 @@
|
|||
###
|
||||
Language Support and default options.
|
||||
###
|
||||
"use strict"
|
||||
# Lazy loaded dependencies
|
||||
_ = null
|
||||
extend = null
|
||||
# Language Beautifiers
|
||||
beautifyJS = null
|
||||
beautifyHTML = null
|
||||
beautifyCSS = null
|
||||
beautifySQL = null
|
||||
beautifyPerl = null
|
||||
beautifyPHP = null
|
||||
beautifyPython = null
|
||||
beautifyRuby = null
|
||||
beautifyLESS = null
|
||||
beautifyCoffeeScript = null
|
||||
uncrustifyBeautifier = null
|
||||
beautifyHTMLERB = null
|
||||
beautifyMarkdown = null
|
||||
beautifyTypeScript = null
|
||||
beautifyTSS = null
|
||||
Analytics = null
|
||||
|
||||
# Misc
|
||||
{allowUnsafeEval} = require 'loophole'
|
||||
allowUnsafeEval ->
|
||||
Analytics = require("analytics-node")
|
||||
pkg = require("../package.json")
|
||||
|
||||
# Analytics
|
||||
analyticsWriteKey = "u3c26xkae8"
|
||||
|
||||
# Get Atom defaults
|
||||
tabLength = atom.config.get('editor.tabLength')
|
||||
softTabs = atom.config.get('editor.softTabs')
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
#
|
||||
module.exports =
|
||||
|
||||
# Supported unique configuration keys
|
||||
# Used for detecting nested configurations in .jsbeautifyrc
|
||||
languages: [
|
||||
"js"
|
||||
"html"
|
||||
"css"
|
||||
"sql"
|
||||
"perl"
|
||||
"php"
|
||||
"python"
|
||||
"ruby"
|
||||
"coffeescript"
|
||||
"c"
|
||||
"cpp"
|
||||
"cs"
|
||||
"markdown"
|
||||
"objectivec"
|
||||
"java"
|
||||
"d"
|
||||
"pawn"
|
||||
"vala"
|
||||
"typescript"
|
||||
]
|
||||
|
||||
# Default options per language
|
||||
defaultLanguageOptions:
|
||||
|
||||
# jshint ignore: start
|
||||
|
||||
# JavaScript
|
||||
js_indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
js_indent_char:
|
||||
type: 'string'
|
||||
default: defaultIndentChar
|
||||
minimum: 0
|
||||
description: "Indentation character"
|
||||
js_indent_level:
|
||||
type: 'integer'
|
||||
default: 0
|
||||
description: "Initial indentation level"
|
||||
js_indent_with_tabs:
|
||||
type: 'boolean'
|
||||
default: defaultIndentWithTabs
|
||||
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
|
||||
js_preserve_newlines:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: "Preserve line-breaks"
|
||||
js_max_preserve_newlines:
|
||||
type: 'integer'
|
||||
default: 10
|
||||
description: "Number of line-breaks to be preserved in one chunk"
|
||||
js_space_in_paren:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Add padding spaces within paren, ie. f( a, b )"
|
||||
js_jslint_happy:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Enable jslint-stricter mode"
|
||||
js_space_after_anon_function:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Add a space before an anonymous function's parens, ie. function ()"
|
||||
js_brace_style:
|
||||
type: 'string'
|
||||
default: "collapse"
|
||||
enum: ["collapse", "expand", "end-expand", "none"]
|
||||
description: "[collapse|expand|end-expand|none]"
|
||||
js_break_chained_methods:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Break chained method calls across subsequent lines"
|
||||
js_keep_array_indentation:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Preserve array indentation"
|
||||
js_keep_function_indentation:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: ""
|
||||
js_space_before_conditional:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: ""
|
||||
js_eval_code:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: ""
|
||||
js_unescape_strings:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Decode printable characters encoded in xNN notation"
|
||||
js_wrap_line_length:
|
||||
type: 'integer'
|
||||
default: 0
|
||||
description: "Wrap lines at next opportunity after N characters"
|
||||
js_end_with_newline:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "End output with newline"
|
||||
|
||||
# CSS
|
||||
css_indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
css_indent_char:
|
||||
type: 'string'
|
||||
default: defaultIndentChar
|
||||
minimum: 0
|
||||
description: "Indentation character"
|
||||
css_selector_separator_newline:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Add a newline between multiple selectors"
|
||||
css_newline_between_rules:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Add a newline between CSS rules"
|
||||
css_preserve_newlines:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "(Only LESS/SASS/SCSS with Prettydiff) "+
|
||||
"Retain empty lines. "+
|
||||
"Consecutive empty lines will be converted to a single empty line."
|
||||
|
||||
|
||||
# HTML
|
||||
html_htmlbeautifier_path:
|
||||
title: "htmlbeautifier path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `htmlbeautifier` CLI executable"
|
||||
html_indent_inner_html:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Indent <head> and <body> sections."
|
||||
html_indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
html_indent_char:
|
||||
type: 'string'
|
||||
default: defaultIndentChar
|
||||
minimum: 0
|
||||
description: "Indentation character"
|
||||
html_brace_style:
|
||||
type: 'string'
|
||||
default: "collapse"
|
||||
enum: ["collapse", "expand", "end-expand", "none"]
|
||||
description: "[collapse|expand|end-expand|none]"
|
||||
html_indent_scripts:
|
||||
type: 'string'
|
||||
default: "normal"
|
||||
enum: ["keep", "separate", "normal"]
|
||||
description: "[keep|separate|normal]"
|
||||
html_wrap_line_length:
|
||||
type: 'integer'
|
||||
default: 250
|
||||
description: "Maximum characters per line (0 disables)"
|
||||
html_wrap_attributes:
|
||||
type: 'string'
|
||||
default: "auto"
|
||||
enum: ["auto", "force"]
|
||||
description: "Wrap attributes to new lines [auto|force]"
|
||||
html_wrap_attributes_indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indent wrapped attributes to after N characters"
|
||||
html_preserve_newlines:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: "Preserve line-breaks"
|
||||
html_max_preserve_newlines:
|
||||
type: 'integer'
|
||||
default: 10
|
||||
description: "Number of line-breaks to be preserved in one chunk"
|
||||
html_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"
|
||||
html_end_with_newline:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "End output with newline"
|
||||
|
||||
# SQL
|
||||
sql_indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
sql_keywords:
|
||||
type: 'string'
|
||||
default: "upper"
|
||||
description: "Change case of keywords"
|
||||
enum: ["lower","upper","capitalize"]
|
||||
sql_identifiers:
|
||||
type: 'string'
|
||||
default: "lower"
|
||||
description: "Change case of identifiers"
|
||||
enum: ["lower","upper","capitalize"]
|
||||
sql_sqlformat_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `sqlformat` CLI executable"
|
||||
|
||||
# Markdown
|
||||
markdown_pandoc_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `pandoc` CLI executable"
|
||||
markdown_yaml_front_matter:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: "Should also format YAML Front Matter (Jekyll) in Markdown"
|
||||
|
||||
# Perl
|
||||
perl_perltidy_path:
|
||||
type: 'string'
|
||||
default: "perltidy"
|
||||
description: "Path to the `perltidy` CLI executable"
|
||||
perl_perltidy_profile:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Specify a configuration file which will override the default name of .perltidyrc"
|
||||
|
||||
# PHP
|
||||
php_cs_fixer_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `php-cs-fixer` CLI executable"
|
||||
php_fixers:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Add fixer(s). i.e. linefeed,-short_tag,indentation"
|
||||
php_level:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "By default, all PSR-2 fixers and some additional ones are run."
|
||||
|
||||
# Python
|
||||
python_autopep8_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `autopep8` CLI executable"
|
||||
python_max_line_length:
|
||||
type: 'integer'
|
||||
default: 79
|
||||
description: "set maximum allowed line length"
|
||||
python_indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
python_ignore:
|
||||
type: 'array'
|
||||
default: ["E24"]
|
||||
items:
|
||||
type: 'string'
|
||||
description: "do not fix these errors/warnings"
|
||||
|
||||
# Ruby
|
||||
ruby_rbeautify_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `rbeautify` CLI executable"
|
||||
|
||||
# C
|
||||
c_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
c_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
# C++
|
||||
cpp_uncrustifyPath:
|
||||
title: "C++ Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
cpp_configPath:
|
||||
title: "C++ Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
# Objective-C
|
||||
objectivec_uncrustifyPath:
|
||||
title: "Objective-C Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
objectivec_configPath:
|
||||
title: "Objective-C Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
# C#
|
||||
cs_uncrustifyPath:
|
||||
title: "C# Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
cs_configPath:
|
||||
title: "C# Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
# D
|
||||
d_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
d_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
# Java
|
||||
java_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
java_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
# Pawn
|
||||
pawn_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
pawn_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
# VALA
|
||||
vala_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
vala_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
# jshint ignore: end
|
||||
|
||||
# Process each language
|
||||
beautify: (text, grammar, allOptions, beautifyCompleted) ->
|
||||
self = this
|
||||
# Beautify!
|
||||
unsupportedGrammar = false
|
||||
options = undefined
|
||||
if atom.config.get("atom-beautify.disabledLanguages")?.indexOf(grammar) > - 1
|
||||
return beautifyCompleted(null)
|
||||
switch grammar
|
||||
# Treat JSON as JavaScript, because it will support comments.
|
||||
# And Glavin001 has tested JSON beauifying with beautifyJS.
|
||||
when "JSON", "JavaScript"
|
||||
beautifyJS ?= require("js-beautify")
|
||||
text = beautifyJS(text, self.getOptions("js", allOptions))
|
||||
beautifyCompleted text
|
||||
when "CoffeeScript"
|
||||
beautifyCoffeeScript ?= require("./langs/coffeescript-beautify")
|
||||
beautifyCoffeeScript text, self.getOptions("js", allOptions), beautifyCompleted
|
||||
when "Handlebars", "HTML (Mustache)"
|
||||
# jshint ignore: start
|
||||
allOptions.push indent_handlebars: true # Force jsbeautify to indent_handlebars
|
||||
# jshint ignore: end
|
||||
beautifyHTML ?= require("js-beautify").html
|
||||
text = beautifyHTML(text, self.getOptions("html", allOptions))
|
||||
beautifyCompleted text
|
||||
when "HTML (Liquid)", "HTML", "XML", "Marko", "Web Form/Control (C#)", "Web Handler (C#)"
|
||||
beautifyHTML ?= require("js-beautify").html
|
||||
text = beautifyHTML(text, self.getOptions("html", allOptions))
|
||||
beautifyCompleted text
|
||||
when "HTML (Ruby - ERB)", "HTML (Rails)"
|
||||
beautifyHTMLERB ?= require("./langs/html-erb-beautify")
|
||||
beautifyHTMLERB text, self.getOptions("html", allOptions), beautifyCompleted
|
||||
when "CSS"
|
||||
beautifyCSS ?= require("js-beautify").css
|
||||
text = beautifyCSS(text, self.getOptions("css", allOptions))
|
||||
beautifyCompleted text
|
||||
when "Sass", "SCSS", "LESS"
|
||||
beautifyLESS ?= require("./langs/css-prettydiff-beautify")
|
||||
beautifyLESS text, self.getOptions("css", allOptions), beautifyCompleted
|
||||
when "TSS"
|
||||
beautifyTSS ?= require("./langs/tss-prettydiff-beautify")
|
||||
beautifyTSS text, self.getOptions("css", allOptions), beautifyCompleted
|
||||
when "SQL (Rails)", "SQL"
|
||||
beautifySQL ?= require("./langs/sql-beautify")
|
||||
beautifySQL text, self.getOptions("sql", allOptions), beautifyCompleted
|
||||
when "Perl"
|
||||
beautifyPerl ?= require("./langs/perl-beautify")
|
||||
beautifyPerl text, self.getOptions("perl", allOptions), beautifyCompleted
|
||||
when "PHP"
|
||||
beautifyPHP ?= require("./langs/php-beautify")
|
||||
beautifyPHP text, self.getOptions("php", allOptions), beautifyCompleted
|
||||
when "Python"
|
||||
beautifyPython ?= require("./langs/python-beautify")
|
||||
beautifyPython text, self.getOptions("python", allOptions), beautifyCompleted
|
||||
when "Ruby", "Ruby on Rails"
|
||||
beautifyRuby ?= require("./langs/ruby-beautify")
|
||||
beautifyRuby text, self.getOptions("ruby", allOptions), beautifyCompleted
|
||||
when "GitHub Markdown"
|
||||
beautifyMarkdown ?= require("./langs/markdown-beautify")
|
||||
beautifyMarkdown text, self.getOptions("markdown", allOptions), beautifyCompleted
|
||||
when "C"
|
||||
options = self.getOptions("c", allOptions)
|
||||
options.languageOverride = "C"
|
||||
uncrustifyBeautifier ?= require("./langs/uncrustify/")
|
||||
uncrustifyBeautifier text, options, beautifyCompleted
|
||||
when "C++"
|
||||
options = self.getOptions("cpp", allOptions)
|
||||
options.languageOverride = "CPP"
|
||||
uncrustifyBeautifier ?= require("./langs/uncrustify/")
|
||||
uncrustifyBeautifier text, options, beautifyCompleted
|
||||
when "C#"
|
||||
options = self.getOptions("cs", allOptions)
|
||||
options.languageOverride = "CS"
|
||||
uncrustifyBeautifier ?= require("./langs/uncrustify/")
|
||||
uncrustifyBeautifier text, options, beautifyCompleted
|
||||
when "Objective-C", "Objective-C++"
|
||||
options = self.getOptions("objectivec", allOptions)
|
||||
options.languageOverride = "OC+"
|
||||
uncrustifyBeautifier ?= require("./langs/uncrustify/")
|
||||
uncrustifyBeautifier text, options, beautifyCompleted
|
||||
when "D"
|
||||
options = self.getOptions("d", allOptions)
|
||||
options.languageOverride = "D"
|
||||
uncrustifyBeautifier ?= require("./langs/uncrustify/")
|
||||
uncrustifyBeautifier text, options, beautifyCompleted
|
||||
when "Pawn"
|
||||
options = self.getOptions("pawn", allOptions)
|
||||
options.languageOverride = "PAWN"
|
||||
uncrustifyBeautifier ?= require("./langs/uncrustify/")
|
||||
uncrustifyBeautifier text, options, beautifyCompleted
|
||||
when "Vala"
|
||||
options = self.getOptions("vala", allOptions)
|
||||
options.languageOverride = "VALA"
|
||||
uncrustifyBeautifier ?= require("./langs/uncrustify/")
|
||||
uncrustifyBeautifier text, options, beautifyCompleted
|
||||
when "Java"
|
||||
options = self.getOptions("java", allOptions)
|
||||
options.languageOverride = "JAVA"
|
||||
uncrustifyBeautifier ?= require("./langs/uncrustify/")
|
||||
uncrustifyBeautifier text, options, beautifyCompleted
|
||||
when "TypeScript"
|
||||
beautifyTypeScript ?= require("./langs/typescript-beautify")
|
||||
beautifyTypeScript text, self.getOptions("js", allOptions), beautifyCompleted
|
||||
else
|
||||
unsupportedGrammar = true
|
||||
|
||||
# Check if Analytics is enabled
|
||||
if atom.config.get("atom-beautify.analytics")
|
||||
# Setup Analytics
|
||||
analytics = new Analytics(analyticsWriteKey)
|
||||
unless atom.config.get("atom-beautify._analyticsUserId")
|
||||
uuid = require("node-uuid")
|
||||
atom.config.set "atom-beautify._analyticsUserId", uuid.v4()
|
||||
# Setup Analytics User Id
|
||||
userId = atom.config.get("atom-beautify._analyticsUserId")
|
||||
analytics.identify userId: userId
|
||||
version = pkg.version
|
||||
analytics.track
|
||||
userId: atom.config.get("atom-beautify._analyticsUserId")
|
||||
event: "Beautify"
|
||||
properties:
|
||||
grammar: grammar
|
||||
version: version
|
||||
options: allOptions
|
||||
label: grammar
|
||||
category: version
|
||||
#
|
||||
if unsupportedGrammar
|
||||
if atom.config.get("atom-beautify.muteUnsupportedLanguageErrors")
|
||||
return beautifyCompleted(null)
|
||||
else
|
||||
throw new Error("Unsupported language for grammar '#{grammar}'.")
|
||||
return
|
||||
|
||||
getOptions: (selection, allOptions) ->
|
||||
self = this
|
||||
_ ?= require("lodash")
|
||||
extend ?= require("extend")
|
||||
# console.log(selection, allOptions);
|
||||
# Reduce all options into correctly merged options.
|
||||
options = _.reduce(allOptions, (result, currOptions) ->
|
||||
containsNested = false
|
||||
collectedConfig = {}
|
||||
key = undefined
|
||||
# Check to see if config file uses nested object format to split up js/css/html options
|
||||
for key of currOptions
|
||||
# Check if is supported language
|
||||
if _.indexOf(self.languages, key) >= 0 and typeof currOptions[key] is "object" # Check if nested object (more options in value)
|
||||
containsNested = true
|
||||
break # Found, break out of loop, no need to continue
|
||||
# console.log(containsNested, currOptions);
|
||||
# Create a flat object of config options if nested format was used
|
||||
unless containsNested
|
||||
_.merge collectedConfig, currOptions
|
||||
else
|
||||
# Merge with selected options
|
||||
# where `selection` could be `html`, `js`, 'css', etc
|
||||
# console.log(selection, currOptions[selection]);
|
||||
_.merge collectedConfig, currOptions[selection]
|
||||
extend result, collectedConfig
|
||||
, {} )
|
||||
# TODO: Clean.
|
||||
# There is a bug in nopt
|
||||
# See https://github.com/npm/nopt/issues/38#issuecomment-45971505
|
||||
# console.log('pre-clean', JSON.stringify(options));
|
||||
#options = cleanOptions(options, knownOpts);
|
||||
#console.log('post-clean', JSON.stringify(options));
|
||||
options
|
|
@ -1,195 +0,0 @@
|
|||
# Lazy loaded dependencies
|
||||
_ = require("lodash")
|
||||
path = require("path")
|
||||
fs = null
|
||||
strip = null
|
||||
yaml = null
|
||||
editorconfig = null
|
||||
beautifier = require("./language-options")
|
||||
languages = beautifier.languages
|
||||
|
||||
module.exports =
|
||||
findFileResults: {}
|
||||
|
||||
# CLI
|
||||
getUserHome: ->
|
||||
process.env.HOME or process.env.HOMEPATH or process.env.USERPROFILE
|
||||
|
||||
verifyExists: (fullPath) ->
|
||||
fs ?= require("fs")
|
||||
(if fs.existsSync(fullPath) then fullPath else null)
|
||||
|
||||
# Storage for memoized results from find file
|
||||
# Should prevent lots of directory traversal &
|
||||
# lookups when liniting an entire project
|
||||
|
||||
###
|
||||
Searches for a file with a specified name starting with
|
||||
'dir' and going all the way up either until it finds the file
|
||||
or hits the root.
|
||||
|
||||
@param {string} name filename to search for (e.g. .jshintrc)
|
||||
@param {string} dir directory to start search from (default:
|
||||
current working directory)
|
||||
@param {boolean} upwards should recurse upwards on failure? (default: true)
|
||||
|
||||
@returns {string} normalized filename
|
||||
###
|
||||
findFile: (name, dir, upwards=true) ->
|
||||
path ?= require("path")
|
||||
dir = dir or process.cwd()
|
||||
filename = path.normalize(path.join(dir, name))
|
||||
return @findFileResults[filename] if @findFileResults[filename] isnt `undefined`
|
||||
parent = path.resolve(dir, "../")
|
||||
if @verifyExists(filename)
|
||||
@findFileResults[filename] = filename
|
||||
return filename
|
||||
if dir is parent
|
||||
@findFileResults[filename] = null
|
||||
return null
|
||||
if upwards
|
||||
findFile name, parent
|
||||
else
|
||||
return null
|
||||
|
||||
###
|
||||
Tries to find a configuration file in either project directory
|
||||
or in the home directory. Configuration files are named
|
||||
'.jsbeautifyrc'.
|
||||
|
||||
@param {string} config name of the configuration file
|
||||
@param {string} file path to the file to be linted
|
||||
@param {boolean} upwards should recurse upwards on failure? (default: true)
|
||||
|
||||
@returns {string} a path to the config file
|
||||
###
|
||||
findConfig: (config, file, upwards=true) ->
|
||||
path ?= require("path")
|
||||
dir = path.dirname(path.resolve(file))
|
||||
envs = @getUserHome()
|
||||
home = path.normalize(path.join(envs, config))
|
||||
proj = @findFile(config, dir, upwards)
|
||||
return proj if proj
|
||||
return home if @verifyExists(home)
|
||||
null
|
||||
getConfigOptionsFromSettings: (langs) ->
|
||||
config = atom.config.get('atom-beautify')
|
||||
options = {}
|
||||
# console.log(langs, config);
|
||||
# Iterate over keys of the settings
|
||||
_.every _.keys(config), (k) ->
|
||||
# Check if keys start with a language
|
||||
p = k.split("_")[0]
|
||||
idx = _.indexOf(langs, p)
|
||||
# console.log(k, p, idx);
|
||||
if idx >= 0
|
||||
# Remove the language prefix and nest in options
|
||||
lang = langs[idx]
|
||||
opt = k.replace(new RegExp("^" + lang + "_"), "")
|
||||
options[lang] = options[lang] or {}
|
||||
options[lang][opt] = config[k]
|
||||
# console.log(lang, opt);
|
||||
true
|
||||
# console.log(options);
|
||||
options
|
||||
|
||||
|
||||
# Look for .jsbeautifierrc in file and home path, check env variables
|
||||
getConfig: (startPath, upwards=true) ->
|
||||
# Verify that startPath is a string
|
||||
startPath = (if (typeof startPath is "string") then startPath else "")
|
||||
return {} unless startPath
|
||||
# Get the path to the config file
|
||||
configPath = @findConfig(".jsbeautifyrc", startPath, upwards)
|
||||
externalOptions = undefined
|
||||
if configPath
|
||||
fs ?= require("fs")
|
||||
contents = fs.readFileSync(configPath,
|
||||
encoding: "utf8"
|
||||
)
|
||||
unless contents
|
||||
externalOptions = {}
|
||||
else
|
||||
try
|
||||
strip ?= require("strip-json-comments")
|
||||
externalOptions = JSON.parse(strip(contents))
|
||||
catch e
|
||||
# console.log "Failed parsing config as JSON: " + configPath
|
||||
# Attempt as YAML
|
||||
try
|
||||
yaml ?= require("yaml-front-matter")
|
||||
externalOptions = yaml.safeLoad(contents)
|
||||
catch e
|
||||
console.log "Failed parsing config as YAML and JSON: " + configPath
|
||||
externalOptions = {}
|
||||
else
|
||||
externalOptions = {}
|
||||
externalOptions
|
||||
|
||||
getOptionsForPath: (editedFilePath, editor) ->
|
||||
|
||||
# Editor Options
|
||||
editorOptions = {}
|
||||
if editor?
|
||||
# Get current Atom editor configuration
|
||||
isSelection = !!editor.getSelectedText()
|
||||
softTabs = editor.softTabs
|
||||
tabLength = editor.getTabLength()
|
||||
editorOptions =
|
||||
indent_size: (if softTabs then tabLength else 1)
|
||||
indent_char: (if softTabs then " " else "\t")
|
||||
indent_with_tabs: not softTabs
|
||||
|
||||
# From Package Settings
|
||||
configOptions = @getConfigOptionsFromSettings(languages)
|
||||
|
||||
# Get configuration in User's Home directory
|
||||
userHome = @getUserHome()
|
||||
# FAKEFILENAME forces `path` to treat as file path and it's parent directory
|
||||
# is the userHome. See implementation of findConfig
|
||||
# and how path.dirname(DIRECTORY) returns the parent directory of DIRECTORY
|
||||
homeOptions = @getConfig(path.join(userHome,"FAKEFILENAME"), false)
|
||||
|
||||
if editedFilePath?
|
||||
# Handle EditorConfig options
|
||||
# http://editorconfig.org/
|
||||
editorconfig ?= require('editorconfig');
|
||||
editorConfigOptions = editorconfig.parse(editedFilePath);
|
||||
# Transform EditorConfig to Atom Beautify's config structure and naming
|
||||
if editorConfigOptions.indent_style is 'space'
|
||||
editorConfigOptions.indent_char = " "
|
||||
# if (editorConfigOptions.indent_size)
|
||||
# editorConfigOptions.indent_size = config.indent_size
|
||||
else if editorConfigOptions.indent_style is 'tab'
|
||||
editorConfigOptions.indent_char = "\t"
|
||||
editorConfigOptions.indent_with_tabs = true
|
||||
if (editorConfigOptions.tab_width)
|
||||
editorConfigOptions.indent_size = editorConfigOptions.tab_width
|
||||
|
||||
# Get all options in configuration files from this directory upwards to root
|
||||
projectOptions = []
|
||||
p = path.dirname(editedFilePath)
|
||||
# Check if p is root (top directory)
|
||||
while p isnt path.resolve(p,"../")
|
||||
# Get config for p
|
||||
pf = path.join(p, "FAKEFILENAME")
|
||||
pc = @getConfig(pf, false)
|
||||
# Add config for p to project's config options
|
||||
projectOptions.push(pc)
|
||||
# console.log p, pc
|
||||
# Move upwards
|
||||
p = path.resolve(p,"../")
|
||||
else
|
||||
editorConfigOptions = {}
|
||||
projectOptions = []
|
||||
|
||||
# Combine all options together
|
||||
allOptions = [
|
||||
editorOptions
|
||||
configOptions
|
||||
homeOptions
|
||||
editorConfigOptions
|
||||
]
|
||||
allOptions = allOptions.concat(projectOptions)
|
||||
# console.log(allOptions)
|
||||
return allOptions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "atom-beautify",
|
||||
"main": "./lib/beautify",
|
||||
"main": "./src/beautify",
|
||||
"version": "0.24.1",
|
||||
"private": true,
|
||||
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, and SQL in Atom",
|
||||
|
@ -52,6 +52,7 @@
|
|||
"async": "^0.9.0",
|
||||
"atom-message-panel": "^1.1.1",
|
||||
"atom-space-pen-views": "^2.0.3",
|
||||
"bluebird": "^2.9.25",
|
||||
"coffee-formatter": "^0.1.1",
|
||||
"editorconfig": "^0.11.4",
|
||||
"emissary": "^1.0.0",
|
||||
|
@ -66,6 +67,7 @@
|
|||
"space-pen": "^4.3.0",
|
||||
"strip-json-comments": "^0.1.3",
|
||||
"temp": "^0.8.0",
|
||||
"tidy-markdown": "^0.3.2",
|
||||
"typescript-formatter": "~0.1.4",
|
||||
"yaml-front-matter": "^3.2.3"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Beautify = require '../lib/beautify'
|
||||
Beautify = require '../src/beautify'
|
||||
|
||||
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
|
||||
#
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
Beautify = require '../lib/beautify'
|
||||
beautifier = require "../lib/language-options"
|
||||
languages = beautifier.languages
|
||||
defaultLanguageOptions = beautifier.defaultLanguageOptions
|
||||
# Beautify = require '../src/beautify'
|
||||
Beautifiers = require "../src/beautifiers"
|
||||
beautifier = new Beautifiers()
|
||||
fs = require "fs"
|
||||
path = require "path"
|
||||
options = require "../lib/options"
|
||||
|
||||
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
|
||||
#
|
||||
|
@ -130,7 +128,7 @@ describe "BeautifyLanguages", ->
|
|||
grammarName = grammar.name
|
||||
|
||||
# Get the options
|
||||
allOptions = options.getOptionsForPath(originalTestPath)
|
||||
allOptions = beautifier.getOptionsForPath(originalTestPath)
|
||||
|
||||
beautifyCompleted = false
|
||||
completionFun = (text) ->
|
||||
|
@ -144,7 +142,9 @@ describe "BeautifyLanguages", ->
|
|||
|
||||
runs ->
|
||||
try
|
||||
beautifier.beautify originalContents, grammarName, allOptions, completionFun
|
||||
beautifier.beautify(originalContents, allOptions, grammarName, testFileName)
|
||||
.then(completionFun)
|
||||
.catch(completionFun)
|
||||
catch e
|
||||
beautifyCompleted = e
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
###
|
||||
Requires https://github.com/hhatto/autopep8
|
||||
###
|
||||
|
||||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class autopep8 extends Beautifier
|
||||
|
||||
options: {
|
||||
Python: true
|
||||
}
|
||||
|
||||
cli: (options) ->
|
||||
path = options.autopep8_path # jshint ignore: line
|
||||
if path
|
||||
# Use absolute path
|
||||
"\"#{path}\""
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"autopep8"
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run(@cli(options), [
|
||||
@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?
|
||||
])
|
|
@ -0,0 +1,136 @@
|
|||
Promise = require("bluebird")
|
||||
_ = require('lodash')
|
||||
fs = require("fs")
|
||||
temp = require("temp").track()
|
||||
exec = require("child_process").exec
|
||||
spawn = require("child_process").spawn
|
||||
readFile = Promise.promisify(fs.readFile)
|
||||
|
||||
module.exports = class Beautifier
|
||||
|
||||
###
|
||||
|
||||
###
|
||||
Promise: Promise
|
||||
|
||||
###
|
||||
Name of Beautifier
|
||||
###
|
||||
name: 'Beautifier'
|
||||
|
||||
###
|
||||
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>
|
||||
|
||||
###
|
||||
options: {}
|
||||
|
||||
###
|
||||
Supported languages by this Beautifier
|
||||
|
||||
Extracted from the keys of the `options` field.
|
||||
###
|
||||
languages: null
|
||||
|
||||
###
|
||||
Filter beautifier
|
||||
###
|
||||
filter: () ->
|
||||
|
||||
###
|
||||
Show deprecation warning to user.
|
||||
|
||||
TODO: implement this
|
||||
###
|
||||
deprecate: (warning) ->
|
||||
|
||||
###
|
||||
Create temporary file
|
||||
###
|
||||
tempFile: (name = "atom-beautify-temp", contents) ->
|
||||
return new Promise((resolve, reject) ->
|
||||
# create temp file
|
||||
temp.open(name, (err, info) ->
|
||||
# console.log(name, info)
|
||||
return reject(err) if err
|
||||
fs.write(info.fd, contents) if contents?
|
||||
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")
|
||||
)
|
||||
|
||||
###
|
||||
Run command-line interface command
|
||||
###
|
||||
run: (executable, args) ->
|
||||
console.log('run', arguments)
|
||||
# TODO: Get $PATH
|
||||
# Resolve executable
|
||||
Promise.resolve(executable)
|
||||
.then((exe) ->
|
||||
# Flatten args first
|
||||
args = _.flatten(args)
|
||||
# Resolve all args
|
||||
Promise.all(args)
|
||||
.then((args) ->
|
||||
return new Promise((resolve, reject) ->
|
||||
# Remove null values
|
||||
args = _.without(args, null)
|
||||
# Spawn command
|
||||
stdout = ""
|
||||
stderr = ""
|
||||
options = {
|
||||
env: {
|
||||
PATH: "/Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin:/Users/glavin/.rvm/gems/ruby-1.9.3-p551@global/bin:/Users/glavin/.rvm/rubies/ruby-1.9.3-p551/bin:/Users/glavin/.nvm/v0.10.32/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/Developer/android-sdk-macosx/tools:/Developer/android-sdk-macosx/platform-tools:/Users/glavin/pear/bin:/Users/glavin/gocode/bin:/Users/glavin/.rvm/bin"
|
||||
}
|
||||
}
|
||||
console.log('spawn', exe, args)
|
||||
cmd = spawn(exe, args, options)
|
||||
# add a 'data' event listener for the spawn instance
|
||||
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', (code) ->
|
||||
# If return code is not 0 then error occured
|
||||
if code isnt 0
|
||||
reject(stderr)
|
||||
else
|
||||
resolve(stdout)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
###
|
||||
Beautify text
|
||||
|
||||
Override this method in subclasses
|
||||
###
|
||||
beautify: null
|
||||
|
||||
###
|
||||
Constructor to setup beautifer
|
||||
###
|
||||
constructor: () ->
|
||||
|
||||
# Set supported languages
|
||||
@languages = _.keys(@options)
|
||||
# TODO: Remove default/catch all key, `_`
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class CoffeeFormatter extends Beautifier
|
||||
|
||||
options: {
|
||||
CoffeeScript: true
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
|
||||
return new @Promise((resolve, reject) ->
|
||||
|
||||
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
|
||||
|
||||
)
|
|
@ -0,0 +1,33 @@
|
|||
###
|
||||
Requires https://github.com/threedaymonk/htmlbeautifier
|
||||
###
|
||||
|
||||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class HTMLBeautifier extends Beautifier
|
||||
|
||||
options: {
|
||||
ERB: true
|
||||
}
|
||||
|
||||
cli: (options) ->
|
||||
htmlBeautifierPath = options.htmlbeautifier_path # jshint ignore: line
|
||||
#
|
||||
if htmlBeautifierPath
|
||||
# Use absolute path
|
||||
htmlBeautifierPath
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"htmlbeautifier"
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run(@cli(options), [
|
||||
'<'
|
||||
@tempFile("input", text)
|
||||
'>'
|
||||
outputFile = @tempFile("output")
|
||||
])
|
||||
.then(=>
|
||||
@readFile(outputFile)
|
||||
)
|
|
@ -0,0 +1,383 @@
|
|||
_ = require('lodash')
|
||||
Promise = require('bluebird')
|
||||
Languages = require('../languages/')
|
||||
path = require('path')
|
||||
|
||||
# Lazy loaded dependencies
|
||||
extend = null
|
||||
Analytics = null
|
||||
fs = null
|
||||
strip = null
|
||||
yaml = null
|
||||
editorconfig = null
|
||||
|
||||
# Misc
|
||||
{allowUnsafeEval} = require 'loophole'
|
||||
allowUnsafeEval ->
|
||||
Analytics = require("analytics-node")
|
||||
pkg = require("../../package.json")
|
||||
# Analytics
|
||||
analyticsWriteKey = "u3c26xkae8"
|
||||
|
||||
###
|
||||
Register all supported beautifiers
|
||||
###
|
||||
module.exports = class Beautifiers
|
||||
|
||||
###
|
||||
List of beautifier names
|
||||
|
||||
To register a beautifier add it's name here
|
||||
###
|
||||
beautifierNames: [
|
||||
'uncrustify'
|
||||
'autopep8'
|
||||
'coffee-formatter'
|
||||
'htmlbeautifier'
|
||||
'js-beautify'
|
||||
'perltidy'
|
||||
'php-cs-fixer'
|
||||
'prettydiff'
|
||||
'ruby-beautify'
|
||||
'sqlformat'
|
||||
'tidy-markdown'
|
||||
'typescript-formatter'
|
||||
]
|
||||
|
||||
###
|
||||
List of loaded beautifiers
|
||||
|
||||
Autogenerated in `constructor` from `beautifierNames`
|
||||
###
|
||||
beautifiers: null
|
||||
|
||||
###
|
||||
All beautifier options
|
||||
|
||||
Autogenerated in `constructor`
|
||||
###
|
||||
options: null
|
||||
|
||||
###
|
||||
Languages
|
||||
###
|
||||
languages: new Languages()
|
||||
|
||||
###
|
||||
Constructor
|
||||
###
|
||||
constructor: ->
|
||||
console.log(@)
|
||||
@beautifiers = _.map(@beautifierNames, (name) ->
|
||||
Beautifier = require("./#{name}")
|
||||
new Beautifier()
|
||||
)
|
||||
@options = @buildOptionsForBeautifiers(@beautifiers)
|
||||
|
||||
###
|
||||
|
||||
###
|
||||
buildOptionsForBeautifiers: (beautifiers) ->
|
||||
[]
|
||||
|
||||
###
|
||||
|
||||
###
|
||||
getBeautifiers: (language, options) ->
|
||||
# console.log(@beautifiers)
|
||||
_.filter(@beautifiers, (beautifier) ->
|
||||
# console.log('beautifier',beautifier, language)
|
||||
_.contains(beautifier.languages, language)
|
||||
)
|
||||
|
||||
# getBeautifiersForGrammar: (grammar) ->
|
||||
#
|
||||
# getBeautifiersForExtension: (extension) ->
|
||||
|
||||
beautify: (text, allOptions, grammar, filePath) ->
|
||||
# console.log(@)
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
|
||||
# Get language
|
||||
fileExtension = path.extname(filePath)
|
||||
languages = @languages.getLanguages(grammar, fileExtension)
|
||||
|
||||
# TODO: select appropriate language
|
||||
language = languages[0]
|
||||
|
||||
# Options for Language
|
||||
# TODO: support fallback for options
|
||||
options = @getOptions(language.namespace, allOptions) || {}
|
||||
console.log('options', options)
|
||||
|
||||
# Beautify!
|
||||
unsupportedGrammar = false
|
||||
if atom.config.get("atom-beautify.disabledLanguages")?.indexOf(grammar) > - 1
|
||||
return resolve(null)
|
||||
|
||||
# Get Beautifiers
|
||||
# console.log(grammar, language)
|
||||
beautifiers = @getBeautifiers(language.name, options)
|
||||
# console.log('beautifiers', beautifiers)
|
||||
|
||||
# Check if unsupported grammar
|
||||
if beautifiers.length < 1
|
||||
unsupportedGrammar = true
|
||||
else
|
||||
# TODO: select beautifier
|
||||
beautifier = beautifiers[0]
|
||||
console.log('beautify!', beautifier, language, options)
|
||||
beautifier.beautify(text, language.name, options)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
|
||||
# Check if Analytics is enabled
|
||||
if atom.config.get("atom-beautify.analytics")
|
||||
# Setup Analytics
|
||||
analytics = new Analytics(analyticsWriteKey)
|
||||
unless atom.config.get("atom-beautify._analyticsUserId")
|
||||
uuid = require("node-uuid")
|
||||
atom.config.set "atom-beautify._analyticsUserId", uuid.v4()
|
||||
# Setup Analytics User Id
|
||||
userId = atom.config.get("atom-beautify._analyticsUserId")
|
||||
analytics.identify userId: userId
|
||||
version = pkg.version
|
||||
analytics.track
|
||||
userId: atom.config.get("atom-beautify._analyticsUserId")
|
||||
event: "Beautify"
|
||||
properties:
|
||||
grammar: grammar
|
||||
version: version
|
||||
options: allOptions
|
||||
label: grammar
|
||||
category: version
|
||||
#
|
||||
if unsupportedGrammar
|
||||
if atom.config.get("atom-beautify.muteUnsupportedLanguageErrors")
|
||||
return resolve(null)
|
||||
else
|
||||
reject(new Error("Unsupported language for grammar '#{grammar}'."))
|
||||
|
||||
)
|
||||
|
||||
findFileResults: {}
|
||||
|
||||
# CLI
|
||||
getUserHome: ->
|
||||
process.env.HOME or process.env.HOMEPATH or process.env.USERPROFILE
|
||||
|
||||
verifyExists: (fullPath) ->
|
||||
fs ?= require("fs")
|
||||
(if fs.existsSync(fullPath) then fullPath else null)
|
||||
|
||||
# Storage for memoized results from find file
|
||||
# Should prevent lots of directory traversal &
|
||||
# lookups when liniting an entire project
|
||||
|
||||
###
|
||||
Searches for a file with a specified name starting with
|
||||
'dir' and going all the way up either until it finds the file
|
||||
or hits the root.
|
||||
|
||||
@param {string} name filename to search for (e.g. .jshintrc)
|
||||
@param {string} dir directory to start search from (default:
|
||||
current working directory)
|
||||
@param {boolean} upwards should recurse upwards on failure? (default: true)
|
||||
|
||||
@returns {string} normalized filename
|
||||
###
|
||||
findFile: (name, dir, upwards=true) ->
|
||||
path ?= require("path")
|
||||
dir = dir or process.cwd()
|
||||
filename = path.normalize(path.join(dir, name))
|
||||
return @findFileResults[filename] if @findFileResults[filename] isnt `undefined`
|
||||
parent = path.resolve(dir, "../")
|
||||
if @verifyExists(filename)
|
||||
@findFileResults[filename] = filename
|
||||
return filename
|
||||
if dir is parent
|
||||
@findFileResults[filename] = null
|
||||
return null
|
||||
if upwards
|
||||
findFile name, parent
|
||||
else
|
||||
return null
|
||||
|
||||
###
|
||||
Tries to find a configuration file in either project directory
|
||||
or in the home directory. Configuration files are named
|
||||
'.jsbeautifyrc'.
|
||||
|
||||
@param {string} config name of the configuration file
|
||||
@param {string} file path to the file to be linted
|
||||
@param {boolean} upwards should recurse upwards on failure? (default: true)
|
||||
|
||||
@returns {string} a path to the config file
|
||||
###
|
||||
findConfig: (config, file, upwards=true) ->
|
||||
path ?= require("path")
|
||||
dir = path.dirname(path.resolve(file))
|
||||
envs = @getUserHome()
|
||||
home = path.normalize(path.join(envs, config))
|
||||
proj = @findFile(config, dir, upwards)
|
||||
return proj if proj
|
||||
return home if @verifyExists(home)
|
||||
null
|
||||
getConfigOptionsFromSettings: (langs) ->
|
||||
config = atom.config.get('atom-beautify')
|
||||
options = {}
|
||||
# console.log(langs, config);
|
||||
# Iterate over keys of the settings
|
||||
_.every _.keys(config), (k) ->
|
||||
# Check if keys start with a language
|
||||
p = k.split("_")[0]
|
||||
idx = _.indexOf(langs, p)
|
||||
# console.log(k, p, idx);
|
||||
if idx >= 0
|
||||
# Remove the language prefix and nest in options
|
||||
lang = langs[idx]
|
||||
opt = k.replace(new RegExp("^" + lang + "_"), "")
|
||||
options[lang] = options[lang] or {}
|
||||
options[lang][opt] = config[k]
|
||||
# console.log(lang, opt);
|
||||
true
|
||||
# console.log(options);
|
||||
options
|
||||
|
||||
|
||||
# Look for .jsbeautifierrc in file and home path, check env variables
|
||||
getConfig: (startPath, upwards=true) ->
|
||||
# Verify that startPath is a string
|
||||
startPath = (if (typeof startPath is "string") then startPath else "")
|
||||
return {} unless startPath
|
||||
# Get the path to the config file
|
||||
configPath = @findConfig(".jsbeautifyrc", startPath, upwards)
|
||||
externalOptions = undefined
|
||||
if configPath
|
||||
fs ?= require("fs")
|
||||
contents = fs.readFileSync(configPath,
|
||||
encoding: "utf8"
|
||||
)
|
||||
unless contents
|
||||
externalOptions = {}
|
||||
else
|
||||
try
|
||||
strip ?= require("strip-json-comments")
|
||||
externalOptions = JSON.parse(strip(contents))
|
||||
catch e
|
||||
# console.log "Failed parsing config as JSON: " + configPath
|
||||
# Attempt as YAML
|
||||
try
|
||||
yaml ?= require("yaml-front-matter")
|
||||
externalOptions = yaml.safeLoad(contents)
|
||||
catch e
|
||||
console.log "Failed parsing config as YAML and JSON: " + configPath
|
||||
externalOptions = {}
|
||||
else
|
||||
externalOptions = {}
|
||||
externalOptions
|
||||
|
||||
getOptionsForPath: (editedFilePath, editor) ->
|
||||
languageNamespaces = @languages.namespaces
|
||||
|
||||
# Editor Options
|
||||
editorOptions = {}
|
||||
if editor?
|
||||
# Get current Atom editor configuration
|
||||
isSelection = !!editor.getSelectedText()
|
||||
softTabs = editor.softTabs
|
||||
tabLength = editor.getTabLength()
|
||||
editorOptions =
|
||||
indent_size: (if softTabs then tabLength else 1)
|
||||
indent_char: (if softTabs then " " else "\t")
|
||||
indent_with_tabs: not softTabs
|
||||
|
||||
# From Package Settings
|
||||
configOptions = @getConfigOptionsFromSettings(languageNamespaces)
|
||||
|
||||
# Get configuration in User's Home directory
|
||||
userHome = @getUserHome()
|
||||
# FAKEFILENAME forces `path` to treat as file path and it's parent directory
|
||||
# is the userHome. See implementation of findConfig
|
||||
# and how path.dirname(DIRECTORY) returns the parent directory of DIRECTORY
|
||||
homeOptions = @getConfig(path.join(userHome,"FAKEFILENAME"), false)
|
||||
|
||||
if editedFilePath?
|
||||
# Handle EditorConfig options
|
||||
# http://editorconfig.org/
|
||||
editorconfig ?= require('editorconfig');
|
||||
editorConfigOptions = editorconfig.parse(editedFilePath);
|
||||
# Transform EditorConfig to Atom Beautify's config structure and naming
|
||||
if editorConfigOptions.indent_style is 'space'
|
||||
editorConfigOptions.indent_char = " "
|
||||
# if (editorConfigOptions.indent_size)
|
||||
# editorConfigOptions.indent_size = config.indent_size
|
||||
else if editorConfigOptions.indent_style is 'tab'
|
||||
editorConfigOptions.indent_char = "\t"
|
||||
editorConfigOptions.indent_with_tabs = true
|
||||
if (editorConfigOptions.tab_width)
|
||||
editorConfigOptions.indent_size = editorConfigOptions.tab_width
|
||||
|
||||
# Get all options in configuration files from this directory upwards to root
|
||||
projectOptions = []
|
||||
p = path.dirname(editedFilePath)
|
||||
# Check if p is root (top directory)
|
||||
while p isnt path.resolve(p,"../")
|
||||
# Get config for p
|
||||
pf = path.join(p, "FAKEFILENAME")
|
||||
pc = @getConfig(pf, false)
|
||||
# Add config for p to project's config options
|
||||
projectOptions.push(pc)
|
||||
# console.log p, pc
|
||||
# Move upwards
|
||||
p = path.resolve(p,"../")
|
||||
else
|
||||
editorConfigOptions = {}
|
||||
projectOptions = []
|
||||
|
||||
# Combine all options together
|
||||
allOptions = [
|
||||
editorOptions
|
||||
configOptions
|
||||
homeOptions
|
||||
editorConfigOptions
|
||||
]
|
||||
allOptions = allOptions.concat(projectOptions)
|
||||
# console.log(allOptions)
|
||||
return allOptions
|
||||
|
||||
getOptions: (selection, allOptions) ->
|
||||
self = this
|
||||
_ ?= require("lodash")
|
||||
extend ?= require("extend")
|
||||
# console.log(selection, allOptions);
|
||||
# Reduce all options into correctly merged options.
|
||||
options = _.reduce(allOptions, (result, currOptions) ->
|
||||
containsNested = false
|
||||
collectedConfig = {}
|
||||
key = undefined
|
||||
# Check to see if config file uses nested object format to split up js/css/html options
|
||||
for key of currOptions
|
||||
# Check if is supported language
|
||||
if _.indexOf(self.languages, key) >= 0 and typeof currOptions[key] is "object" # Check if nested object (more options in value)
|
||||
containsNested = true
|
||||
break # Found, break out of loop, no need to continue
|
||||
# console.log(containsNested, currOptions);
|
||||
# Create a flat object of config options if nested format was used
|
||||
unless containsNested
|
||||
_.merge collectedConfig, currOptions
|
||||
else
|
||||
# Merge with selected options
|
||||
# where `selection` could be `html`, `js`, 'css', etc
|
||||
# console.log(selection, currOptions[selection]);
|
||||
_.merge collectedConfig, currOptions[selection]
|
||||
extend result, collectedConfig
|
||||
, {} )
|
||||
# TODO: Clean.
|
||||
# There is a bug in nopt
|
||||
# See https://github.com/npm/nopt/issues/38#issuecomment-45971505
|
||||
# console.log('pre-clean', JSON.stringify(options));
|
||||
#options = cleanOptions(options, knownOpts);
|
||||
#console.log('post-clean', JSON.stringify(options));
|
||||
options
|
|
@ -0,0 +1,42 @@
|
|||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class JSBeautify extends Beautifier
|
||||
|
||||
options: {
|
||||
HTML: true
|
||||
Handlebars: true
|
||||
Mustache: true
|
||||
Marko: true
|
||||
JavaScript: true
|
||||
JSON: true
|
||||
CSS: true
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
|
||||
return new @Promise((resolve, reject) ->
|
||||
console.log('JSBeautify', language, options)
|
||||
|
||||
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)
|
||||
resolve text
|
||||
when "CSS"
|
||||
beautifyCSS = require("js-beautify").css
|
||||
text = beautifyCSS(text, options)
|
||||
resolve text
|
||||
|
||||
)
|
|
@ -0,0 +1,27 @@
|
|||
###
|
||||
Requires [perltidy](http://perltidy.sourceforge.net)
|
||||
###
|
||||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class PerlTidy extends Beautifier
|
||||
|
||||
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
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run(@cli(options), [
|
||||
'--standard-output'
|
||||
'--standard-error-output'
|
||||
'--quiet'
|
||||
"--profile=#{options.perltidy_profile}" if options.perltidy_profile?
|
||||
@tempFile("input", text)
|
||||
])
|
|
@ -0,0 +1,39 @@
|
|||
###
|
||||
Requires https://github.com/FriendsOfPHP/PHP-CS-Fixer
|
||||
###
|
||||
|
||||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class PHPCSFixer extends Beautifier
|
||||
|
||||
options: {
|
||||
PHP: true
|
||||
}
|
||||
|
||||
cli: (options) ->
|
||||
phpCsFixerPath = options.cs_fixer_path # jshint ignore: line
|
||||
if phpCsFixerPath
|
||||
isWin = /^win/.test(process.platform)
|
||||
# Use absolute path
|
||||
if isWin
|
||||
# Windows does require `php` prefix
|
||||
# See https://github.com/Glavin001/atom-beautify/issues/269
|
||||
"php \"#{phpCsFixerPath}\""
|
||||
else
|
||||
# Mac & Linux do not require `php` prefix
|
||||
# See https://github.com/Glavin001/atom-beautify/pull/263
|
||||
"\"#{phpCsFixerPath}\""
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"php-cs-fixer"
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run(@cli(options), [
|
||||
"--level=#{options.level}" if options.level?
|
||||
"--fixers=#{options.fixers}" if options.fixers?
|
||||
tempFile = @tempFile("temp", text)
|
||||
])
|
||||
.then(=>
|
||||
@readFile(tempFile)
|
||||
)
|
|
@ -0,0 +1,68 @@
|
|||
"use strict"
|
||||
prettydiff = require("prettydiff")
|
||||
Beautifier = require('./beautifier')
|
||||
_ = require('lodash')
|
||||
|
||||
module.exports = class PrettyDiff extends Beautifier
|
||||
|
||||
options: {
|
||||
CSV: true
|
||||
HTML: true
|
||||
JavaScript: true
|
||||
CSS: true
|
||||
SCSS: true
|
||||
Sass: true
|
||||
JSON: true
|
||||
TSS: true
|
||||
LESS: {
|
||||
inchar: "indent_char"
|
||||
insize: "indent_size"
|
||||
alphasort: (options) ->
|
||||
options.alphasort or false
|
||||
preserve: (options) ->
|
||||
if (options.preserve_newlines is true ) then \
|
||||
"all" else "none"
|
||||
}
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
|
||||
return new @Promise((resolve, reject) ->
|
||||
|
||||
# Select Prettydiff language
|
||||
lang = "auto"
|
||||
switch language
|
||||
when "CSV"
|
||||
lang = "csv"
|
||||
when "EJS Template", "ERB Template", "Handlebars", "JSTL", "Markup (non-specific)", "Mustache Template", "SGML", "Spacebars Template", "XML"
|
||||
lang = "markup"
|
||||
when "HTML"
|
||||
lang = "html"
|
||||
when "JavaScript", "JSON", "JSX"
|
||||
lang = "javascript"
|
||||
when "CSS", "LESS", "SCSS", "SASS"
|
||||
lang = "css"
|
||||
when "TSS"
|
||||
lang = "tss"
|
||||
when "Plain text"
|
||||
lang = "text"
|
||||
else
|
||||
lang = "auto"
|
||||
|
||||
# Prettydiff Arguments
|
||||
args =
|
||||
source: text
|
||||
lang: lang
|
||||
mode: "beautify"
|
||||
|
||||
# Merge args intos options
|
||||
_.merge(options, args)
|
||||
|
||||
# Beautify
|
||||
output = prettydiff.api(options)
|
||||
result = output[0]
|
||||
|
||||
# Return beautified text
|
||||
resolve(result)
|
||||
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
###
|
||||
Requires https://github.com/erniebrodeur/ruby-beautify
|
||||
###
|
||||
|
||||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class RubyBeautify extends Beautifier
|
||||
|
||||
options: {
|
||||
SQL: true
|
||||
}
|
||||
|
||||
cli: (options) ->
|
||||
path = options.rbeautify_path # jshint ignore: line
|
||||
if path
|
||||
# Use absolute path
|
||||
"ruby \"#{path}\""
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"rbeautify"
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run(@cli(options), [
|
||||
@tempFile("input", text)
|
||||
])
|
|
@ -0,0 +1,30 @@
|
|||
###
|
||||
Requires https://github.com/andialbrecht/sqlparse
|
||||
###
|
||||
|
||||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class sqlformat extends Beautifier
|
||||
|
||||
options: {
|
||||
SQL: true
|
||||
}
|
||||
|
||||
cli: (options) ->
|
||||
path = options.sqlformat_path
|
||||
if path
|
||||
# Use absolute path
|
||||
"python \"#{path}\""
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"sqlformat"
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run(@cli(options), [
|
||||
@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?
|
||||
])
|
|
@ -0,0 +1,15 @@
|
|||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class TidyMarkdown extends Beautifier
|
||||
|
||||
options: {
|
||||
Markdown: true
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
return new @Promise((resolve, reject) ->
|
||||
tidyMarkdown = require 'tidy-markdown'
|
||||
cleanMarkdown = tidyMarkdown(text)
|
||||
resolve(cleanMarkdown)
|
||||
)
|
|
@ -0,0 +1,22 @@
|
|||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class TypeScriptFormatter extends Beautifier
|
||||
|
||||
options: {
|
||||
TypeScript: true
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
return new @Promise((resolve, reject) ->
|
||||
|
||||
TF = require("typescript-formatter/typescript-toolbox/lib/formatter")
|
||||
opts = TF.createDefaultFormatCodeOptions()
|
||||
|
||||
opts.TabSize = options.tab_width
|
||||
opts.IndentSize = options.indent_size
|
||||
|
||||
result = TF.applyFormatterToContent(text, opts)
|
||||
resolve result
|
||||
|
||||
)
|
|
@ -0,0 +1,91 @@
|
|||
###
|
||||
Requires http://uncrustify.sourceforge.net/
|
||||
###
|
||||
"use strict"
|
||||
Beautifier = require('../beautifier')
|
||||
cfg = require("./cfg")
|
||||
path = require("path")
|
||||
expandHomeDir = require('expand-home-dir')
|
||||
_ = require('lodash')
|
||||
|
||||
module.exports = class Uncrustify extends Beautifier
|
||||
|
||||
options: {
|
||||
C: true
|
||||
"C++": true
|
||||
"C#": true
|
||||
"Objective-C": true
|
||||
D: true
|
||||
Pawn: true
|
||||
Vala: true
|
||||
Java: true
|
||||
}
|
||||
|
||||
cli: (options) ->
|
||||
uncrustifyPath = options.uncrustifyPath
|
||||
if uncrustifyPath
|
||||
# Use path given by user
|
||||
"\"#{uncrustifyPath}\""
|
||||
else
|
||||
# Use command available in $PATH
|
||||
"uncrustify"
|
||||
|
||||
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.getActiveEditor()
|
||||
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(@cli(options), [
|
||||
"-c"
|
||||
configPath
|
||||
"-f"
|
||||
@tempFile("input", text)
|
||||
"-o"
|
||||
outputFile = @tempFile("output", text)
|
||||
"-l"
|
||||
lang
|
||||
])
|
||||
.then(=>
|
||||
@readFile(outputFile)
|
||||
)
|
||||
)
|
|
@ -5,10 +5,9 @@ pkg = require('../package.json')
|
|||
# Dependencies
|
||||
plugin = module.exports
|
||||
_ = require("lodash")
|
||||
beautifier = require("./language-options")
|
||||
languages = beautifier.languages
|
||||
defaultLanguageOptions = beautifier.defaultLanguageOptions
|
||||
options = require "./options"
|
||||
Beautifiers = require("./beautifiers")
|
||||
beautifier = new Beautifiers()
|
||||
defaultLanguageOptions = beautifier.options
|
||||
# Lazy loaded dependencies
|
||||
fs = null
|
||||
path = require("path")
|
||||
|
@ -20,7 +19,7 @@ LoadingView = null
|
|||
MessagePanelView = null
|
||||
PlainMessageView = null
|
||||
$ = null
|
||||
#MessageView = require "./message-view"
|
||||
#MessageView = require "./views/message-view"
|
||||
|
||||
# function cleanOptions(data, types) {
|
||||
# nopt.clean(data, types);
|
||||
|
@ -50,7 +49,7 @@ beautify = ({onSave}) ->
|
|||
path ?= require("path")
|
||||
MessagePanelView ?= require('atom-message-panel').MessagePanelView
|
||||
PlainMessageView ?= require('atom-message-panel').PlainMessageView
|
||||
LoadingView ?= require "./loading-view"
|
||||
LoadingView ?= require "./views/loading-view"
|
||||
@messagePanel ?= new MessagePanelView title: 'Atom Beautify Error Messages'
|
||||
@loadingView ?= new LoadingView()
|
||||
@loadingView.show()
|
||||
|
@ -125,7 +124,7 @@ beautify = ({onSave}) ->
|
|||
# Get editor path and configurations for paths
|
||||
editedFilePath = editor.getPath()
|
||||
# Get all options
|
||||
allOptions = options.getOptionsForPath(editedFilePath, editor)
|
||||
allOptions = beautifier.getOptionsForPath(editedFilePath, editor)
|
||||
|
||||
# Get current editor's text
|
||||
text = undefined
|
||||
|
@ -138,7 +137,9 @@ beautify = ({onSave}) ->
|
|||
grammarName = editor.getGrammar().name
|
||||
# Finally, beautify!
|
||||
try
|
||||
beautifier.beautify text, grammarName, allOptions, beautifyCompleted
|
||||
beautifier.beautify(text, allOptions, grammarName, editedFilePath)
|
||||
.then(beautifyCompleted)
|
||||
.catch(beautifyCompleted)
|
||||
catch e
|
||||
showError(e)
|
||||
return
|
||||
|
@ -161,7 +162,7 @@ beautifyFilePath = (filePath, callback) ->
|
|||
grammar = atom.grammars.selectGrammar(filePath, input)
|
||||
grammarName = grammar.name
|
||||
# Get the options
|
||||
allOptions = options.getOptionsForPath(filePath)
|
||||
allOptions = beautifier.getOptionsForPath(filePath)
|
||||
# Beautify File
|
||||
completionFun = (output) ->
|
||||
if output instanceof Error
|
||||
|
@ -174,7 +175,9 @@ beautifyFilePath = (filePath, callback) ->
|
|||
else
|
||||
return cb(new Error("Unknown beautification result #{output}."), output)
|
||||
try
|
||||
beautifier.beautify input, grammarName, allOptions, completionFun
|
||||
beautifier.beautify(input, allOptions, grammarName, filePath)
|
||||
.then(completionFun)
|
||||
.catch(completionFun)
|
||||
catch e
|
||||
return cb(e)
|
||||
)
|
||||
|
@ -270,7 +273,7 @@ debug = () ->
|
|||
|
||||
# Beautification Options
|
||||
# Get all options
|
||||
allOptions = options.getOptionsForPath(filePath, editor)
|
||||
allOptions = beautifier.getOptionsForPath(filePath, editor)
|
||||
[
|
||||
editorOptions
|
||||
configOptions
|
||||
|
@ -286,7 +289,7 @@ debug = () ->
|
|||
"Options from Atom Beautify package settings\n"+
|
||||
"```json\n#{JSON.stringify(configOptions, undefined, 4)}\n```")
|
||||
addInfo('Home Options', "\n"+
|
||||
"Options from `#{path.resolve(options.getUserHome(), '.jsbeautifyrc')}`\n"+
|
||||
"Options from `#{path.resolve(beautifier.getUserHome(), '.jsbeautifyrc')}`\n"+
|
||||
"```json\n#{JSON.stringify(homeOptions, undefined, 4)}\n```")
|
||||
addInfo('EditorConfig Options', "\n"+
|
||||
"Options from [EditorConfig](http://editorconfig.org/) file\n"+
|
|
@ -0,0 +1,39 @@
|
|||
module.exports = {
|
||||
|
||||
name: "C#"
|
||||
namespace: "cs"
|
||||
fallback: []
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"C#"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
'cs'
|
||||
]
|
||||
|
||||
options:
|
||||
# C#
|
||||
cs_uncrustifyPath:
|
||||
title: "C# Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
cs_configPath:
|
||||
title: "C# Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
module.exports = {
|
||||
|
||||
name: "C"
|
||||
namespace: "c"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"C"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"c"
|
||||
]
|
||||
|
||||
options:
|
||||
# C
|
||||
c_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
c_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
module.exports = {
|
||||
|
||||
name: "CoffeeScript"
|
||||
namespace: "coffeescript"
|
||||
fallback: ['js']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"CoffeeScript"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"coffee"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
module.exports = {
|
||||
|
||||
name: "C++"
|
||||
namespace: "cpp"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"C++"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"h"
|
||||
"cpp"
|
||||
]
|
||||
|
||||
options:
|
||||
# C++
|
||||
cpp_uncrustifyPath:
|
||||
title: "C++ Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
cpp_configPath:
|
||||
title: "C++ Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
# Get Atom defaults
|
||||
tabLength = atom.config.get('editor.tabLength')
|
||||
softTabs = atom.config.get('editor.softTabs')
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: "CSS"
|
||||
namespace: "css"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"CSS"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"css"
|
||||
]
|
||||
|
||||
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: "(Only LESS/SASS/SCSS with Prettydiff) "+
|
||||
"Retain empty lines. "+
|
||||
"Consecutive empty lines will be converted to a single empty line."
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
module.exports = {
|
||||
|
||||
name: "D"
|
||||
namespace: "d"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"D"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
]
|
||||
|
||||
options:
|
||||
# D
|
||||
d_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
d_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
module.exports = {
|
||||
|
||||
name: "ERB"
|
||||
namespace: "erb"
|
||||
fallback: ['html']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"HTML (Ruby - ERB)"
|
||||
"HTML (Rails)"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
|
||||
options: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Handlebars"
|
||||
namespace: "handlebars"
|
||||
fallback: ['html','mustache']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Handlebars"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"hbs"
|
||||
]
|
||||
|
||||
options: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
# Get Atom defaults
|
||||
tabLength = atom.config.get('editor.tabLength')
|
||||
softTabs = atom.config.get('editor.softTabs')
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: "HTML"
|
||||
namespace: "html"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"HTML"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"html"
|
||||
]
|
||||
|
||||
options:
|
||||
# HTML
|
||||
htmlbeautifier_path:
|
||||
title: "htmlbeautifier path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `htmlbeautifier` CLI executable"
|
||||
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"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
###
|
||||
Language Support and default options.
|
||||
###
|
||||
"use strict"
|
||||
# Lazy loaded dependencies
|
||||
_ = require('lodash')
|
||||
extend = null
|
||||
|
||||
# Get Atom defaults
|
||||
tabLength = atom.config.get('editor.tabLength')
|
||||
softTabs = atom.config.get('editor.softTabs')
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
#
|
||||
module.exports = class Languages
|
||||
|
||||
# Supported unique configuration keys
|
||||
# Used for detecting nested configurations in .jsbeautifyrc
|
||||
languageNames: [
|
||||
"c-sharp"
|
||||
"c"
|
||||
"coffeescript"
|
||||
"cpp"
|
||||
"css"
|
||||
"d"
|
||||
"erb"
|
||||
"handlebars"
|
||||
"html"
|
||||
"java"
|
||||
"javascript"
|
||||
"json"
|
||||
"jsx"
|
||||
"less"
|
||||
"markdown"
|
||||
'marko'
|
||||
"mustache"
|
||||
"objective-c"
|
||||
"pawn"
|
||||
"perl"
|
||||
"php"
|
||||
"python"
|
||||
"ruby"
|
||||
"sass"
|
||||
"scss"
|
||||
"sql"
|
||||
"tss"
|
||||
"typescript"
|
||||
"vala"
|
||||
]
|
||||
|
||||
###
|
||||
Languages
|
||||
###
|
||||
languages: null
|
||||
|
||||
###
|
||||
Namespaces
|
||||
###
|
||||
namespaces: null
|
||||
|
||||
###
|
||||
Constructor
|
||||
###
|
||||
constructor: ->
|
||||
@languages = _.map(@languageNames, (name) ->
|
||||
require("./#{name}")
|
||||
)
|
||||
@namespaces = _.map(@languages, (language) -> language.namespace)
|
||||
|
||||
###
|
||||
Get language for grammar and extension
|
||||
###
|
||||
getLanguages: (grammar, extension) ->
|
||||
# console.log(grammar, extension, @languages)
|
||||
_.union(
|
||||
_.filter(@languages, (language) -> _.contains(language.grammars, grammar))
|
||||
_.filter(@languages, (language) -> _.contains(language.extensions, extension))
|
||||
)
|
|
@ -0,0 +1,36 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Java"
|
||||
namespace: "java"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Java"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"java"
|
||||
]
|
||||
|
||||
options:
|
||||
# Java
|
||||
java_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
java_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
# Get Atom defaults
|
||||
tabLength = atom.config.get('editor.tabLength')
|
||||
softTabs = atom.config.get('editor.softTabs')
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: "JavaScript"
|
||||
namespace: "js"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"JavaScript"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"js"
|
||||
]
|
||||
|
||||
###
|
||||
|
||||
###
|
||||
options:
|
||||
# JavaScript
|
||||
indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
indent_char:
|
||||
type: 'string'
|
||||
default: defaultIndentChar
|
||||
minimum: 0
|
||||
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"
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
module.exports = {
|
||||
|
||||
name: "JSON"
|
||||
namespace: "json"
|
||||
fallback: ['js']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"JSON"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"json"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
module.exports = {
|
||||
|
||||
name: "JSX"
|
||||
namespace: "jsx"
|
||||
fallback: ['js']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"JSX"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"jsx"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
module.exports = {
|
||||
|
||||
name: "LESS"
|
||||
namespace: "less"
|
||||
fallback: ['css','scss','sass']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"LESS"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "PrettyDiff"
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Markdown"
|
||||
namespace: "markdown"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"GitHub Markdown"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"markdown"
|
||||
"md"
|
||||
]
|
||||
|
||||
options:
|
||||
# Markdown
|
||||
markdown_pandoc_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `pandoc` CLI executable"
|
||||
markdown_yaml_front_matter:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: "Should also format YAML Front Matter (Jekyll) in Markdown"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Marko"
|
||||
namespace: "marko"
|
||||
fallback: ['html']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Marko"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"marko"
|
||||
]
|
||||
|
||||
options: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Mustache"
|
||||
namespace: "mustache"
|
||||
fallback: ['html','handlebars']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"HTML (Mustache)"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"hbs"
|
||||
]
|
||||
|
||||
options: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Objective-C"
|
||||
namespace: "objectivec"
|
||||
fallback: []
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Objective-C"
|
||||
"Objective-C++"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
|
||||
]
|
||||
|
||||
options:
|
||||
# Objective-C
|
||||
objectivec_uncrustifyPath:
|
||||
title: "Objective-C Uncrustify Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
objectivec_configPath:
|
||||
title: "Objective-C Config Path"
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Pawn"
|
||||
namespace: "pawn"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Pawn"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
|
||||
options:
|
||||
# Pawn
|
||||
pawn_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
pawn_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Perl"
|
||||
namespace: "perl"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Perl", "Perl 6"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
]
|
||||
|
||||
options:
|
||||
# Perl
|
||||
perl_perltidy_path:
|
||||
type: 'string'
|
||||
default: "perltidy"
|
||||
description: "Path to the `perltidy` CLI executable"
|
||||
perl_perltidy_profile:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Specify a configuration file which will override the default name of .perltidyrc"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
module.exports = {
|
||||
|
||||
name: "PHP"
|
||||
namespace: "php"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"PHP"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"php"
|
||||
]
|
||||
|
||||
options:
|
||||
# PHP
|
||||
php_cs_fixer_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `php-cs-fixer` CLI executable"
|
||||
php_fixers:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Add fixer(s). i.e. linefeed,-short_tag,indentation"
|
||||
php_level:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "By default, all PSR-2 fixers and some additional ones are run."
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
# Get Atom defaults
|
||||
tabLength = atom.config.get('editor.tabLength')
|
||||
softTabs = atom.config.get('editor.softTabs')
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: "Python"
|
||||
namespace: "python"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Python"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"py"
|
||||
]
|
||||
|
||||
options:
|
||||
# Python
|
||||
python_autopep8_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `autopep8` CLI executable"
|
||||
python_max_line_length:
|
||||
type: 'integer'
|
||||
default: 79
|
||||
description: "set maximum allowed line length"
|
||||
python_indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
python_ignore:
|
||||
type: 'array'
|
||||
default: ["E24"]
|
||||
items:
|
||||
type: 'string'
|
||||
description: "do not fix these errors/warnings"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Ruby"
|
||||
namespace: "ruby"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Ruby"
|
||||
"Ruby on Rails"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
|
||||
options:
|
||||
# Ruby
|
||||
ruby_rbeautify_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `rbeautify` CLI executable"
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Sass"
|
||||
namespace: "sass"
|
||||
fallback: ['css', 'scss']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Sass"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"sass"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "PrettyDiff"
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
module.exports = {
|
||||
|
||||
name: "SCSS"
|
||||
namespace: "scss"
|
||||
fallback: ['css', 'sass']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"SCSS"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"scss"
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "PrettyDiff"
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
# Get Atom defaults
|
||||
tabLength = atom.config.get('editor.tabLength')
|
||||
softTabs = atom.config.get('editor.softTabs')
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: "SQL"
|
||||
namespace: "sql"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"SQL (Rails)"
|
||||
"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"]
|
||||
sqlformat_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `sqlformat` CLI executable"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
module.exports = {
|
||||
|
||||
name: "TSS"
|
||||
description: "Titanium Style Sheets"
|
||||
namespace: "tss"
|
||||
fallback: ['css', 'sass']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"TSS"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "PrettyDiff"
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
module.exports = {
|
||||
|
||||
name: "TypeScript"
|
||||
namespace: "typescript"
|
||||
fallback: ['js']
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"TypeScript"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
]
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Vala"
|
||||
namespace: "vala"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Vala"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: []
|
||||
|
||||
options:
|
||||
# VALA
|
||||
vala_uncrustifyPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `uncrustify` CLI executable"
|
||||
vala_configPath:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to uncrustify config file. i.e. uncrustify.cfg"
|
||||
|
||||
|
||||
|
||||
###
|
||||
Selected beautifier
|
||||
###
|
||||
beautifier: "JS Beautifier"
|
||||
|
||||
}
|
Loading…
Reference in New Issue