@@ -0,0 +1,166 @@
1+;;; Highlighting for lua
2+
3+;;; Builtins
4+(self) @variable.builtin
5+
6+;; Keywords
7+
8+(if_statement
9+[
10+ "if"
11+ "then"
12+ "end"
13+] @keyword.control.conditional)
14+
15+[
16+ "else"
17+ "elseif"
18+ "then"
19+] @keyword.control.conditional
20+
21+(for_statement
22+[
23+ "for"
24+ "do"
25+ "end"
26+] @keyword.control.loop)
27+
28+(for_in_statement
29+[
30+ "for"
31+ "do"
32+ "end"
33+] @keyword.control.loop)
34+
35+(while_statement
36+[
37+ "while"
38+ "do"
39+ "end"
40+] @keyword.control.loop)
41+
42+(repeat_statement
43+[
44+ "repeat"
45+ "until"
46+] @keyword.control.loop)
47+
48+(do_statement
49+[
50+ "do"
51+ "end"
52+] @keyword)
53+
54+[
55+ "in"
56+ "local"
57+ (break_statement)
58+ "goto"
59+ "return"
60+] @keyword
61+
62+;; Operators
63+
64+[
65+ "not"
66+ "and"
67+ "or"
68+] @keyword.operator
69+
70+[
71+"="
72+"~="
73+"=="
74+"<="
75+">="
76+"<"
77+">"
78+"+"
79+"-"
80+"%"
81+"/"
82+"//"
83+"*"
84+"^"
85+"&"
86+"~"
87+"|"
88+">>"
89+"<<"
90+".."
91+"#"
92+ ] @operator
93+
94+;; Punctuation
95+["," "." ":" ";"] @punctuation.delimiter
96+
97+;; Brackets
98+[
99+ "("
100+ ")"
101+ "["
102+ "]"
103+ "{"
104+ "}"
105+] @punctuation.bracket
106+
107+; ;; Constants
108+[
109+(false)
110+(true)
111+] @boolean
112+(nil) @constant.builtin
113+(spread) @constant ;; "..."
114+((identifier) @constant
115+ (#match? @constant "^[A-Z][A-Z_0-9]*$"))
116+
117+;; Parameters
118+(parameters
119+ (identifier) @parameter)
120+
121+; ;; Functions
122+(function [(function_name) (identifier)] @function)
123+(function ["function" "end"] @keyword.function)
124+
125+(function
126+ (function_name
127+ (function_name_field
128+ (property_identifier) @function .)))
129+
130+(local_function (identifier) @function)
131+(local_function ["function" "end"] @keyword.function)
132+
133+(variable_declaration
134+ (variable_declarator (identifier) @function) (function_definition))
135+(local_variable_declaration
136+ (variable_declarator (identifier) @function) (function_definition))
137+
138+(function_definition ["function" "end"] @keyword.function)
139+
140+(function_call
141+ [
142+ ((identifier) @variable (method) @method)
143+ ((_) (method) @method)
144+ (identifier) @function
145+ (field_expression (property_identifier) @function)
146+ ]
147+ . (arguments))
148+
149+;; Nodes
150+(table ["{" "}"] @constructor)
151+(comment) @comment
152+(string) @string
153+(number) @number
154+(label_statement) @label
155+; A bit of a tricky one, this will only match field names
156+(field . (identifier) @property (_))
157+(shebang) @comment
158+
159+;; Property
160+(property_identifier) @property
161+
162+;; Variable
163+(identifier) @variable
164+
165+;; Error
166+(ERROR) @error