|
1 | 1 | ;;; Highlighting for lua
|
2 | 2 |
|
3 | 3 | ;;; Builtins
|
4 |
| -(self) @variable.builtin |
| 4 | +((identifier) @variable.builtin |
| 5 | + (#eq? @variable.builtin "self")) |
5 | 6 |
|
6 | 7 | ;; Keywords
|
7 | 8 |
|
|
12 | 13 | "end"
|
13 | 14 | ] @keyword.control.conditional)
|
14 | 15 |
|
| 16 | +(elseif_statement |
15 | 17 | [
|
16 |
| - "else" |
17 | 18 | "elseif"
|
18 | 19 | "then"
|
19 |
| -] @keyword.control.conditional |
| 20 | + "end" |
| 21 | +] @keyword.control.conditional) |
20 | 22 |
|
21 |
| -(for_statement |
| 23 | +(else_statement |
22 | 24 | [
|
23 |
| - "for" |
24 |
| - "do" |
| 25 | + "else" |
25 | 26 | "end"
|
26 |
| -] @keyword.control.repeat) |
| 27 | +] @keyword.control.conditional) |
27 | 28 |
|
28 |
| -(for_in_statement |
| 29 | +(for_statement |
29 | 30 | [
|
30 | 31 | "for"
|
31 | 32 | "do"
|
|
51 | 52 | "end"
|
52 | 53 | ] @keyword)
|
53 | 54 |
|
| 55 | +"return" @keyword.control.return |
| 56 | + |
54 | 57 | [
|
55 | 58 | "in"
|
56 | 59 | "local"
|
57 | 60 | (break_statement)
|
58 | 61 | "goto"
|
59 |
| - "return" |
60 | 62 | ] @keyword
|
61 | 63 |
|
| 64 | +(function_declaration |
| 65 | +[ |
| 66 | + "function" |
| 67 | + "end" |
| 68 | +] @keyword.function) |
| 69 | + |
| 70 | +(function_definition |
| 71 | +[ |
| 72 | + "function" |
| 73 | + "end" |
| 74 | +] @keyword.function) |
| 75 | + |
62 | 76 | ;; Operators
|
63 | 77 |
|
64 | 78 | [
|
65 | 79 | "not"
|
66 | 80 | "and"
|
67 | 81 | "or"
|
68 |
| -] @operator |
| 82 | +] @keyword.operator |
69 | 83 |
|
70 | 84 | [
|
71 | 85 | "="
|
|
95 | 109 | ["," "." ":" ";"] @punctuation.delimiter
|
96 | 110 |
|
97 | 111 | ;; Brackets
|
| 112 | + |
98 | 113 | [
|
99 | 114 | "("
|
100 | 115 | ")"
|
|
110 | 125 | (true)
|
111 | 126 | ] @constant.builtin.boolean
|
112 | 127 | (nil) @constant.builtin
|
113 |
| -(spread) @constant ;; "..." |
| 128 | +(vararg_expression) @constant |
| 129 | + |
114 | 130 | ((identifier) @constant
|
115 | 131 | (#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
116 | 132 |
|
|
119 | 135 | (identifier) @variable.parameter)
|
120 | 136 |
|
121 | 137 | ; ;; 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) |
132 | 140 |
|
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)) |
137 | 143 |
|
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))) |
139 | 150 |
|
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) |
148 | 152 |
|
149 | 153 | ;; Nodes
|
150 |
| -(table ["{" "}"] @constructor) |
151 | 154 | (comment) @comment
|
152 | 155 | (string) @string
|
153 | 156 | (number) @constant.numeric.integer
|
154 | 157 | (label_statement) @label
|
155 | 158 | ; A bit of a tricky one, this will only match field names
|
156 | 159 | (field . (identifier) @variable.other.member (_))
|
157 |
| -(shebang) @comment |
| 160 | +(hash_bang_line) @comment |
158 | 161 |
|
159 | 162 | ;; Property
|
160 |
| -(property_identifier) @variable.other.member |
| 163 | +(dot_index_expression field: (identifier) @variable.other.member) |
161 | 164 |
|
162 | 165 | ;; Variable
|
163 | 166 | (identifier) @variable
|
|
0 commit comments