Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 955bc72

Browse files
committed
Adding configuration for new, tree-sitter based indentation logic in core
See this PR in atom/atom: FILL-ME-IN. Once the other PR is merged, this one then fixes #594.
1 parent 25863da commit 955bc72

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

lib/main.js

+16
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ exports.activate = function () {
6161
}
6262
})
6363
}
64+
65+
// This feels hacky. Better suggestions welcome.
66+
const grammar = atom.grammars.grammarForId('source.js')
67+
grammar.precedingRowConditions = (node) => (
68+
(node.parent.type == 'while_statement' && node.type != 'statement_block')
69+
|| (node.parent.type == 'jsx_self_closing_element' && node.type != '/')
70+
|| (node.parent.type == 'if_statement'
71+
&& (!(node.type == 'if_statement'
72+
&& node.previousSibling.type == 'else'
73+
&& node.previousSibling.startPosition.row == node.startPosition.row)
74+
/* not an else-if */
75+
)
76+
&& node.type != 'statement_block'
77+
&& node.type != 'else')
78+
)
79+
6480
}
6581

6682
const STYLED_REGEX = /\bstyled\b/i

settings/language-javascript.cson

+24
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,27 @@
1111
'decreaseIndentPattern': '(?x)
1212
^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])]
1313
'
14+
scopes:
15+
indent:
16+
array: true
17+
object: true
18+
arguments: true
19+
statement_block: true
20+
class_body: true
21+
parenthesized_expression: true
22+
jsx_element: true
23+
jsx_opening_element: true
24+
jsx_expression: true
25+
switch_body: true
26+
comment: true
27+
indentExceptFirst:
28+
member_expression: true
29+
assignment_expression: true
30+
expression_statement: true
31+
variable_declarator: true
32+
lexical_declaration: true
33+
binary_expression: true
34+
types:
35+
indent: {}
36+
outdent:
37+
access_specifier: true

0 commit comments

Comments
 (0)