See Atom Settings-View bug: https://github.com/atom/settings-view/issues/386#issuecomment-98379708
This commit is contained in:
parent
a2262619ad
commit
48af4a3ff6
|
@ -185,32 +185,27 @@ module.exports = class Beautifiers
|
||||||
), {})
|
), {})
|
||||||
|
|
||||||
# Generate Language configurations
|
# Generate Language configurations
|
||||||
langConfigs = {}
|
# console.log('languages', languages)
|
||||||
# Process all languages
|
|
||||||
for langName, lang of languages
|
for langName, lang of languages
|
||||||
|
# console.log(langName, lang)
|
||||||
name = lang.name
|
name = lang.name
|
||||||
beautifiers = lang.beautifiers
|
beautifiers = lang.beautifiers
|
||||||
langConfigs[name] = {
|
optionName = "language_#{lang.namespace}"
|
||||||
type: 'object'
|
# Add Language configurations
|
||||||
properties:
|
flatOptions["#{optionName}_disabled"] = {
|
||||||
disabled:
|
|
||||||
title: "Language Config - #{name} - Disable Beautifying Language"
|
title: "Language Config - #{name} - Disable Beautifying Language"
|
||||||
type: 'boolean'
|
type: 'boolean'
|
||||||
default: false
|
default: false
|
||||||
description: "Disable #{name} Beautification"
|
description: "Disable #{name} Beautification"
|
||||||
default_beautifier:
|
}
|
||||||
|
flatOptions["#{optionName}_default_beautifier"] = {
|
||||||
title: "Language Config - #{name} - Default Beautifier"
|
title: "Language Config - #{name} - Default Beautifier"
|
||||||
type: 'string'
|
type: 'string'
|
||||||
default: beautifiers[0]
|
default: beautifiers[0]
|
||||||
description: "Default Beautifier to be used for #{name}"
|
description: "Default Beautifier to be used for #{name}"
|
||||||
enum: _.uniq(beautifiers)
|
enum: _.uniq(beautifiers)
|
||||||
}
|
}
|
||||||
# Add Language configurations
|
# console.log('flatOptions', flatOptions)
|
||||||
flatOptions.languages = {
|
|
||||||
type: 'object'
|
|
||||||
properties: langConfigs
|
|
||||||
}
|
|
||||||
|
|
||||||
return flatOptions
|
return flatOptions
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -238,12 +233,13 @@ module.exports = class Beautifiers
|
||||||
language = languages[0]
|
language = languages[0]
|
||||||
|
|
||||||
# Get language config
|
# Get language config
|
||||||
langConfig = atom.config.get("atom-beautify.languages")?[language.name]
|
langDisabled = atom.config.get("atom-beautify.language_#{language.namespace}_disabled")
|
||||||
|
preferredBeautifierName = atom.config.get("atom-beautify.language_#{language.namespace}_default_beautifier")
|
||||||
|
|
||||||
# Beautify!
|
# Beautify!
|
||||||
unsupportedGrammar = false
|
unsupportedGrammar = false
|
||||||
# Check if Language is disabled
|
# Check if Language is disabled
|
||||||
if langConfig?.disabled
|
if langDisabled
|
||||||
return resolve(null)
|
return resolve(null)
|
||||||
|
|
||||||
# Options for Language
|
# Options for Language
|
||||||
|
@ -264,7 +260,6 @@ module.exports = class Beautifiers
|
||||||
unsupportedGrammar = true
|
unsupportedGrammar = true
|
||||||
else
|
else
|
||||||
# Select beautifier from language config preferences
|
# Select beautifier from language config preferences
|
||||||
preferredBeautifierName = langConfig.default_beautifier
|
|
||||||
beautifier = _.find(beautifiers, (beautifier) ->
|
beautifier = _.find(beautifiers, (beautifier) ->
|
||||||
beautifier.name is preferredBeautifierName
|
beautifier.name is preferredBeautifierName
|
||||||
) or beautifiers[0]
|
) or beautifiers[0]
|
||||||
|
|
Loading…
Reference in New Issue