]> git.lizzy.rs Git - micro.git/blob - syntax_files/lua.micro
Add syntax flags and fix a couple highlighting bugs
[micro.git] / syntax_files / lua.micro
1 ##############################################################################
2 #
3 # Lua syntax highlighting for Nano.
4 #
5 # Author:  Matthew Wild <mwild1 (at) gmail.com>
6 # License: GPL 2  or later
7 #
8 # Version: 2007-06-06
9 #
10 # Notes: Originally based on Ruby syntax rc by Josef 'Jupp' Schugt
11 ##############################################################################
12
13
14 # Automatically use for '.lua' files
15 syntax "Lua" ".*\.lua$"
16
17 # General
18 color brightwhite ".+"
19
20 # Operators
21 color brightyellow ":|\*\*|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\b(not|and|or)\b"
22
23 # Statements
24 color brightblue "\b(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return)\b"
25
26 # Keywords
27 color brightyellow "\b(debug|string|math|table|io|coroutine|os|utf8|bit32)\b\."
28 color brightyellow "\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*\("
29
30 # Standard library
31 color brightyellow "io\.\b(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)\b"
32 color brightyellow "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"
33 color brightyellow "os\.\b(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\b"
34 color brightyellow "package\.\b(config|cpath|loaded|loadlib|path|preload|seeall|searchers|searchpath)\b"
35 color brightyellow "string\.\b(byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)\b"
36 color brightyellow "table\.\b(concat|insert|maxn|move|pack|remove|sort|unpack)\b"
37 color brightyellow "utf8\.\b(char|charpattern|codes|codepoint|len|offset)\b"
38 color brightyellow "coroutine\.\b(create|isyieldable|resume|running|status|wrap|yield)\b"
39 color brightyellow "debug\.\b(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setfenv|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin)\b"
40 color brightyellow "bit32\.\b(arshift|band|bnot|bor|btest|bxor|extract|replace|lrotate|lshift|rrotate|rshift)\b"
41
42 # File handle methods
43 color brightyellow "\:\b(close|flush|lines|read|seek|setvbuf|write)\b"
44
45 # false, nil, true
46 color brightmagenta "\b(false|nil|true)\b"
47
48 # External files
49 color brightgreen "(\b(dofile|require|include)|%q|%!|%Q|%r|%x)\b"
50
51 # Numbers
52 color red "\b([0-9]+)\b"
53
54 # Symbols
55 color brightmagenta "(\(|\)|\[|\]|\{|\})"
56
57 # Strings
58 color red "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'"
59
60 # Multiline strings
61 color red (s) "\s*\[\[.*?\]\]"
62
63 # Escapes
64 color red "\\[0-7][0-7][0-7]|\\x[0-9a-fA-F][0-9a-fA-F]|\\[abefnrs]|(\\c|\\C-|\\M-|\\M-\\C-)."
65
66 # Shebang
67 color brightcyan "^#!.*"
68
69 # Simple comments
70 color green "\-\-.*$"
71
72 # Multiline comments
73 color green (s) "\s*\-\-\s*\[\[.*?\]\]"
74