]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/lua.yaml
934f6a317508b665647314dd5e2b404c63393c35
[micro.git] / runtime / syntax / lua.yaml
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)\\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|sinh|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     - constant.number: "\\b([0-9]+)\\b"
26     - symbol.brackets: "[(){}\\[\\]]"
27     - symbol: "(\\*|//|/|%|\\+|-|\\^|>|>=|<|<=|~=|=|[\\.]{2,3}|#)"
28
29     - constant.string:
30         start: "\""
31         end: "\""
32         skip: "\\\\."
33         rules:
34             - constant.specialChar: "\\\\."
35
36     - constant.string:
37         start: "'"
38         end: "'"
39         skip: "\\\\."
40         rules:
41             - constant.specialChar: "\\\\."
42
43     - constant.string:
44         start: "\\[\\["
45         end: "\\]\\]"
46         rules:
47             - constant.specialChar: "\\\\."
48
49 # support first few lengths of "long brackets" explicitly
50 # brackets longer than that will give false positives
51
52     - constant.string:
53         start: "\\[=\\["
54         end: "\\]=\\]"
55         rules:
56             - constant.specialChar: "\\\\."
57
58     - constant.string:
59         start: "\\[==\\["
60         end: "\\]==\\]"
61         rules:
62             - constant.specialChar: "\\\\."
63
64     - constant.string:
65         start: "\\[===\\["
66         end: "\\]===\\]"
67         rules:
68             - constant.specialChar: "\\\\."
69
70     - constant.string:
71         start: "\\[====+\\["
72         end: "\\]====+\\]"
73         rules:
74             - constant.specialChar: "\\\\."
75
76     - special: "\\\\[0-7][0-7][0-7]|\\\\x[0-9a-fA-F][0-9a-fA-F]|\\\\[abefnrs]|(\\\\c|\\\\C-|\\\\M-|\\\\M-\\\\C-)."
77
78     - comment.block:
79         start: "\\-\\-\\[\\["
80         end: "\\]\\]"
81         rules:
82             - todo: "(TODO|NOTE|FIXME):?"
83
84 # support long brackets, same as with multiline strings
85
86     - comment.block:
87         start: "\\-\\-\\[=\\["
88         end: "\\]=\\]"
89         rules:
90             - todo: "(TODO|NOTE|FIXME):?"
91
92     - comment.block:
93         start: "\\-\\-\\[==\\["
94         end: "\\]==\\]"
95         rules:
96             - todo: "(TODO|NOTE|FIXME):?"
97
98     - comment.block:
99         start: "\\-\\-\\[===\\["
100         end: "\\]===\\]"
101         rules:
102             - todo: "(TODO|NOTE|FIXME):?"
103
104     - comment.block:
105         start: "\\-\\-\\[====+\\["
106         end: "\\]====+\\]"
107         rules:
108             - todo: "(TODO|NOTE|FIXME):?"
109
110 # this has to go after block comment or block comment does not work
111
112     - comment: 
113         start: "\\-\\-"
114         end: "$"
115         rules:
116             - todo: "(TODO|NOTE|FIXME):?"