| 1 | ;; Lua highlights |
| 2 | |
| 3 | ;;; Keywords |
| 4 | |
| 5 | [ |
| 6 | "do" |
| 7 | "else" |
| 8 | "elseif" |
| 9 | "end" |
| 10 | "for" |
| 11 | "function" |
| 12 | "goto" |
| 13 | "if" |
| 14 | "in" |
| 15 | "local" |
| 16 | "repeat" |
| 17 | "return" |
| 18 | "then" |
| 19 | "until" |
| 20 | "while" |
| 21 | (break_statement) |
| 22 | ] @keyword |
| 23 | |
| 24 | ;;; Operators |
| 25 | |
| 26 | [ |
| 27 | "and" |
| 28 | "not" |
| 29 | "or" |
| 30 | ] @keyword |
| 31 | |
| 32 | [ |
| 33 | "+" |
| 34 | "-" |
| 35 | "*" |
| 36 | "/" |
| 37 | "%" |
| 38 | "^" |
| 39 | "#" |
| 40 | "==" |
| 41 | "~=" |
| 42 | "<=" |
| 43 | ">=" |
| 44 | "<" |
| 45 | ">" |
| 46 | "=" |
| 47 | "&" |
| 48 | "~" |
| 49 | "|" |
| 50 | "<<" |
| 51 | ">>" |
| 52 | "//" |
| 53 | ".." |
| 54 | ] @operator |
| 55 | |
| 56 | ;;; Punctuations |
| 57 | |
| 58 | [ |
| 59 | ";" |
| 60 | ":" |
| 61 | "," |
| 62 | "." |
| 63 | ] @punctuation.delimiter |
| 64 | |
| 65 | [ |
| 66 | "(" |
| 67 | ")" |
| 68 | "[" |
| 69 | "]" |
| 70 | "{" |
| 71 | "}" |
| 72 | ] @punctuation.bracket |
| 73 | |
| 74 | ;;; Constants |
| 75 | |
| 76 | (nil) @boolean |
| 77 | [ |
| 78 | (false) |
| 79 | (true) |
| 80 | ] @boolean |
| 81 | |
| 82 | (vararg_expression) @constant |
| 83 | |
| 84 | ((identifier) @constant |
| 85 | (#match? @constant "^[A-Z][A-Z_0-9]*$")) |
| 86 | |
| 87 | ;;; Numbers |
| 88 | |
| 89 | (number) @number |
| 90 | |
| 91 | ;;; Strings |
| 92 | |
| 93 | (string) @string |
| 94 | (escape_sequence) @string.escape |
| 95 | |
| 96 | ;;; Comments |
| 97 | |
| 98 | (comment) @comment |
| 99 | (hash_bang_line) @comment |
| 100 | |
| 101 | ;;; Tables |
| 102 | |
| 103 | (field name: (identifier) @property) |
| 104 | |
| 105 | (dot_index_expression field: (identifier) @property) |
| 106 | |
| 107 | (table_constructor |
| 108 | [ |
| 109 | "{" |
| 110 | "}" |
| 111 | ] @punctuation.bracket) |
| 112 | |
| 113 | ;;; Functions |
| 114 | |
| 115 | (parameters (identifier) @variable) |
| 116 | |
| 117 | (function_call |
| 118 | name: [ |
| 119 | (identifier) @function |
| 120 | (dot_index_expression field: (identifier) @function) |
| 121 | ]) |
| 122 | |
| 123 | (function_declaration |
| 124 | name: [ |
| 125 | (identifier) @function |
| 126 | (dot_index_expression field: (identifier) @function) |
| 127 | ]) |
| 128 | |
| 129 | (method_index_expression method: (identifier) @function) |
| 130 | |
| 131 | ;; Built-in functions |
| 132 | (function_call |
| 133 | (identifier) @function |
| 134 | (#any-of? @function |
| 135 | ;; built-in functions in Lua 5.1+ |
| 136 | "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" |
| 137 | "load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print" |
| 138 | "rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable" |
| 139 | "tonumber" "tostring" "type" "unpack" "xpcall")) |
| 140 | |
| 141 | ;;; Variables |
| 142 | |
| 143 | (variable_list |
| 144 | attribute: (attribute |
| 145 | (identifier) @attribute)) |
| 146 | |
| 147 | ;; self reference |
| 148 | ((identifier) @variable.special |
| 149 | (#eq? @variable.special "self")) |
| 150 | |
| 151 | ;; Generic identifier |
| 152 | (identifier) @variable |