]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/lua.yaml
Fix Lua number syntax highlighting (#2409)
[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
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: "\\\\."
37
38     - constant.string:
39         start: "'"
40         end: "'"
41         skip: "\\\\."
42         rules:
43             - constant.specialChar: "\\\\."
44
45     - constant.string:
46         start: "\\[\\["
47         end: "\\]\\]"
48         rules:
49             - constant.specialChar: "\\\\."
50
51 # support first few lengths of "long brackets" explicitly
52 # brackets longer than that will give false positives
53
54     - constant.string:
55         start: "\\[=\\["
56         end: "\\]=\\]"
57         rules:
58             - constant.specialChar: "\\\\."
59
60     - constant.string:
61         start: "\\[==\\["
62         end: "\\]==\\]"
63         rules:
64             - constant.specialChar: "\\\\."
65
66     - constant.string:
67         start: "\\[===\\["
68         end: "\\]===\\]"
69         rules:
70             - constant.specialChar: "\\\\."
71
72     - constant.string:
73         start: "\\[====+\\["
74         end: "\\]====+\\]"
75         rules:
76             - constant.specialChar: "\\\\."
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):?"