Skip to content

Commit

Permalink
Merge pull request #341 from akalongman/dev
Browse files Browse the repository at this point in the history
Drop ST2 support and update dependencies
  • Loading branch information
akalongman authored Nov 12, 2017
2 parents b650f9d + c2961a1 commit a08d8a9
Show file tree
Hide file tree
Showing 36 changed files with 3,528 additions and 2,775 deletions.
21 changes: 13 additions & 8 deletions CodeFormatter.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@
"space_in_empty_paren": false, // Add padding spaces within paren if parent empty, ie. f( )
"e4x": false, // Pass E4X xml literals through untouched
"jslint_happy": false, // if true, then jslint-stricter mode is enforced. Example function () vs function()
"space_after_anon_function": false, // Space after anonimouse functions
"brace_style": "collapse", // "collapse" | "expand" | "end-expand". put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.
"keep_array_indentation": false, // keep array indentation.
"keep_function_indentation": false, // keep function indentation.
"eval_code": false, // eval code
"unescape_strings": false, // Decode printable characters encoded in xNN notation
"wrap_line_length": 0, // Wrap lines at next opportunity after N characters
"unindent_chained_methods": false, // Unindent chained method calls
"break_chained_methods": false, // Break chained method calls across subsequent lines
"end_with_newline": false, // Add new line at end of file
"comma_first": false // Add comma first
"comma_first": false, // Add comma first
"operator_position": "before-newline" // Operator position: before-newline, after-newline, preserve-newline
},


"codeformatter_css_options":
{
"syntaxes": "css,less", // Syntax names which must process CSS formatter
Expand All @@ -59,19 +61,23 @@
"selector_separator_newline": false, // Add new lines after selector separators
"end_with_newline": false, // Add new line of end in file
"newline_between_rules": false, // Add new line between rules
"space_around_combinator": false, // Space around combinator
"eol": "\n" // EOL symbol
},

"codeformatter_scss_options":
{
"syntaxes": "scss", // Indentation size
"syntaxes": "scss,sass", // Indentation size
"format_on_save": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : "^((?!.min.|vendor).)*$"
"format_on_save": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : "^((?!.min.|vendor).)*$"
"indent_size": 2, // Indentation size
"indent_size": 4, // Indentation size
"indent_char": " ", // Indentation character
"indent_with_tabs": false, // Indent with one tab (overrides indent_size and indent_char options)
"selector_separator_newline": true, // Add new lines after selector separators
"newline_between_rules": true, // Add new line between rules
"end_with_newline": true // Add new line of end in file
"selector_separator_newline": false, // Add new lines after selector separators
"end_with_newline": false, // Add new line of end in file
"newline_between_rules": false, // Add new line between rules
"space_around_combinator": false, // Space around combinator
"eol": "\n" // EOL symbol
},

"codeformatter_html_options":
Expand All @@ -92,7 +98,6 @@
"custom_singletons": "" // Custom singleton tags for various template languages outside of the HTML5 spec
},


"codeformatter_python_options":
{
"syntaxes": "python", // Syntax names which must process Python formatter
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ CodeFormatter has support for the following languages:
* PHP - By [phpF](https://github.com/subins2000/phpF)
* JavaScript/JSON - By JSBeautifier
* HTML - By [Custom fork of BeautifulSoup](https://github.com/akalongman/python-beautifulsoup)
* CSS - By JSBeautifier
* SCSS - By Nishutosh Sharma
* CSS,LESS,SASS - By JSBeautifier
* Python - By PythonTidy (only ST2)
* Visual Basic/VBScript
* Coldfusion/Railo/Lucee
Expand Down
10 changes: 10 additions & 0 deletions codeformatter/cssformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ def format(self, text):
else:
options.eol = '\n'

if ('space_around_combinator' in self.opts and self.opts['space_around_combinator']):
options.space_around_combinator = True
else:
options.space_around_combinator = False

if ('newline_between_rules' in self.opts and self.opts['newline_between_rules']):
options.newline_between_rules = True
else:
options.newline_between_rules = False

try:
stdout = cssbeautifier.beautify(text, options)
except Exception as e:
Expand Down
13 changes: 13 additions & 0 deletions codeformatter/jsformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ def format(self, text):
else:
options.space_after_anon_function = False

if (
'unindent_chained_methods' in self.opts and
self.opts['unindent_chained_methods']
):
options.unindent_chained_methods = True
else:
options.unindent_chained_methods = False

if ('operator_position' in self.opts and self.opts['operator_position']):
options.operator_position = self.opts['operator_position']
else:
options.operator_position = 'before-newline'

try:
stdout = jsbeautifier.beautify(text, options)
except Exception as e:
Expand Down
Loading

0 comments on commit a08d8a9

Please sign in to comment.