mirror of
https://github.com/helix-editor/helix
synced 2026-05-05 05:42:27 +02:00
a1cb573f1d
When auto-pairs is disabled, typing an opening delimiter without a
matching closing one causes tree-sitter to produce an ERROR node.
Add patterns to match ERROR nodes containing '{', '(', and '[' so
that indentation works correctly in these cases.
Fixes #7910
Signed-off-by: majiayu000 <1835304752@qq.com>
47 lines
1002 B
Scheme
47 lines
1002 B
Scheme
[
|
|
(import_declaration)
|
|
(const_declaration)
|
|
(type_declaration)
|
|
(type_spec)
|
|
(func_literal)
|
|
(literal_value)
|
|
(literal_element)
|
|
(keyed_element)
|
|
(expression_case)
|
|
(default_case)
|
|
(type_case)
|
|
(communication_case)
|
|
(argument_list)
|
|
(field_declaration_list)
|
|
(block)
|
|
(var_declaration)
|
|
] @indent
|
|
|
|
[
|
|
"]"
|
|
")"
|
|
] @outdent
|
|
|
|
; Switches and selects aren't indented, only their case bodies are.
|
|
; Outdent all closing braces except those closing switches or selects.
|
|
(
|
|
(_ "}" @outdent) @outer
|
|
(#not-kind-eq? @outer "select_statement")
|
|
(#not-kind-eq? @outer "type_switch_statement")
|
|
(#not-kind-eq? @outer "expression_switch_statement")
|
|
)
|
|
|
|
; Starting a line after a new case should indent.
|
|
[
|
|
(communication_case)
|
|
(expression_case)
|
|
(default_case)
|
|
(type_case)
|
|
] @extend
|
|
|
|
; Handle ERROR nodes for when auto-pairs is disabled.
|
|
; Typing an opening delimiter without a closing one produces an ERROR node.
|
|
(ERROR "{") @indent @extend
|
|
(ERROR "(") @indent
|
|
(ERROR "[") @indent
|