@@ -1,7 +1,8 @@
11;;; Highlighting for lua
22
33;;; Builtins
4−(self) @variable.builtin
4+((identifier) @variable.builtin
5+ (#eq? @variable.builtin "self"))
56
67;; Keywords
78
@@ -12,20 +13,20 @@
1213 "end"
1314] @keyword.control.conditional)
1415
16+(elseif_statement
1517[
16− "else"
1718 "elseif"
1819 "then"
19−] @keyword.control.conditional
20+ "end"
21+] @keyword.control.conditional)
2022
21−(for_statement
23+(else_statement
2224[
23− "for"
24− "do"
25+ "else"
2526 "end"
26−] @keyword.control.repeat)
27+] @keyword.control.conditional)
2728
28−(for_in_statement
29+(for_statement
2930[
3031 "for"
3132 "do"
@@ -51,21 +52,34 @@
5152 "end"
5253] @keyword)
5354
55+"return" @keyword.control.return
56+
5457[
5558 "in"
5659 "local"
5760 (break_statement)
5861 "goto"
59− "return"
6062] @keyword
6163
64+(function_declaration
65+[
66+ "function"
67+ "end"
68+] @keyword.function)
69+
70+(function_definition
71+[
72+ "function"
73+ "end"
74+] @keyword.function)
75+
6276;; Operators
6377
6478[
6579 "not"
6680 "and"
6781 "or"
68−] @operator
82+] @keyword.operator
6983
7084[
7185"="
@@ -95,6 +109,7 @@
95109["," "." ":" ";"] @punctuation.delimiter
96110
97111;; Brackets
112+
98113[
99114 "("
100115 ")"
@@ -110,7 +125,8 @@
110125(true)
111126] @constant.builtin.boolean
112127(nil) @constant.builtin
113−(spread) @constant ;; "..."
128+(vararg_expression) @constant
129+
114130((identifier) @constant
115131 (#match? @constant "^[A-Z][A-Z_0-9]*$"))
116132
@@ -119,45 +135,32 @@
119135 (identifier) @variable.parameter)
120136
121137; ;; 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)
138+(function_declaration name: (identifier) @function)
139+(function_call name: (identifier) @function.call)
132140
133−(variable_declaration
134− (variable_declarator (identifier) @function) (function_definition))
135−(local_variable_declaration
136− (variable_declarator (identifier) @function) (function_definition))
141+(function_declaration name: (dot_index_expression field: (identifier) @function))
142+(function_call name: (dot_index_expression field: (identifier) @function.call))
137143
138−(function_definition ["function" "end"] @keyword.function)
144+; TODO: incorrectly highlights variable N in `N, nop = 42, function() end`
145+(assignment_statement
146+ (variable_list
147+ name: (identifier) @function)
148+ (expression_list
149+ value: (function_definition)))
139150
140−(function_call
141− [
142− ((identifier) @variable (method) @function.method)
143− ((_) (method) @function.method)
144− (identifier) @function
145− (field_expression (property_identifier) @function)
146− ]
147− . (arguments))
151+(method_index_expression method: (identifier) @function.method)
148152
149153;; Nodes
150−(table ["{" "}"] @constructor)
151154(comment) @comment
152155(string) @string
153156(number) @constant.numeric.integer
154157(label_statement) @label
155158; A bit of a tricky one, this will only match field names
156159(field . (identifier) @variable.other.member (_))
157−(shebang) @comment
160+(hash_bang_line) @comment
158161
159162;; Property
160−(property_identifier) @variable.other.member
163+(dot_index_expression field: (identifier) @variable.other.member)
161164
162165;; Variable
163166(identifier) @variable