2014-05-16 20:21:34 +00:00
## Syntax highlighting for Lua.
2020-04-20 17:15:43 +00:00
## Original author: Matthew Wild
## License: GPL version 3 or newer
2011-05-08 04:23:24 +00:00
2018-02-07 10:25:46 +00:00
syntax lua "\.lua$"
2017-11-19 10:10:53 +00:00
magic "Lua script"
2016-05-25 20:13:50 +00:00
comment "--"
2011-05-08 04:23:24 +00:00
2019-11-04 18:52:35 +00:00
linter luacheck --no-color
2011-05-08 04:23:24 +00:00
color brightwhite "\[\[.*\]\]"
# Operators
2018-08-05 11:38:52 +00:00
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|#|\<(not|and|or)\>"
# Don't partially color ... as an operator
color normal "\.\.\."
2011-05-08 04:23:24 +00:00
# Statements
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
# Keywords
2021-04-27 09:18:41 +00: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)[[:blank:]]*\("
2011-05-08 04:23:24 +00:00
# Standard library
2018-01-01 13:55:57 +00:00
color brightyellow "\<coroutine\.(create|isyieldable|resume|running|status|wrap|yield)\>"
2018-01-06 16:58:06 +00:00
color brightyellow "\<debug\.(debug|(get|set)(fenv|hook|local|metatable|(up|user)value)|getinfo|getregistry|traceback|upvalue(id|join))\>"
2018-01-01 13:55:57 +00: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 13:26:06 +00:00
color brightyellow "\<os\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
2017-12-31 05:56:01 +00: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 04:23:24 +00:00
# File handle methods
2017-12-30 16:32:15 +00:00
color brightyellow ":(close|flush|lines|read|seek|setvbuf|write)\>"
2011-05-08 04:23:24 +00:00
# External files
color brightgreen "\<(dofile|require)\>"
2018-01-01 13:55:57 +00:00
# Special words
color brightmagenta "\<(false|nil|true)\>"
# Decimal and hexadecimal numbers
2017-12-31 03:54:01 +00:00
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
2019-08-17 15:01:19 +00:00
color red "\<0x[0-9A-Fa-f]+(\.[0-9A-Fa-f]*)?([Pp][+-]?[0-9]+)?\>"
2011-05-08 04:23:24 +00:00
2018-01-01 13:55:57 +00:00
# Brackets
color brightmagenta "\(|\)|\[|\]|\{|\}"
2011-05-08 04:23:24 +00:00
# Shebang
2018-01-01 13:55:57 +00:00
color brightcyan "^#!.*"
2011-05-08 04:23:24 +00:00
2018-08-05 11:38:52 +00:00
# Strings
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
2018-01-01 13:55:57 +00:00
# Simple comments and multiline comments
color green "--.*"
color green start="--\[\[" end="\]\]"