What's new: - Add settings descriptions - Update options for js-beautify (JS, CSS, HTML) - Update Spec to support new changes
This commit is contained in:
parent
a2292201a3
commit
eb1471d23b
|
@ -3,8 +3,7 @@ class Example
|
|||
|
||||
Example()
|
||||
: member(0)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
int member;
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
{{#items}}
|
||||
{{#first}}
|
||||
<li><strong>{{name}}</strong>
|
||||
<li>
|
||||
<strong>{{name}}</strong>
|
||||
</li>
|
||||
{{/first}}
|
||||
{{#link}}
|
|
@ -5,3 +5,4 @@ title: "This is a title!"
|
|||
stuff
|
||||
|
||||
more stuff
|
||||
|
||||
|
|
|
@ -222,13 +222,37 @@ handleSaveEvent = =>
|
|||
|
||||
{Subscriber} = require path.join(atom.packages.resourcePath, 'node_modules', 'emissary')
|
||||
Subscriber.extend plugin
|
||||
plugin.configDefaults = _.merge(
|
||||
analytics: true
|
||||
beautifyOnSave: false
|
||||
beautifyEntireFileOnSave: true
|
||||
muteUnsupportedLanguageErrors: false
|
||||
muteAllErrors: false
|
||||
disabledLanguages: []
|
||||
plugin.config = _.merge(
|
||||
analytics:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: "Automatically send usage information (NEVER CODE) to Google Analytics"
|
||||
_analyticsUserId:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Unique identifier for this user for tracking usage analytics"
|
||||
beautifyOnSave:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Beautify active editor on save"
|
||||
beautifyEntireFileOnSave:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: "When beautifying on save, use the entire file, even if there is selected text in the editor"
|
||||
muteUnsupportedLanguageErrors:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Do not show \"Unsupported Language\" errors when they occur"
|
||||
muteAllErrors:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Do not show any/all errors when they occur"
|
||||
disabledLanguages:
|
||||
type: 'array'
|
||||
default: []
|
||||
items:
|
||||
type: 'string'
|
||||
description: "An array of languages/grammars to disable Beautification for"
|
||||
, defaultLanguageOptions)
|
||||
plugin.activate = ->
|
||||
handleSaveEvent()
|
||||
|
|
|
@ -30,9 +30,12 @@ getCmd = (inputPath, outputPath, options, cb) ->
|
|||
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)
|
||||
|
|
|
@ -30,6 +30,15 @@ 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
|
||||
|
@ -62,93 +71,317 @@ module.exports =
|
|||
# jshint ignore: start
|
||||
|
||||
# JavaScript
|
||||
js_indent_size: 2
|
||||
js_indent_char: " "
|
||||
js_indent_level: 0
|
||||
js_indent_with_tabs: false
|
||||
js_preserve_newlines: true
|
||||
js_max_preserve_newlines: 10
|
||||
js_jslint_happy: false
|
||||
js_brace_style: "collapse"
|
||||
js_keep_array_indentation: false
|
||||
js_keep_function_indentation: false
|
||||
js_space_before_conditional: true
|
||||
js_break_chained_methods: false
|
||||
js_eval_code: false
|
||||
js_unescape_strings: false
|
||||
js_wrap_line_length: 0
|
||||
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: 2
|
||||
css_indent_char: " "
|
||||
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"
|
||||
|
||||
# HTML
|
||||
html_indent_inner_html: false
|
||||
html_indent_size: 2
|
||||
html_indent_char: " "
|
||||
html_brace_style: "collapse"
|
||||
html_indent_scripts: "normal"
|
||||
html_wrap_line_length: 250
|
||||
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_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: 2
|
||||
sql_keywords: "upper"
|
||||
sql_identifiers: "lower"
|
||||
sql_sqlformat_path: ""
|
||||
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: ""
|
||||
markdown_yaml_front_matter: true
|
||||
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: "perltidy"
|
||||
perl_perltidy_profile: ""
|
||||
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_beautifier_path: ""
|
||||
php_filters: ""
|
||||
php_directory_filters: ""
|
||||
php_beautifier_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `PHP_Beautifier` CLI executable"
|
||||
php_filters:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Add filter(s). i.e. \"Filter1(setting1=value1,setting2=value2) Filter2()\""
|
||||
php_directory_filters:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Include dirs for filters"
|
||||
|
||||
# Python
|
||||
python_autopep8_path: ""
|
||||
python_max_line_length: 79
|
||||
python_indent_size: 4
|
||||
python_ignore: ["E24"]
|
||||
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: ""
|
||||
ruby_rbeautify_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `rbeautify` CLI executable"
|
||||
|
||||
# C
|
||||
c_uncrustifyPath: ""
|
||||
c_configPath: ""
|
||||
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: ""
|
||||
cpp_configPath: ""
|
||||
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: ""
|
||||
objectivec_configPath: ""
|
||||
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: ""
|
||||
cs_configPath: ""
|
||||
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: ""
|
||||
d_configPath: ""
|
||||
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: ""
|
||||
java_configPath: ""
|
||||
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: ""
|
||||
pawn_configPath: ""
|
||||
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: ""
|
||||
vala_configPath: ""
|
||||
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
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ yaml = null
|
|||
editorconfig = null
|
||||
beautifier = require("./language-options")
|
||||
languages = beautifier.languages
|
||||
defaultLanguageOptions = beautifier.defaultLanguageOptions
|
||||
|
||||
module.exports =
|
||||
findFileResults: {}
|
||||
|
@ -73,8 +72,8 @@ module.exports =
|
|||
return proj if proj
|
||||
return home if @verifyExists(home)
|
||||
null
|
||||
getConfigOptionsFromSettings: (langs, config) ->
|
||||
config ?= atom.config.get('atom-beautify')
|
||||
getConfigOptionsFromSettings: (langs) ->
|
||||
config = atom.config.get('atom-beautify')
|
||||
options = {}
|
||||
# console.log(langs, config);
|
||||
# Iterate over keys of the settings
|
||||
|
@ -140,12 +139,9 @@ module.exports =
|
|||
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)
|
||||
else
|
||||
# Without editor
|
||||
# Use default options for Atom editor
|
||||
configOptions = @getConfigOptionsFromSettings(languages, defaultLanguageOptions)
|
||||
|
||||
# Get configuration in User's Home directory
|
||||
userHome = @getUserHome()
|
||||
|
@ -195,3 +191,5 @@ module.exports =
|
|||
editorConfigOptions
|
||||
]
|
||||
allOptions = allOptions.concat(projectOptions)
|
||||
# console.log(allOptions)
|
||||
return allOptions
|
||||
|
|
13
package.json
13
package.json
|
@ -63,14 +63,19 @@
|
|||
"typescript-formatter": "~0.1.4",
|
||||
"yaml-front-matter": "^3.2.3"
|
||||
},
|
||||
"activationEvents": [
|
||||
"beautify",
|
||||
"activationCommands": {
|
||||
"atom-workspace": [
|
||||
"beautify:beautify-editor",
|
||||
"beautify:beautify-file",
|
||||
"beautify:beautify-directory",
|
||||
"core:save",
|
||||
"core:save-as"
|
||||
],
|
||||
".tree-view .file .name": [
|
||||
"beautify:beautify-file"
|
||||
],
|
||||
".tree-view .directory .name": [
|
||||
"beautify:beautify-directory"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"atom",
|
||||
"beautify",
|
||||
|
|
|
@ -25,11 +25,29 @@ describe "BeautifyLanguages", ->
|
|||
]
|
||||
|
||||
beforeEach ->
|
||||
# Install all of the languages
|
||||
for lang in allLanguages
|
||||
do (lang) ->
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage("language-#{lang}")
|
||||
|
||||
# Activate package
|
||||
waitsForPromise ->
|
||||
activationPromise = atom.packages.activatePackage('atom-beautify')
|
||||
# Force activate package
|
||||
pack = atom.packages.getLoadedPackage("atom-beautify")
|
||||
pack.activateNow()
|
||||
# Return promise
|
||||
return activationPromise
|
||||
|
||||
# Set Uncrustify config path
|
||||
# uncrustifyConfigPath = path.resolve(__dirname, "../examples/nested-jsbeautifyrc/uncrustify.cfg")
|
||||
# uncrustifyLangs = ["c", "cpp", "objectivec", "cs", "d", "java", "pawn", "vala"]
|
||||
# for lang in uncrustifyLangs
|
||||
# do (lang) ->
|
||||
# atom.config.set("atom-beautify.#{lang}_configPath", uncrustifyConfigPath)
|
||||
# expect(atom.config.get("atom-beautify.#{lang}_configPath")).toEqual("TEST")
|
||||
|
||||
###
|
||||
Directory structure:
|
||||
- examples
|
||||
|
|
Loading…
Reference in New Issue