Closes #35. Add more options for Python PEP8 beautifying.
Options: - max line length - indent size - ignore (errors) Also fixed typo causing very important bug, such that languages were not loaded correctly and options were missing.
This commit is contained in:
parent
f7c7fc7614
commit
65ff7f9f7a
|
@ -30,3 +30,8 @@
|
|||
indent_char: " "
|
||||
indent_level: 0
|
||||
indent_with_tabs: false
|
||||
python:
|
||||
indent_size: 4
|
||||
#max_line_length: 79
|
||||
#ignore:
|
||||
# - "E24"
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue