diff --git a/examples/nested-jsbeautifyrc/.jsbeautifyrc b/examples/nested-jsbeautifyrc/.jsbeautifyrc index 6d223e7..c9999ee 100644 --- a/examples/nested-jsbeautifyrc/.jsbeautifyrc +++ b/examples/nested-jsbeautifyrc/.jsbeautifyrc @@ -30,3 +30,8 @@ indent_char: " " indent_level: 0 indent_with_tabs: false + python: + indent_size: 4 + #max_line_length: 79 + #ignore: + # - "E24" diff --git a/examples/simple-jsbeautifyrc/test.py b/examples/nested-jsbeautifyrc/test.py similarity index 100% rename from examples/simple-jsbeautifyrc/test.py rename to examples/nested-jsbeautifyrc/test.py diff --git a/lib/atom-beautify.js b/lib/atom-beautify.js index 222fdf4..404b34b 100644 --- a/lib/atom-beautify.js +++ b/lib/atom-beautify.js @@ -12,7 +12,7 @@ var strip = require('strip-json-comments'); var yaml = require('js-yaml'); // Language options var beautifier = require('./language-options'); -var languages = beautifier.langauges; +var languages = beautifier.languages; var defaultLanguageOptions = beautifier.defaultLanguageOptions; // TODO: Copied from jsbeautify, please update it from time to time @@ -156,21 +156,21 @@ function findConfig(config, file) { function getConfigOptionsFromSettings(langs) { var config = atom.config.getSettings()['atom-beautify']; var options = {}; - // console.log(langs, config); + console.log(langs, config); // Iterate over keys of the settings _.every(_.keys(config), function (k) { // Check if keys start with a language var p = k.split('_')[0]; var idx = _.indexOf(langs, p); - // console.log(k, p, idx); + console.log(k, p, idx); if (idx >= 0) { // Remove the language prefix and nest in options var lang = langs[idx]; var opt = k.replace(new RegExp('^' + lang + '_'), ''); options[lang] = options[lang] || {}; options[lang][opt] = config[k]; - // console.log(lang, opt); + console.log(lang, opt); } return true; }); diff --git a/lib/langs/python-beautify.js b/lib/langs/python-beautify.js index 3ad57f9..56500bb 100644 --- a/lib/langs/python-beautify.js +++ b/lib/langs/python-beautify.js @@ -8,12 +8,15 @@ var cliBeautify = require('./cli-beautify'); function getCmd(inputPath, outputPath, options) { var path = options.autopep8_path; // jshint ignore: line + var optionsStr = '--max-line-length ' + options.max_line_length + // jshint ignore: line + ' --indent-size ' + options.indent_size // jshint ignore: line + + ' --ignore ' + options.ignore.join(','); // jshint ignore: line if (path) { // Use absolute path - return 'python "' + path + '" "' + inputPath + '"'; + return 'python "' + path + '" "' + inputPath + '" ' + optionsStr; } else { // Use command available in $PATH - return 'autopep8 "' + inputPath + '"'; + return 'autopep8 "' + inputPath + '" ' + optionsStr; } } var isStdout = true; diff --git a/lib/language-options.js b/lib/language-options.js index 4641f7d..7532622 100644 --- a/lib/language-options.js +++ b/lib/language-options.js @@ -57,6 +57,9 @@ module.exports = { php_beautifier_path: '', // Python python_autopep8_path: '', + python_max_line_length: 79, + python_indent_size: 4, + python_ignore: ['E24'], // Ruby ruby_rbeautify_path: '' /* jshint ignore: end */ @@ -156,4 +159,4 @@ module.exports = { return options; } -} +};