aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/go
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/queries/go')
-rw-r--r--runtime/queries/go/highlights.scm117
-rw-r--r--runtime/queries/go/tags.scm30
2 files changed, 147 insertions, 0 deletions
diff --git a/runtime/queries/go/highlights.scm b/runtime/queries/go/highlights.scm
new file mode 100644
index 00000000..224c8b78
--- /dev/null
+++ b/runtime/queries/go/highlights.scm
@@ -0,0 +1,117 @@
+; 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
+
+(type_identifier) @type
+(field_identifier) @property
+(identifier) @variable
+
+; Operators
+
+[
+ "--"
+ "-"
+ "-="
+ ":="
+ "!"
+ "!="
+ "..."
+ "*"
+ "*"
+ "*="
+ "/"
+ "/="
+ "&"
+ "&&"
+ "&="
+ "%"
+ "%="
+ "^"
+ "^="
+ "+"
+ "++"
+ "+="
+ "<-"
+ "<"
+ "<<"
+ "<<="
+ "<="
+ "="
+ "=="
+ ">"
+ ">="
+ ">>"
+ ">>="
+ "|"
+ "|="
+ "||"
+] @operator
+
+; Keywords
+
+[
+ "break"
+ "case"
+ "chan"
+ "const"
+ "continue"
+ "default"
+ "defer"
+ "else"
+ "fallthrough"
+ "for"
+ "func"
+ "go"
+ "goto"
+ "if"
+ "import"
+ "interface"
+ "map"
+ "package"
+ "range"
+ "return"
+ "select"
+ "struct"
+ "switch"
+ "type"
+ "var"
+] @keyword
+
+; Literals
+
+[
+ (interpreted_string_literal)
+ (raw_string_literal)
+ (rune_literal)
+] @string
+
+(escape_sequence) @escape
+
+[
+ (int_literal)
+ (float_literal)
+ (imaginary_literal)
+] @number
+
+[
+ (true)
+ (false)
+ (nil)
+] @constant.builtin
+
+(comment) @comment
diff --git a/runtime/queries/go/tags.scm b/runtime/queries/go/tags.scm
new file mode 100644
index 00000000..d87008ab
--- /dev/null
+++ b/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