summaryrefslogtreecommitdiff
path: root/vendor/queries/go/indents.scm
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/queries/go/indents.scm')
-rw-r--r--vendor/queries/go/indents.scm55
1 files changed, 55 insertions, 0 deletions
diff --git a/vendor/queries/go/indents.scm b/vendor/queries/go/indents.scm
new file mode 100644
index 00000000..3734f458
--- /dev/null
+++ b/vendor/queries/go/indents.scm
@@ -0,0 +1,55 @@
+; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389:
+; runtime/queries/go/indents.scm.
+; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE,
+; https://mozilla.org/MPL/2.0/).
+
+[
+ (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)
+ (parameter_list)
+ (field_declaration_list)
+ (block)
+ (var_declaration)
+ (selector_expression)
+ (binary_expression)
+] @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")
+)
+
+; 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
+
+; Labels (`Loop:`, `done:`) are de-indented one level by gofmt.
+; Capturing the label_name (a child, not an ancestor of the labeled body)
+; outdents only the label line.
+(labeled_statement
+ (label_name) @outdent)
+
+; Raw string literals (backticks) span lines and are literal content.
+(raw_string_literal) @opaque