aboutsummaryrefslogtreecommitdiff
path: root/helix-22.03-x86_64-windows/runtime/queries/go
diff options
context:
space:
mode:
Diffstat (limited to 'helix-22.03-x86_64-windows/runtime/queries/go')
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/go/highlights.scm152
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/go/indents.toml30
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/go/injections.scm2
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/go/locals.scm30
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/go/tags.scm30
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/go/textobjects.scm25
6 files changed, 269 insertions, 0 deletions
diff --git a/helix-22.03-x86_64-windows/runtime/queries/go/highlights.scm b/helix-22.03-x86_64-windows/runtime/queries/go/highlights.scm
new file mode 100644
index 0000000..4ff8675
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/go/highlights.scm
@@ -0,0 +1,152 @@
+; Function calls
+
+(call_expression
+ function: (identifier) @function)
+
+(call_expression
+ function: (selector_expression
+ field: (field_identifier) @function.method))
+
+; Function definitions
+
+(function_declaration
+ name: (identifier) @function)
+
+(method_declaration
+ name: (field_identifier) @function.method)
+
+; Identifiers
+
+((identifier) @constant (match? @constant "^[A-Z][A-Z\\d_]+$"))
+(const_spec
+ name: (identifier) @constant)
+
+(parameter_declaration (identifier) @variable.parameter)
+(variadic_parameter_declaration (identifier) @variable.parameter)
+
+(type_identifier) @type
+(field_identifier) @variable.other.member
+(identifier) @variable
+(package_identifier) @variable
+
+
+; Operators
+
+[
+ "--"
+ "-"
+ "-="
+ ":="
+ "!"
+ "!="
+ "..."
+ "*"
+ "*"
+ "*="
+ "/"
+ "/="
+ "&"
+ "&&"
+ "&="
+ "%"
+ "%="
+ "^"
+ "^="
+ "+"
+ "++"
+ "+="
+ "<-"
+ "<"
+ "<<"
+ "<<="
+ "<="
+ "="
+ "=="
+ ">"
+ ">="
+ ">>"
+ ">>="
+ "|"
+ "|="
+ "||"
+ "~"
+] @operator
+
+; Keywords
+
+[
+ "break"
+ "case"
+ "chan"
+ "const"
+ "continue"
+ "default"
+ "defer"
+ "else"
+ "fallthrough"
+ "for"
+ "func"
+ "go"
+ "goto"
+ "if"
+ "interface"
+ "map"
+ "range"
+ "return"
+ "select"
+ "struct"
+ "switch"
+ "type"
+ "var"
+] @keyword
+
+[
+ "import"
+ "package"
+] @keyword.control.import
+
+; Delimiters
+
+[
+ ":"
+ "."
+ ","
+ ";"
+] @punctuation.delimiter
+
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+; Literals
+
+[
+ (interpreted_string_literal)
+ (raw_string_literal)
+ (rune_literal)
+] @string
+
+(escape_sequence) @constant.character.escape
+
+[
+ (int_literal)
+ (float_literal)
+ (imaginary_literal)
+] @constant.numeric.integer
+
+[
+ (true)
+ (false)
+] @constant.builtin.boolean
+
+[
+ (nil)
+ (iota)
+] @constant.builtin
+
+(comment) @comment
diff --git a/helix-22.03-x86_64-windows/runtime/queries/go/indents.toml b/helix-22.03-x86_64-windows/runtime/queries/go/indents.toml
new file mode 100644
index 0000000..7929ff5
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/go/indents.toml
@@ -0,0 +1,30 @@
+indent = [
+ "import_declaration",
+ "const_declaration",
+ #"var_declaration",
+ #"short_var_declaration",
+ "type_declaration",
+ "type_spec",
+ # simply block should be enough
+ # "function_declaration",
+ # "method_declaration",
+ # "composite_literal",
+ "func_literal",
+ "literal_value",
+ "element",
+ "keyed_element",
+ "expression_case",
+ "default_case",
+ "type_case",
+ "communication_case",
+ "argument_list",
+ "field_declaration_list",
+ "block",
+]
+
+outdent = [
+ "case",
+ "}",
+ "]",
+ ")"
+]
diff --git a/helix-22.03-x86_64-windows/runtime/queries/go/injections.scm b/helix-22.03-x86_64-windows/runtime/queries/go/injections.scm
new file mode 100644
index 0000000..321c90a
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/go/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/helix-22.03-x86_64-windows/runtime/queries/go/locals.scm b/helix-22.03-x86_64-windows/runtime/queries/go/locals.scm
new file mode 100644
index 0000000..d240e2b
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/go/locals.scm
@@ -0,0 +1,30 @@
+; Scopes
+
+(block) @local.scope
+
+; Definitions
+
+(parameter_declaration (identifier) @local.definition)
+(variadic_parameter_declaration (identifier) @local.definition)
+
+(short_var_declaration
+ left: (expression_list
+ (identifier) @local.definition))
+
+(var_spec
+ name: (identifier) @local.definition)
+
+(for_statement
+ (range_clause
+ left: (expression_list
+ (identifier) @local.definition)))
+
+(const_declaration
+ (const_spec
+ name: (identifier) @local.definition))
+
+; References
+
+(identifier) @local.reference
+(field_identifier) @local.reference
+
diff --git a/helix-22.03-x86_64-windows/runtime/queries/go/tags.scm b/helix-22.03-x86_64-windows/runtime/queries/go/tags.scm
new file mode 100644
index 0000000..d87008a
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/go/tags.scm
@@ -0,0 +1,30 @@
+(
+ (comment)* @doc
+ .
+ (function_declaration
+ name: (identifier) @name) @definition.function
+ (#strip! @doc "^//\\s*")
+ (#set-adjacent! @doc @definition.function)
+)
+
+(
+ (comment)* @doc
+ .
+ (method_declaration
+ name: (field_identifier) @name) @definition.method
+ (#strip! @doc "^//\\s*")
+ (#set-adjacent! @doc @definition.method)
+)
+
+(call_expression
+ function: [
+ (identifier) @name
+ (parenthesized_expression (identifier) @name)
+ (selector_expression field: (field_identifier) @name)
+ (parenthesized_expression (selector_expression field: (field_identifier) @name))
+ ]) @reference.call
+
+(type_spec
+ name: (type_identifier) @name) @definition.type
+
+(type_identifier) @name @reference.type
diff --git a/helix-22.03-x86_64-windows/runtime/queries/go/textobjects.scm b/helix-22.03-x86_64-windows/runtime/queries/go/textobjects.scm
new file mode 100644
index 0000000..d77e14b
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/go/textobjects.scm
@@ -0,0 +1,25 @@
+(function_declaration
+ body: (block)? @function.inside) @function.around
+
+(func_literal
+ (_)? @function.inside) @function.around
+
+(method_declaration
+ body: (block)? @function.inside) @function.around
+
+;; struct and interface declaration as class textobject?
+(type_declaration
+ (type_spec (type_identifier) (struct_type (field_declaration_list (_)?) @class.inside))) @class.around
+
+(type_declaration
+ (type_spec (type_identifier) (interface_type (method_spec_list (_)?) @class.inside))) @class.around
+
+(parameter_list
+ (_) @parameter.inside)
+
+(argument_list
+ (_) @parameter.inside)
+
+(comment) @comment.inside
+
+(comment)+ @comment.around