2020-04-20 16:18:02 +02:00
|
|
|
;; Keywords
|
2020-09-05 09:53:21 -05:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
"return" @keyword.return
|
2020-09-05 09:53:21 -05:00
|
|
|
|
2020-07-16 09:30:15 +02:00
|
|
|
[
|
2022-01-18 22:15:26 +01:00
|
|
|
"goto"
|
|
|
|
|
"in"
|
|
|
|
|
"local"
|
|
|
|
|
] @keyword
|
2020-06-30 08:59:34 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(break_statement) @keyword
|
2020-06-30 08:59:34 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(do_statement
|
2020-09-05 09:53:21 -05:00
|
|
|
[
|
2020-07-05 19:58:47 +02:00
|
|
|
"do"
|
2020-09-05 09:53:21 -05:00
|
|
|
"end"
|
2022-01-18 22:15:26 +01:00
|
|
|
] @keyword)
|
2020-09-05 09:53:21 -05:00
|
|
|
|
|
|
|
|
(while_statement
|
|
|
|
|
[
|
2020-07-05 19:58:47 +02:00
|
|
|
"while"
|
2020-09-05 09:53:21 -05:00
|
|
|
"do"
|
|
|
|
|
"end"
|
|
|
|
|
] @repeat)
|
2020-07-05 19:58:47 +02:00
|
|
|
|
2020-09-05 09:53:21 -05:00
|
|
|
(repeat_statement
|
|
|
|
|
[
|
|
|
|
|
"repeat"
|
|
|
|
|
"until"
|
|
|
|
|
] @repeat)
|
2020-06-30 08:59:34 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(if_statement
|
|
|
|
|
[
|
|
|
|
|
"if"
|
|
|
|
|
"elseif"
|
|
|
|
|
"else"
|
|
|
|
|
"then"
|
|
|
|
|
"end"
|
|
|
|
|
] @conditional)
|
|
|
|
|
|
|
|
|
|
(elseif_statement
|
|
|
|
|
[
|
|
|
|
|
"elseif"
|
|
|
|
|
"then"
|
|
|
|
|
"end"
|
|
|
|
|
] @conditional)
|
|
|
|
|
|
|
|
|
|
(else_statement
|
|
|
|
|
[
|
|
|
|
|
"else"
|
|
|
|
|
"end"
|
|
|
|
|
] @conditional)
|
|
|
|
|
|
|
|
|
|
(for_statement
|
2021-01-27 09:29:44 +01:00
|
|
|
[
|
2022-01-18 22:15:26 +01:00
|
|
|
"for"
|
2021-01-27 09:29:44 +01:00
|
|
|
"do"
|
|
|
|
|
"end"
|
2022-01-18 22:15:26 +01:00
|
|
|
] @repeat)
|
2021-01-27 09:29:44 +01:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(function_declaration
|
2020-06-30 08:59:34 +02:00
|
|
|
[
|
2022-01-18 22:15:26 +01:00
|
|
|
"function"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.function)
|
2020-04-20 16:18:02 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(function_definition
|
|
|
|
|
[
|
|
|
|
|
"function"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.function)
|
2021-07-04 19:55:59 +03:00
|
|
|
|
2020-04-20 16:18:02 +02:00
|
|
|
;; Operators
|
2020-09-13 15:08:11 +02:00
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"and"
|
2022-01-18 22:15:26 +01:00
|
|
|
"not"
|
2020-09-13 15:08:11 +02:00
|
|
|
"or"
|
|
|
|
|
] @keyword.operator
|
|
|
|
|
|
2020-06-30 08:59:34 +02:00
|
|
|
[
|
2022-01-18 22:15:26 +01:00
|
|
|
"+"
|
|
|
|
|
"-"
|
|
|
|
|
"*"
|
|
|
|
|
"/"
|
|
|
|
|
"%"
|
|
|
|
|
"^"
|
|
|
|
|
"#"
|
|
|
|
|
"=="
|
|
|
|
|
"~="
|
|
|
|
|
"<="
|
|
|
|
|
">="
|
|
|
|
|
"<"
|
|
|
|
|
">"
|
|
|
|
|
"="
|
|
|
|
|
"&"
|
|
|
|
|
"~"
|
|
|
|
|
"|"
|
|
|
|
|
"<<"
|
|
|
|
|
">>"
|
|
|
|
|
"//"
|
|
|
|
|
".."
|
|
|
|
|
] @operator
|
|
|
|
|
|
|
|
|
|
;; Punctuations
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
";"
|
|
|
|
|
":"
|
2023-03-19 21:04:38 -04:00
|
|
|
"::"
|
2022-01-18 22:15:26 +01:00
|
|
|
","
|
|
|
|
|
"."
|
|
|
|
|
] @punctuation.delimiter
|
2020-08-11 10:04:34 +02:00
|
|
|
|
2020-07-27 20:00:18 -05:00
|
|
|
;; Brackets
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2020-07-27 20:00:18 -05:00
|
|
|
[
|
|
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @punctuation.bracket
|
2020-04-20 16:18:02 +02:00
|
|
|
|
2020-09-12 20:57:01 +02:00
|
|
|
;; Variables
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2020-09-12 20:57:01 +02:00
|
|
|
(identifier) @variable
|
|
|
|
|
|
2023-04-28 03:42:54 -04:00
|
|
|
((identifier) @constant.builtin
|
|
|
|
|
(#eq? @constant.builtin "_VERSION"))
|
|
|
|
|
|
2022-03-12 20:17:11 +01:00
|
|
|
((identifier) @variable.builtin
|
2023-04-28 03:42:54 -04:00
|
|
|
(#eq? @variable.builtin "self"))
|
|
|
|
|
|
|
|
|
|
((identifier) @namespace.builtin
|
|
|
|
|
(#any-of? @namespace.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
|
2023-03-16 03:41:31 -04:00
|
|
|
|
|
|
|
|
((identifier) @keyword.coroutine
|
|
|
|
|
(#eq? @keyword.coroutine "coroutine"))
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2022-11-01 12:27:29 +01:00
|
|
|
(variable_list
|
|
|
|
|
attribute: (attribute
|
|
|
|
|
(["<" ">"] @punctuation.bracket
|
|
|
|
|
(identifier) @attribute)))
|
|
|
|
|
|
2023-03-19 21:04:38 -04:00
|
|
|
;; Labels
|
|
|
|
|
|
|
|
|
|
(label_statement (identifier) @label)
|
|
|
|
|
|
|
|
|
|
(goto_statement (identifier) @label)
|
|
|
|
|
|
2022-03-12 20:17:11 +01:00
|
|
|
;; Constants
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2021-08-14 13:33:55 -05:00
|
|
|
((identifier) @constant
|
2021-11-18 09:51:03 +00:00
|
|
|
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
|
2020-04-20 16:18:02 +02:00
|
|
|
|
2022-03-12 20:17:11 +01:00
|
|
|
(vararg_expression) @constant
|
|
|
|
|
|
|
|
|
|
(nil) @constant.builtin
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
(false)
|
|
|
|
|
(true)
|
|
|
|
|
] @boolean
|
|
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
;; Tables
|
|
|
|
|
|
|
|
|
|
(field name: (identifier) @field)
|
|
|
|
|
|
|
|
|
|
(dot_index_expression field: (identifier) @field)
|
|
|
|
|
|
|
|
|
|
(table_constructor
|
|
|
|
|
[
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @constructor)
|
|
|
|
|
|
2020-08-03 21:40:23 -05:00
|
|
|
;; Functions
|
2020-09-08 17:59:16 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(parameters (identifier) @parameter)
|
2021-07-07 08:49:36 -05:00
|
|
|
|
2022-07-29 21:09:58 -03:00
|
|
|
(function_call name: (identifier) @function.call)
|
2022-01-18 22:15:26 +01:00
|
|
|
(function_declaration name: (identifier) @function)
|
2020-06-30 08:59:34 +02:00
|
|
|
|
2022-07-29 21:09:58 -03:00
|
|
|
(function_call name: (dot_index_expression field: (identifier) @function.call))
|
2022-01-18 22:15:26 +01:00
|
|
|
(function_declaration name: (dot_index_expression field: (identifier) @function))
|
2020-09-05 09:27:13 -05:00
|
|
|
|
2022-12-11 23:10:33 +09:00
|
|
|
(method_index_expression method: (identifier) @method.call)
|
2020-09-05 09:27:13 -05:00
|
|
|
|
2021-08-29 14:53:52 -05:00
|
|
|
(function_call
|
|
|
|
|
(identifier) @function.builtin
|
|
|
|
|
(#any-of? @function.builtin
|
|
|
|
|
;; built-in functions in Lua 5.1
|
|
|
|
|
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs"
|
|
|
|
|
"load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print"
|
2023-03-16 03:41:31 -04:00
|
|
|
"rawequal" "rawget" "rawlen" "rawset" "require" "select" "setfenv" "setmetatable"
|
|
|
|
|
"tonumber" "tostring" "type" "unpack" "xpcall"
|
|
|
|
|
"__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc"
|
|
|
|
|
"__idiv" "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex"
|
|
|
|
|
"__pairs" "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
|
2021-08-29 14:53:52 -05:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
;; Others
|
2020-10-21 10:16:05 +05:30
|
|
|
|
2022-09-26 10:19:02 +01:00
|
|
|
(comment) @comment @spell
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2023-03-02 08:06:35 -05:00
|
|
|
((comment) @comment.documentation
|
|
|
|
|
(#lua-match? @comment.documentation "^[-][-][-]"))
|
|
|
|
|
|
|
|
|
|
((comment) @comment.documentation
|
|
|
|
|
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
|
|
|
|
|
|
2022-09-18 20:15:23 +03:00
|
|
|
(hash_bang_line) @preproc
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2020-04-20 19:13:24 +02:00
|
|
|
(number) @number
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2022-09-26 10:19:02 +01:00
|
|
|
(string) @string @spell
|
2020-04-20 16:18:02 +02:00
|
|
|
|
|
|
|
|
;; Error
|
2020-08-03 19:43:17 -05:00
|
|
|
(ERROR) @error
|