1;;; Highlighting for lua
  2
  3;;; Builtins
  4;; Keywords
  5
  6[(if_start)
  7 (if_then)
  8 (if_elseif)
  9 (if_else)
 10 (if_end)] @keyword.conditional
 11
 12[(for_start)
 13 (for_in)
 14 (for_do)
 15 (for_end)] @keyword.repeat
 16
 17[(while_start)
 18 (while_do)
 19 (while_end)] @keyword.repeat
 20
 21[(repeat_start)
 22 (repeat_until)] @keyword.repeat
 23
 24(break_statement) @keyword.repeat
 25
 26[(return_statement)
 27 (module_return_statement)] @keyword.return
 28
 29[(do_start)
 30 (do_end)] @keyword
 31
 32; [
 33;  "goto"
 34; ] @keyword
 35
 36;; Operators
 37
 38; TODO: I think I've made a bunch of these nodes.
 39;   we might be able to just use those!
 40
 41[
 42 "not"
 43 "and"
 44 "or"] @keyword.operator
 45
 46["="
 47 "~="
 48 "=="
 49 "<="
 50 ">="
 51 "<"
 52 ">"
 53 "+"
 54 "-"
 55 "%"
 56 "/"
 57 "//"
 58 "*"
 59 "^"
 60 "&"
 61 "~"
 62 "|"
 63 ">>"
 64 "<<"
 65 ".."
 66 "#"] @operator
 67
 68
 69
 70;; Punctuation
 71["," "."] @punctuation.delimiter
 72
 73;; Brackets
 74[(left_paren)
 75 (right_paren)
 76 "["
 77 "]"
 78 "{"
 79 "}"] @punctuation.bracket
 80
 81;; Variables
 82(identifier) @variable
 83(
 84  (identifier) @variable.builtin
 85  (#match? @variable.builtin "self"))
 86
 87; (preproc_call
 88;   directive: (preproc_directive) @_u
 89;   argument: (_) @constant
 90;   (#eq? @_u "#undef"))
 91
 92;; Constants
 93(boolean) @boolean
 94(nil) @constant.builtin
 95(ellipsis) @constant ;; "..."
 96(local) @keyword
 97
 98;; Functions
 99(function_call_paren) @function.bracket
100
101[
102  (function_start)
103  (function_end)] @keyword.function
104
105(emmy_type) @type
106(emmy_literal) @string
107(emmy_parameter
108 (identifier) @parameter
109 description: (_)? @comment) @comment
110
111(emmy_class) @comment
112(emmy_field name: (_) @property) @comment
113(emmy_function_parameter
114  name: (_) @parameter) 
115
116(emmy_type_dictionary_value key: (identifier) @property)
117
118(emmy_note) @comment
119(emmy_see) @comment
120
121; TODO: Make the container so we can still highlight the beginning of the line
122; (emmy_eval_container) @comment
123; (_emmy_eval_container) @comment
124
125(emmy_return) @comment
126
127; TODO: returns
128
129(emmy_header) @comment
130(emmy_ignore) @comment
131(documentation_brief) @comment
132
133(documentation_command) @comment
134
135(function_call
136  [
137    ((identifier)+ @identifier . (identifier) @function.call . (function_call_paren))
138    ((identifier) @function.call.lua . (function_call_paren))])
139
140(function_call
141  prefix: (identifier) @function.call.lua
142  args: (string_argument) @string)
143
144(function_call
145 prefix: (identifier) @function.call.lua
146 args: (table_argument))
147
148; (function [(function_name) (identifier)] @function)
149; (function ["function" "end"] @keyword.function)
150; (local_function [(function_name) (identifier)] @function)
151; (local_function ["function" "end"] @keyword.function)
152; (function_definition ["function" "end"] @keyword.function)
153
154; TODO: Do I have replacements for these.
155; (property_identifier) @property
156; (method) @method
157
158; (function_call (identifier) @function . (arguments))
159; (function_call (field (property_identifier) @function) . (arguments))
160
161;; Parameters
162; (parameters (identifier) @parameter)
163
164;; Nodes
165; (table ["{" "}"] @constructor)
166(comment) @comment
167(string) @string
168(number) @number
169; (label_statement) @label
170
171;; Error
172(ERROR) @error