@@ -1,7 +1,8 @@
1;;; Highlighting for lua
1;;; Highlighting for lua
3;;; Builtins
3;;; Builtins
4−(self) @variable.builtin
4+((identifier) @variable.builtin
5+ (#eq? @variable.builtin "self"))
@@ -12,20 +13,20 @@
13] @keyword.control.conditional)
14] @keyword.control.conditional)
19−] @keyword.control.conditional
21+] @keyword.control.conditional)
21−(for_statement
23+(else_statement
26−] @keyword.control.repeat)
27+] @keyword.control.conditional)
28−(for_in_statement
29+(for_statement
@@ -51,21 +52,34 @@
52] @keyword)
53] @keyword)
55+"return" @keyword.control.return
57 (break_statement)
60 (break_statement)
62;; Operators
76;; Operators
68−] @operator
82+] @keyword.operator
@@ -95,6 +109,7 @@
95["," "." ":" ";"] @punctuation.delimiter
109["," "." ":" ";"] @punctuation.delimiter
97;; Brackets
111;; Brackets
@@ -110,7 +125,8 @@
111] @constant.builtin.boolean
126] @constant.builtin.boolean
112(nil) @constant.builtin
127(nil) @constant.builtin
113−(spread) @constant ;; "..."
128+(vararg_expression) @constant
114((identifier) @constant
130((identifier) @constant
115 (#match? @constant "^[A-Z][A-Z_0-9]*$"))
131 (#match? @constant "^[A-Z][A-Z_0-9]*$"))
@@ -119,45 +135,32 @@
119 (identifier) @variable.parameter)
135 (identifier) @variable.parameter)
121; ;; Functions
137; ;; Functions
122−(function [(function_name) (identifier)] @function)
138+(function_declaration name: (identifier) @function)
123−(function ["function" "end"] @keyword.function)
127− (function_name_field
128− (property_identifier) @function .)))
130−(local_function (identifier) @function)
139+(function_call name: (identifier) @function.call)
131−(local_function ["function" "end"] @keyword.function)
133−(variable_declaration
141+(function_declaration name: (dot_index_expression field: (identifier) @function))
134− (variable_declarator (identifier) @function) (function_definition))
142+(function_call name: (dot_index_expression field: (identifier) @function.call))
135−(local_variable_declaration
136− (variable_declarator (identifier) @function) (function_definition))
138−(function_definition ["function" "end"] @keyword.function)
144+; TODO: incorrectly highlights variable N in `N, nop = 42, function() end`
145+(assignment_statement
147+ name: (identifier) @function)
149+ value: (function_definition)))
140−(function_call
151+(method_index_expression method: (identifier) @function.method)
142− ((identifier) @variable (method) @function.method)
143− ((_) (method) @function.method)
144− (identifier) @function
145− (field_expression (property_identifier) @function)
150−(table ["{" "}"] @constructor)
151(comment) @comment
154(comment) @comment
152(string) @string
155(string) @string
153(number) @constant.numeric.integer
156(number) @constant.numeric.integer
154(label_statement) @label
157(label_statement) @label
155; A bit of a tricky one, this will only match field names
158; A bit of a tricky one, this will only match field names
156(field . (identifier) @variable.other.member (_))
159(field . (identifier) @variable.other.member (_))
157−(shebang) @comment
160+(hash_bang_line) @comment
159;; Property
162;; Property
160−(property_identifier) @variable.other.member
163+(dot_index_expression field: (identifier) @variable.other.member)
162;; Variable
165;; Variable
163(identifier) @variable
166(identifier) @variable