2014-05-17 00:21:34 +04:00
## Syntax highlighting for Lua.
2020-04-20 20:15:43 +03:00
## Original author: Matthew Wild
## License: GPL version 3 or newer
2011-05-08 08:23:24 +04:00
2018-02-07 13:25:46 +03: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
2019-11-04 21:52:35 +03:00
linter luacheck --no-color
2011-05-08 08:23:24 +04:00
color brightwhite "\[\[.*\]\]"
# Operators
2018-08-05 14:38:52 +03:00
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|#|\<(not|and|or)\>"
# Don't partially color ... as an operator
color normal "\.\.\."
2011-05-08 08:23:24 +04:00
# 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
2018-01-01 16:55:57 +03:00
color brightyellow "\<coroutine\.(create|isyieldable|resume|running|status|wrap|yield)\>"
2018-01-06 19:58:06 +03:00
color brightyellow "\<debug\.(debug|(get|set)(fenv|hook|local|metatable|(up|user)value)|getinfo|getregistry|traceback|upvalue(id|join))\>"
2018-01-01 16:55:57 +03:00
color brightyellow "\<io\.(close|flush|input|lines|output|p?open|read|tmpfile|type|write|std(in|out|err))\>"
color brightyellow "\<math\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log)\>"
color brightyellow "\<math\.((max|min)(integer)?|modf?|pi|pow|rad|random(seed)?|sinh?|sqrt|tan|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 "\<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
# External files
color brightgreen "\<(dofile|require)\>"
2018-01-01 16:55:57 +03:00
# Special words
color brightmagenta "\<(false|nil|true)\>"
# Decimal and hexadecimal numbers
2017-12-31 06:54:01 +03:00
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
2019-08-17 18:01:19 +03:00
color red "\<0x[0-9A-Fa-f]+(\.[0-9A-Fa-f]*)?([Pp][+-]?[0-9]+)?\>"
2011-05-08 08:23:24 +04:00
2018-01-01 16:55:57 +03:00
# Brackets
color brightmagenta "\(|\)|\[|\]|\{|\}"
2011-05-08 08:23:24 +04:00
# Shebang
2018-01-01 16:55:57 +03:00
color brightcyan "^#!.*"
2011-05-08 08:23:24 +04:00
2018-08-05 14:38:52 +03:00
# Strings
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
2018-01-01 16:55:57 +03:00
# Simple comments and multiline comments
color green "--.*"
color green start="--\[\[" end="\]\]"