| 1 |
filetype: lua |
| 2 |
|
| 3 |
detect: |
| 4 |
filename: "\\.lua$" |
| 5 |
|
| 6 |
rules: |
| 7 |
- statement: "\\b(do|end|while|break|repeat|until|if|elseif|then|else|for|in|function|local|return|goto)\\b" |
| 8 |
- statement: "\\b(not|and|or)\\b" |
| 9 |
- statement: "\\b(debug|string|math|table|io|coroutine|os|utf8|bit32)\\b\\." |
| 10 |
- statement: "\\b(_ENV|_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\s*\\(" |
| 11 |
- identifier: "io\\.\\b(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)\\b" |
| 12 |
- identifier: "math\\.\\b(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log|max|maxinteger|min|mininteger|modf|pi|pow|rad|random|randomseed|sin|sqrt|tan|tointeger|type|ult)\\b" |
| 13 |
- identifier: "os\\.\\b(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\\b" |
| 14 |
- identifier: "package\\.\\b(config|cpath|loaded|loadlib|path|preload|seeall|searchers|searchpath)\\b" |
| 15 |
- identifier: "string\\.\\b(byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)\\b" |
| 16 |
- identifier: "table\\.\\b(concat|insert|maxn|move|pack|remove|sort|unpack)\\b" |
| 17 |
- identifier: "utf8\\.\\b(char|charpattern|codes|codepoint|len|offset)\\b" |
| 18 |
- identifier: "coroutine\\.\\b(create|isyieldable|resume|running|status|wrap|yield)\\b" |
| 19 |
- identifier: "debug\\.\\b(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setfenv|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin)\\b" |
| 20 |
- identifier: "bit32\\.\\b(arshift|band|bnot|bor|btest|bxor|extract|replace|lrotate|lshift|rrotate|rshift)\\b" |
| 21 |
- identifier: "\\:\\b(close|flush|lines|read|seek|setvbuf|write|byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)\\b" |
| 22 |
- identifier: "\\b(self|arg)\\b" |
| 23 |
- constant: "\\b(false|nil|true)\\b" |
| 24 |
- statement: "(\\b(dofile|require|include)|%q|%!|%Q|%r|%x)\\b" |
| 25 |
|
| 26 |
- symbol.brackets: "[(){}\\[\\]]" |
| 27 |
- symbol: "(\\*|//|/|%|\\+|-|\\^|>|>=|<|<=|~=|=|[\\.]{2,3}|#)" |
| 28 |
|
| 29 |
- constant.number: "\\b((0[xX](([0-9A-Fa-f]+\\.[0-9A-Fa-f]*)|(\\.?[0-9A-Fa-f]+))([pP][-+]?[0-9]+)?)|((([0-9]+\\.[0-9]*)|(\\.?[0-9]+))([eE][-+]?[0-9]+)?))" |
| 30 |
|
| 31 |
- constant.string: |
| 32 |
start: "\"" |
| 33 |
end: "\"" |
| 34 |
skip: "\\\\." |
| 35 |
rules: |
| 36 |
- constant.specialChar: "\\\\([abfnrtvz\\'\"]|[0-9]{1,3}|x[0-9a-fA-F][0-9a-fA-F]|u\\{[0-9a-fA-F]+\\})" |
| 37 |
|
| 38 |
- constant.string: |
| 39 |
start: "'" |
| 40 |
end: "'" |
| 41 |
skip: "\\\\." |
| 42 |
rules: |
| 43 |
- constant.specialChar: "\\\\([abfnrtvz\\'\"]|[0-9]{1,3}|x[0-9a-fA-F][0-9a-fA-F]|u\\{[0-9a-fA-F]+\\})" |
| 44 |
|
| 45 |
- constant.string: |
| 46 |
start: "\\[\\[" |
| 47 |
end: "\\]\\]" |
| 48 |
rules: [] |
| 49 |
|
| 50 |
# support first few lengths of "long brackets" explicitly |
| 51 |
# brackets longer than that will give false positives |
| 52 |
|
| 53 |
- constant.string: |
| 54 |
start: "\\[=\\[" |
| 55 |
end: "\\]=\\]" |
| 56 |
rules: [] |
| 57 |
|
| 58 |
- constant.string: |
| 59 |
start: "\\[==\\[" |
| 60 |
end: "\\]==\\]" |
| 61 |
rules: [] |
| 62 |
|
| 63 |
- constant.string: |
| 64 |
start: "\\[===\\[" |
| 65 |
end: "\\]===\\]" |
| 66 |
rules: [] |
| 67 |
|
| 68 |
- constant.string: |
| 69 |
start: "\\[====+\\[" |
| 70 |
end: "\\]====+\\]" |
| 71 |
rules: [] |
| 72 |
|
| 73 |
- comment.block: |
| 74 |
start: "\\-\\-\\[\\[" |
| 75 |
end: "\\]\\]" |
| 76 |
rules: |
| 77 |
- todo: "(TODO|NOTE|FIXME):?" |
| 78 |
|
| 79 |
# support long brackets, same as with multiline strings |
| 80 |
|
| 81 |
- comment.block: |
| 82 |
start: "\\-\\-\\[=\\[" |
| 83 |
end: "\\]=\\]" |
| 84 |
rules: |
| 85 |
- todo: "(TODO|NOTE|FIXME):?" |
| 86 |
|
| 87 |
- comment.block: |
| 88 |
start: "\\-\\-\\[==\\[" |
| 89 |
end: "\\]==\\]" |
| 90 |
rules: |
| 91 |
- todo: "(TODO|NOTE|FIXME):?" |
| 92 |
|
| 93 |
- comment.block: |
| 94 |
start: "\\-\\-\\[===\\[" |
| 95 |
end: "\\]===\\]" |
| 96 |
rules: |
| 97 |
- todo: "(TODO|NOTE|FIXME):?" |
| 98 |
|
| 99 |
- comment.block: |
| 100 |
start: "\\-\\-\\[====+\\[" |
| 101 |
end: "\\]====+\\]" |
| 102 |
rules: |
| 103 |
- todo: "(TODO|NOTE|FIXME):?" |
| 104 |
|
| 105 |
# this has to go after block comment or block comment does not work |
| 106 |
|
| 107 |
- comment: |
| 108 |
start: "\\-\\-" |
| 109 |
end: "$" |
| 110 |
rules: |
| 111 |
- todo: "(TODO|NOTE|FIXME):?" |