2014-05-17 00:21:34 +04:00
## Syntax highlighting for Lua.
2011-05-08 08:23:24 +04:00
#
2014-05-17 00:21:34 +04:00
## Author: Matthew Wild <mwild1 (at) gmail.com>
## License: GPL 3 or later
## Version: 2011-05-05
2011-05-08 08:23:24 +04:00
syntax "lua" "\.lua$"
2017-11-19 13:10:53 +03:00
magic "Lua script"
2016-05-25 23:13:50 +03:00
comment "--"
2011-05-08 08:23:24 +04:00
color brightwhite "\[\[.*\]\]"
# Operators
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\<(not|and|or)\>"
# Statements
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
# Keywords
2017-12-31 08:56:01 +03:00
color brightyellow "\<(_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*\("
2011-05-08 08:23:24 +04:00
# Standard library
2017-12-27 16:26:06 +03:00
color brightyellow "\<io\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write|stdin|stdout|stderr)\>"
color brightyellow "\<math\.(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log)\>"
2017-12-31 08:56:01 +03:00
color brightyellow "\<math\.(max|maxinteger|min|mininteger|mod|modf|pi|pow|rad|random|randomseed|sinh|sin|sqrt|tan)\>"
color brightyellow "\<math\.(tointeger|type|ult)\>"
2017-12-27 16:26:06 +03:00
color brightyellow "\<os\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
2017-12-31 08:56:01 +03:00
color brightyellow "\<package\.(config|cpath|loaded|loadlib|path|preload|searchers|searchpath|seeall)\>"
color brightyellow "\<string\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)\>"
color brightyellow "\<table\.(concat|insert|maxn|move|pack|remove|sort|unpack)\>"
color brightyellow "\<coroutine\.(create|isyieldable|resume|running|status|wrap|yield)\>"
color brightyellow "\<debug\.(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue)\>"
color brightyellow "\<debug\.(setfenv|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin)\>"
color brightyellow "\<utf8\.(char|charpattern|codepoint|codes|len|offset)\>"
2011-05-08 08:23:24 +04:00
# File handle methods
2017-12-30 19:32:15 +03:00
color brightyellow ":(close|flush|lines|read|seek|setvbuf|write)\>"
2011-05-08 08:23:24 +04:00
# false, nil, true
color brightmagenta "\<(false|nil|true)\>"
# External files
color brightgreen "\<(dofile|require)\>"
# Numbers
2017-12-31 06:54:01 +03:00
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
2011-05-08 08:23:24 +04:00
# Symbols
color brightmagenta "(\(|\)|\[|\]|\{|\})"
# Shebang
color brightcyan "^#!.*"
# Simple comments
color green "\-\-.*$"
# Multiline comments
color green start="\-\-\[\[" end="\]\]"
# Strings
2017-12-31 06:51:26 +03:00
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
2014-02-23 20:07:44 +04:00
##color red start="\[\[" end="\]\]"
2011-05-08 08:23:24 +04:00
# Hex literals
2017-12-31 06:54:01 +03:00
icolor red "\<0x[0-9a-f]+(\.[0-9a-f]*)?(p[+-]?[0-9]+)?\>"