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 ((function_declaration
61 name: (identifier) @function.public)
62 (#match? @function.public "^[A-Z]"))
63
64 (method_declaration
65 name: (field_identifier) @function.method)
66
67 ((method_declaration
68 name: (field_identifier) @function.method.public)
69 (#match? @function.method.public "^[A-Z]"))
70
71 (method_elem
72 name: (field_identifier) @function.method)
73
74 ((method_elem
75 name: (field_identifier) @function.method.public)
76 (#match? @function.method.public "^[A-Z]"))
77
78 ; Blank identifier `_` (Go's discard) — dim as unused.
79 ; It parses as (blank_identifier) in imports and as (identifier) elsewhere
80 ; (`_ = x`, `a, _ := f()`, `for _, v := range`).
81 (blank_identifier) @comment.unused
82 ((identifier) @comment.unused
83 (#eq? @comment.unused "_"))
84
85 ; Operators
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 "="
116 "=="
117 ">"
118 ">="
119 ">>"
120 ">>="
121 "|"
122 "|="
123 "||"
124 "&^"
125 "&^="
126 "~"
127 ] @operator
128
129 ; Keywords
130
131 [
132 "default"
133 "type"
134 ] @keyword
135
136 [
137 "defer"
138 "go"
139 "goto"
140 ] @keyword.control
141
142 [
143 "if"
144 "else"
145 "switch"
146 "select"
147 "case"
148 ] @keyword.control.conditional
149
150 [
151 "for"
152 "range"
153 ] @keyword.control.repeat
154
155 [
156 "import"
157 "package"
158 ] @keyword.control.import
159
160 [
161 "return"
162 "continue"
163 "break"
164 "fallthrough"
165 ] @keyword.control.return
166
167 [
168 "func"
169 ] @keyword.function
170
171 [
172 "var"
173 "chan"
174 "interface"
175 "map"
176 "struct"
177 ] @keyword.storage.type
178
179 [
180 "const"
181 ] @keyword.storage.modifier
182
183 ; Delimiters
184
185 [
186 ":"
187 "."
188 ","
189 ";"
190 ] @punctuation.delimiter
191
192 [
193 "("
194 ")"
195 "["
196 "]"
197 "{"
198 "}"
199 ] @punctuation.bracket
200
201 ; Literals
202
203 [
204 (interpreted_string_literal)
205 (raw_string_literal)
206 ] @string
207
208 (rune_literal) @constant.character
209
210 (escape_sequence) @constant.character.escape
211
212 [
213 (int_literal)
214 ] @constant.numeric.integer
215
216 [
217 (float_literal)
218 (imaginary_literal)
219 ] @constant.numeric.float
220
221 [
222 (true)
223 (false)
224 ] @constant.builtin.boolean
225
226 [
227 (nil)
228 (iota)
229 ] @constant.builtin
230
231 ; Comments
232 (comment) @comment
233
234 ; Doc Comments
235 (source_file
236 (comment) @comment.block.documentation . (comment)* . [
237 (package_clause) ; `package`
238 (type_declaration) ; `type`
239 (function_declaration) ; `func`
240 (method_declaration) ; `func`
241 (var_declaration) ; `var`
242 (const_declaration) ; `const`
243 ; var (
244 ; A = 1
245 ; B = 2
246 ; )
247 (var_spec)
248 ; const (
249 ; A = 1
250 ; B = 2
251 ; )
252 (const_spec)
253 ])