Debian Codegraph @

runtime/queries/go/highlights.scm

raw symbols SCIP
1
2 ; Identifiers
3
4 (field_identifier) @variable.other.member
5
6 (identifier) @variable
7
8 (package_identifier) @namespace
9
10 (const_spec
11 name: (identifier) @constant)
12
13 (keyed_element . (literal_element (identifier) @variable.other.member))
14 (field_declaration
15 name: (field_identifier) @variable.other.member)
16
17 (parameter_declaration (identifier) @variable.parameter)
18 (variadic_parameter_declaration (identifier) @variable.parameter)
19
20 (label_name) @label
21
22 (const_spec
23 name: (identifier) @constant)
24
25 ; Function calls
26
27 (call_expression
28 function: (identifier) @function)
29
30 (call_expression
31 function: (selector_expression
32 field: (field_identifier) @function.method))
33
34 (call_expression
35 function: (identifier) @function.builtin
36 (#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover|min|max|clear)$"))
37
38 ; Types
39
40 (type_identifier) @type
41
42 (type_parameter_list
43 (type_parameter_declaration
44 name: (identifier) @type.parameter))
45
46 ((type_identifier) @type.builtin
47 (#match? @type.builtin "^(any|bool|byte|comparable|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$"))
48
49 ; Type definition names: `type Foo struct{}`, `type Bar = Baz`.
50 (type_spec
51 name: (type_identifier) @type.definition)
52 (type_alias
53 name: (type_identifier) @type.definition)
54
55 ; Function definitions
56
57 (function_declaration
58 name: (identifier) @function)
59
60 (method_declaration
61 name: (field_identifier) @function.method)
62
63 (method_elem
64 name: (field_identifier) @function.method)
65
66 ; Blank identifier `_` (Go's discard) — dim as unused.
67 ; It parses as (blank_identifier) in imports and as (identifier) elsewhere
68 ; (`_ = x`, `a, _ := f()`, `for _, v := range`).
69 (blank_identifier) @comment.unused
70 ((identifier) @comment.unused
71 (#eq? @comment.unused "_"))
72
73 ; Operators
74
75 [
76 "--"
77 "-"
78 "-="
79 ":="
80 "!"
81 "!="
82 "..."
83 "*"
84 "*"
85 "*="
86 "/"
87 "/="
88 "&"
89 "&&"
90 "&="
91 "%"
92 "%="
93 "^"
94 "^="
95 "+"
96 "++"
97 "+="
98 "<-"
99 "<"
100 "<<"
101 "<<="
102 "<="
103 "="
104 "=="
105 ">"
106 ">="
107 ">>"
108 ">>="
109 "|"
110 "|="
111 "||"
112 "&^"
113 "&^="
114 "~"
115 ] @operator
116
117 ; Keywords
118
119 [
120 "default"
121 "type"
122 ] @keyword
123
124 [
125 "defer"
126 "go"
127 "goto"
128 ] @keyword.control
129
130 [
131 "if"
132 "else"
133 "switch"
134 "select"
135 "case"
136 ] @keyword.control.conditional
137
138 [
139 "for"
140 "range"
141 ] @keyword.control.repeat
142
143 [
144 "import"
145 "package"
146 ] @keyword.control.import
147
148 [
149 "return"
150 "continue"
151 "break"
152 "fallthrough"
153 ] @keyword.control.return
154
155 [
156 "func"
157 ] @keyword.function
158
159 [
160 "var"
161 "chan"
162 "interface"
163 "map"
164 "struct"
165 ] @keyword.storage.type
166
167 [
168 "const"
169 ] @keyword.storage.modifier
170
171 ; Delimiters
172
173 [
174 ":"
175 "."
176 ","
177 ";"
178 ] @punctuation.delimiter
179
180 [
181 "("
182 ")"
183 "["
184 "]"
185 "{"
186 "}"
187 ] @punctuation.bracket
188
189 ; Literals
190
191 [
192 (interpreted_string_literal)
193 (raw_string_literal)
194 ] @string
195
196 (rune_literal) @constant.character
197
198 (escape_sequence) @constant.character.escape
199
200 [
201 (int_literal)
202 ] @constant.numeric.integer
203
204 [
205 (float_literal)
206 (imaginary_literal)
207 ] @constant.numeric.float
208
209 [
210 (true)
211 (false)
212 ] @constant.builtin.boolean
213
214 [
215 (nil)
216 (iota)
217 ] @constant.builtin
218
219 ; Comments
220 (comment) @comment
221
222 ; Doc Comments
223 (source_file
224 (comment) @comment.block.documentation . (comment)* . [
225 (package_clause) ; `package`
226 (type_declaration) ; `type`
227 (function_declaration) ; `func`
228 (method_declaration) ; `func`
229 (var_declaration) ; `var`
230 (const_declaration) ; `const`
231 ; var (
232 ; A = 1
233 ; B = 2
234 ; )
235 (var_spec)
236 ; const (
237 ; A = 1
238 ; B = 2
239 ; )
240 (const_spec)
241 ])