1; Function calls
2
3(call_expression
4 function: (identifier) @function)
5
6(call_expression
7 function: (identifier) @function.builtin
8 (#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$"))
9
10(call_expression
11 function: (selector_expression
12 field: (field_identifier) @function.method))
13
14; Function definitions
15
16(function_declaration
17 name: (identifier) @function)
18
19(method_declaration
20 name: (field_identifier) @function.method)
21
22; Identifiers
23
24(type_identifier) @type
25(field_identifier) @property
26(identifier) @variable
27
28; Operators
29
30[
31 "--"
32 "-"
33 "-="
34 ":="
35 "!"
36 "!="
37 "..."
38 "*"
39 "*"
40 "*="
41 "/"
42 "/="
43 "&"
44 "&&"
45 "&="
46 "%"
47 "%="
48 "^"
49 "^="
50 "+"
51 "++"
52 "+="
53 "<-"
54 "<"
55 "<<"
56 "<<="
57 "<="
58 "="
59 "=="
60 ">"
61 ">="
62 ">>"
63 ">>="
64 "|"
65 "|="
66 "||"
67 "~"
68] @operator
69
70; Keywords
71
72[
73 "break"
74 "case"
75 "chan"
76 "const"
77 "continue"
78 "default"
79 "defer"
80 "else"
81 "fallthrough"
82 "for"
83 "func"
84 "go"
85 "goto"
86 "if"
87 "import"
88 "interface"
89 "map"
90 "package"
91 "range"
92 "return"
93 "select"
94 "struct"
95 "switch"
96 "type"
97 "var"
98] @keyword
99
100; Literals
101
102[
103 (interpreted_string_literal)
104 (raw_string_literal)
105 (rune_literal)
106] @string
107
108(escape_sequence) @escape
109
110[
111 (int_literal)
112 (float_literal)
113 (imaginary_literal)
114] @number
115
116[
117 (true)
118 (false)
119 (nil)
120 (iota)
121] @constant.builtin
122
123(comment) @comment
124
125(call_expression
126 function: [
127 (identifier) @name
128 (parenthesized_expression (identifier) @name)
129 (selector_expression field: (field_identifier) @name)
130 (parenthesized_expression (selector_expression field: (field_identifier) @name))
131 ]) @reference.call
132
133(type_spec
134 name: (type_identifier) @name) @definition.type
135
136(type_identifier) @name @reference.type
137
138(package_clause "package" (package_identifier) @name)
139
140(type_declaration (type_spec name: (type_identifier) @name type: (interface_type)))
141
142(type_declaration (type_spec name: (type_identifier) @name type: (struct_type)))
143
144(import_declaration (import_spec) @name)
145
146(var_declaration (var_spec name: (identifier) @name))
147
148(const_declaration (const_spec name: (identifier) @name))