mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-23 01:46:18 +04:00
e7f25d88ca
Unlike other languages, in Go, switches themselves are not indented; it's just each case body which is indented by one level: switch foo { case "bar": baz() } As such, we shouldn't `@indent` for type_switch_statement nor expression_switch_statement, as otherwise inserted lines show up as: switch foo { // inserted with "o" case "bar": // inserted with "o" baz() } With the fix, the inserted lines are indented properly: switch foo { // inserted with "o" case "bar": // inserted with "o" baz() } I also verified that indentation on selects similarly works well. Thanks to Triton171 for helping with this fix.
41 lines
803 B
Scheme
41 lines
803 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
|