diff --git a/lib/main.js b/lib/main.js index da1e9faf..1e72bc7a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -61,6 +61,22 @@ exports.activate = function () { } }) } + + // This feels hacky. Better suggestions welcome. + const grammar = atom.grammars.grammarForId('source.js') + grammar.precedingRowConditions = (node) => ( + (node.parent.type == 'while_statement' && node.type != 'statement_block') + || (node.parent.type == 'jsx_self_closing_element' && node.type != '/') + || (node.parent.type == 'if_statement' + && (!(node.type == 'if_statement' + && node.previousSibling.type == 'else' + && node.previousSibling.startPosition.row == node.startPosition.row) + /* not an else-if */ + ) + && node.type != 'statement_block' + && node.type != 'else') + ) + } const STYLED_REGEX = /\bstyled\b/i diff --git a/settings/language-javascript.cson b/settings/language-javascript.cson index f7bc48f6..8f9de981 100644 --- a/settings/language-javascript.cson +++ b/settings/language-javascript.cson @@ -11,3 +11,27 @@ 'decreaseIndentPattern': '(?x) ^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])] ' + scopes: + indent: + array: true + object: true + arguments: true + statement_block: true + class_body: true + parenthesized_expression: true + jsx_element: true + jsx_opening_element: true + jsx_expression: true + switch_body: true + comment: true + indentExceptFirst: + member_expression: true + assignment_expression: true + expression_statement: true + variable_declarator: true + lexical_declaration: true + binary_expression: true + types: + indent: {} + outdent: + access_specifier: true