on bbcdcd0 help sign in
helix/runtime/queries/lua/highlights.scm
169 lines 2.3 kB history raw
1;;; Highlighting for lua
3;;; Builtins
4((identifier) @variable.builtin
5 (#eq? @variable.builtin "self"))
7;; Keywords
9(if_statement
11 "if"
12 "then"
13 "end"
14] @keyword.control.conditional)
16(elseif_statement
18 "elseif"
19 "then"
20 "end"
21] @keyword.control.conditional)
23(else_statement
25 "else"
26 "end"
27] @keyword.control.conditional)
29(for_statement
31 "for"
32 "do"
33 "end"
34] @keyword.control.repeat)
36(while_statement
38 "while"
39 "do"
40 "end"
41] @keyword.control.repeat)
43(repeat_statement
45 "repeat"
46 "until"
47] @keyword.control.repeat)
49(do_statement
51 "do"
52 "end"
53] @keyword)
55"return" @keyword.control.return
58 "in"
59 "local"
60 (break_statement)
61 "goto"
62] @keyword
64(function_declaration
66 "function"
67 "end"
68] @keyword.function)
70(function_definition
72 "function"
73 "end"
74] @keyword.function)
76;; Operators
79 "not"
80 "and"
81 "or"
82] @keyword.operator
85"="
86"~="
87"=="
88"<="
89">="
90"<"
91">"
92"+"
93"-"
94"%"
95"/"
96"//"
97"*"
98"^"
99"&"
100"~"
101"|"
102">>"
103"<<"
104".."
105"#"
106 ] @operator
108;; Punctuation
109["," "." ":" ";"] @punctuation.delimiter
111;; Brackets
114 "("
115 ")"
116 "["
117 "]"
118 "{"
119 "}"
120] @punctuation.bracket
122; ;; Constants
124(false)
125(true)
126] @constant.builtin.boolean
127(nil) @constant.builtin
128(vararg_expression) @constant
130((identifier) @constant
131 (#match? @constant "^[A-Z][A-Z_0-9]*$"))
133;; Parameters
134(parameters
135 (identifier) @variable.parameter)
137; ;; Functions
138(function_declaration name: (identifier) @function)
139(function_call name: (identifier) @function.call)
141(function_declaration name: (dot_index_expression field: (identifier) @function))
142(function_call name: (dot_index_expression field: (identifier) @function.call))
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)))
151(method_index_expression method: (identifier) @function.method)
153;; Nodes
154(comment) @comment
155(string) @string
156(number) @constant.numeric.integer
157(label_statement) @label
158; A bit of a tricky one, this will only match field names
159(field . (identifier) @variable.other.member (_))
160(hash_bang_line) @comment
162;; Property
163(dot_index_expression field: (identifier) @variable.other.member)
165;; Variable
166(identifier) @variable
168;; Error
169(ERROR) @error