Fixes #894. Default options are extracted from Atom Editor options

This is for indent_size, indent_char, indent_with_tabs, and wrap_attributes_indent_size.
This commit is contained in:
Glavin Wiechert 2017-04-15 19:09:27 -03:00
parent 7990806008
commit 147f97d4c7
18 changed files with 351 additions and 365 deletions

View File

@ -82,12 +82,6 @@ Handlebars.registerHelper('example-config', (key, option, options) ->
Handlebars.registerHelper('language-beautifiers-support', (languageOptions, options) ->
###
| Language | Supported Beautifiers |
| --- | ---- |
| JavaScript | Js-Beautify, Pretty Diff |
###
rows = _.map(languageOptions, (val, k) ->
name = val.title
defaultBeautifier = _.get(val, "properties.default_beautifier.default")

File diff suppressed because it is too large Load Diff

View File

@ -185,6 +185,7 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) {
type: 'object',
description: "Options for language " + lang.name,
collapsed: true,
scope: lang.scope,
beautifiers: [],
grammars: lang.grammars,
extensions: lang.extensions,

View File

@ -110,11 +110,32 @@ module.exports = class Beautifiers extends EventEmitter
new Beautifier()
)
@options = @loadOptions()
loadOptions : ->
try
@options = require('../options.json')
catch
console.warn('Beautifier options not found.')
@options = {}
options = require('../options.json')
options = _.mapValues(options, (lang) ->
scope = lang.scope
tabLength = atom?.config.get('editor.tabLength', scope: scope)
softTabs = atom?.config.get('editor.softTabs', scope: scope)
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
if _.has(lang, "properties.indent_size")
_.set(lang, "properties.indent_size.default", defaultIndentSize)
if _.has(lang, "properties.indent_char")
_.set(lang, "properties.indent_char.default", defaultIndentChar)
if _.has(lang, "properties.indent_with_tabs")
_.set(lang, "properties.indent_with_tabs.default", defaultIndentWithTabs)
if _.has(lang, "properties.wrap_attributes_indent_size")
_.set(lang, "properties.wrap_attributes_indent_size.default", defaultIndentSize)
return lang
)
catch error
console.error("Error loading options", error)
options = {}
return options
###
From https://github.com/atom/notifications/blob/01779ade79e7196f1603b8c1fa31716aa4a33911/lib/notification-issue.coffee#L130

View File

@ -1,12 +1,8 @@
scope = ['source.sh', 'source.bash']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 2
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
module.exports = {
name: "Bash"
namespace: "bash"
scope: ['source.sh', 'source.bash']
###
Supported Grammars
@ -28,7 +24,7 @@ module.exports = {
options:
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"

View File

@ -1,15 +1,9 @@
scope = ['text.html']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "Coldfusion"
description: "Coldfusion Markup; cfscript is also handled via the prettydiff javascript parser"
namespace: "cfml"
scope: ['text.html']
###
Supported Grammars
@ -30,12 +24,12 @@ module.exports = {
options:
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: defaultIndentChar
default: null
minimum: 0
description: "Indentation character"
wrap_line_length:

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['source.css']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "CSS"
namespace: "css"
scope: ['source.css']
###
Supported Grammars
@ -31,12 +24,12 @@ module.exports = {
# CSS
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: defaultIndentChar
default: null
minimum: 0
description: "Indentation character"
selector_separator_newline:

View File

@ -1,14 +1,8 @@
# Get Atom defaults
tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "gherkin"
namespace: "gherkin"
scope: []
grammars: [
"Gherkin"
@ -21,12 +15,12 @@ module.exports = {
options:
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: defaultIndentChar
default: null
minimum: 0
description: "Indentation character"
}

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['text.html']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "HTML"
namespace: "html"
scope: ['text.html']
###
Supported Grammars
@ -32,12 +25,12 @@ module.exports = {
description: "Indent <head> and <body> sections."
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: defaultIndentChar
default: null
description: "Indentation character"
brace_style:
type: 'string'
@ -60,7 +53,7 @@ module.exports = {
description: "Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline]"
wrap_attributes_indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indent wrapped attributes to after N characters"
preserve_newlines:

View File

@ -1,16 +1,9 @@
# Get Atom defaults
scope = ['text.jade']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "Jade"
namespace: "jade"
fallback: ['html']
scope: ['text.jade']
###
Supported Grammars
@ -29,12 +22,12 @@ module.exports = {
options: [
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: defaultIndentChar
default: null
description: "Indentation character"
omit_div:
type: 'boolean'

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['source.js']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "JavaScript"
namespace: "js"
scope: ['source.js']
###
Supported Grammars
@ -46,7 +39,7 @@ module.exports = {
description: "Initial indentation level"
indent_with_tabs:
type: 'boolean'
default: defaultIndentWithTabs
default: null
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
preserve_newlines:
type: 'boolean'

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['source.js']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "LaTeX"
namespace: "latex"
scope: ['source.tex']
###
Supported Grammars
@ -33,11 +26,11 @@ module.exports = {
options:
indent_char:
type: 'string'
default: defaultIndentChar
default: null
description: "Indentation character"
indent_with_tabs:
type: 'boolean'
default: true
default: null
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
indent_preamble:
type: 'boolean'

View File

@ -1,16 +1,9 @@
# Get Atom defaults
scope = ['text.marko']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 4)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "Marko"
namespace: "marko"
fallback: ['html']
scope: ['text.marko']
###
Supported Grammars
@ -29,12 +22,12 @@ module.exports = {
options:
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: defaultIndentChar
default: null
description: "Indentation character"
syntax:
type: 'string'

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['source.conf']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "Nginx"
namespace: "nginx"
scope: ['source.conf']
###
Supported Grammars
@ -30,16 +23,16 @@ module.exports = {
options:
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: defaultIndentChar
default: null
description: "Indentation character"
indent_with_tabs:
type: 'boolean'
default: defaultIndentWithTabs
default: null
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
dontJoinCurlyBracet:
title: "Don't join curly brackets"

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['source.python']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "Python"
namespace: "python"
scope: ['source.python']
###
Supported Grammars
@ -32,7 +25,7 @@ module.exports = {
description: "set maximum allowed line length"
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
ignore:

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['text.html']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "R"
namespace: "r"
scope: ['text.r']
###
Supported Grammars
@ -29,7 +22,7 @@ module.exports = {
options:
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
description: "Indentation size/length"
}

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['source.ruby']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "Ruby"
namespace: "ruby"
scope: ['source.ruby']
###
Supported Grammars
@ -29,19 +22,18 @@ module.exports = {
options:
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: null
description: "Indentation character"
enum: [" ", "\t"]
rubocop_path:
title: "Rubocop Path"
type: 'string'
default: ""
description: "Path to the `rubocop` CLI executable"
indent_char:
type: 'string'
default: defaultIndentChar
description: "Indentation character"
enum: [" ", "\t"]
}

View File

@ -1,15 +1,8 @@
# Get Atom defaults
scope = ['source.sql']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "SQL"
namespace: "sql"
scope: ['source.sql']
###
Supported Grammars
@ -30,7 +23,7 @@ module.exports = {
# SQL
indent_size:
type: 'integer'
default: defaultIndentSize
default: null
minimum: 0
description: "Indentation size/length"
keywords: