Debian Codegraph @

runtime/queries/teal/highlights.scm

raw symbols SCIP
1
2 ;; Primitives
3 (boolean) @constant.builtin.boolean
4 (comment) @comment
5 (shebang_comment) @comment
6 (identifier) @variable
7 ((identifier) @variable.builtin
8 (#eq? @variable.builtin "self"))
9 (nil) @constant.builtin
10 (number) @constant.numeric
11 (string) @string
12 (table_constructor ["{" "}"] @constructor)
13 (varargs "..." @constant.builtin)
14 [ "," "." ":" ";" ] @punctuation.delimiter
15
16 (escape_sequence) @constant.character.escape
17 (format_specifier) @constant.character.escape
18
19 ;; Basic statements/Keywords
20 [ "if" "then" "elseif" "else" ] @keyword.control.conditional
21 [ "for" "while" "repeat" "until" "do" ] @keyword.control.repeat
22 [ "end" ] @keyword
23 [ "in" ] @keyword.operator
24 [ "local" ] @keyword.storage.type
25 [ (break) (goto) ] @keyword.control
26 [ "return" ] @keyword.control.return
27 (label) @label
28
29 ;; Global isn't a real keyword, but it gets special treatment in these places
30 (var_declaration "global" @keyword.storage.type)
31 (type_declaration "global" @keyword.storage.type)
32 (function_statement "global" @keyword.storage.type)
33 (record_declaration "global" @keyword.storage.type)
34 (interface_declaration "global" @keyword.storage.type)
35 (enum_declaration "global" @keyword.storage.type)
36
37 (macroexp_statement "macroexp" @keyword)
38
39 ;; Ops
40 (bin_op (op) @operator)
41 (unary_op (op) @operator)
42 [ "=" "as" ] @operator
43
44 ;; Functions
45 (function_statement
46 "function" @keyword.function
47 . name: (_) @function)
48 (anon_function
49 "function" @keyword.function)
50 (function_body "end" @keyword.function)
51
52 (arg name: (identifier) @variable.parameter)
53
54 (function_signature
55 (arguments
56 . (arg name: (identifier) @variable.builtin))
57 (#eq? @variable.builtin "self"))
58
59 (typeargs
60 "<" @punctuation.bracket
61 . (_) @type.parameter
62 . ("," . (_) @type.parameter)*
63 . ">" @punctuation.bracket)
64
65 (function_call
66 (identifier) @function . (arguments))
67 (function_call
68 (index (_) key: (identifier) @function) . (arguments))
69 (function_call
70 (method_index (_) key: (identifier) @function) . (arguments))
71
72 ;; Types
73
74 ; Contextual keywords in record bodies
75 (record_declaration
76 . [ "record" ] @keyword.storage.type
77 name: (identifier) @type)
78 (anon_record . "record" @keyword.storage.type)
79 (record_body
80 (record_declaration
81 . [ "record" ] @keyword.storage.type
82 . name: (identifier) @type))
83 (record_body
84 (enum_declaration
85 . [ "enum" ] @keyword.storage.type
86 . name: (identifier) @type.enum))
87 (record_body
88 (interface_declaration
89 . [ "interface" ] @keyword.storage.type
90 . name: (identifier) @type))
91 (record_body
92 (typedef
93 . "type" @keyword.storage.type
94 . name: (identifier) @type . "="))
95 (record_body
96 (macroexp_declaration
97 . [ "macroexp" ] @keyword.storage.type))
98 (record_body (metamethod "metamethod" @keyword.storage.modifier))
99 (record_body (userdata) @keyword.storage.modifier)
100
101 ; Contextual keywords in interface bodies
102 (interface_declaration
103 . [ "interface" ] @keyword.storage.type
104 name: (identifier) @type)
105 (anon_interface . "interface" @keyword.storage.type)
106 (interface_body
107 (record_declaration
108 . [ "record" ] @keyword.storage.type
109 . name: (identifier) @type))
110 (interface_body
111 (enum_declaration
112 . [ "enum" ] @keyword.storage.type
113 . name: (identifier) @type.enum))
114 (interface_body
115 (interface_declaration
116 . [ "interface" ] @keyword.storage.type
117 . name: (identifier) @type))
118 (interface_body
119 (typedef
120 . "type" @keyword.storage.type
121 . name: (identifier) @type . "="))
122 (interface_body
123 (macroexp_declaration
124 . [ "macroexp" ] @keyword.storage.type))
125 (interface_body (metamethod "metamethod" @keyword.storage.modifier))
126 (interface_body (userdata) @keyword.storage.modifier)
127
128 (enum_declaration
129 "enum" @keyword.storage.type
130 name: (identifier) @type.enum)
131
132 (type_declaration "type" @keyword.storage.type)
133 (type_declaration (identifier) @type)
134 (simple_type) @type
135 (type_index) @type
136 (type_union "|" @operator)
137 (function_type "function" @type)
138
139 ;; The rest of it
140 (var_declaration
141 declarators: (var_declarators
142 (var name: (identifier) @variable)))
143 (var_declaration
144 declarators: (var_declarators
145 (var
146 "<" @punctuation.bracket
147 . attribute: (attribute) @attribute
148 . ">" @punctuation.bracket)))
149 [ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
150
151 ;; Only highlight format specifiers in calls to string.format
152 ;; string.format('...')
153 ;(function_call
154 ; called_object: (index
155 ; (identifier) @base
156 ; key: (identifier) @entry)
157 ; arguments: (arguments .
158 ; (string (format_specifier) @string.escape))
159 ;
160 ; (#eq? @base "string")
161 ; (#eq? @entry "format"))
162
163 ;; ('...'):format()
164 ;(function_call
165 ; called_object: (method_index
166 ; (string (format_specifier) @string.escape)
167 ; key: (identifier) @func-name)
168 ; (#eq? @func-name "format"))
169
170