syntax: lua: condense some regexes, tweak comments, reorder things

Also remove some redundant backslashes and parentheses.
This commit is contained in:
Benno Schulenberg 2018-01-01 14:55:57 +01:00
parent 058b9da9b9
commit 21cd953e85

View File

@ -1,8 +1,7 @@
## Syntax highlighting for Lua.
#
## Author: Matthew Wild <mwild1 (at) gmail.com>
## Original author: Matthew Wild <mwild1 (at) gmail.com>
## License: GPL 3 or later
## Version: 2011-05-05
syntax "lua" "\.lua$"
magic "Lua script"
@ -20,46 +19,39 @@ color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|functi
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*\("
# Standard library
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)\>"
color brightyellow "\<math\.(max|maxinteger|min|mininteger|mod|modf|pi|pow|rad|random|randomseed|sinh|sin|sqrt|tan)\>"
color brightyellow "\<math\.(tointeger|type|ult)\>"
color brightyellow "\<coroutine\.(create|isyieldable|resume|running|status|wrap|yield)\>"
color brightyellow "\<debug\.(debug|(get|set)(fenv|hook|info|local|metatable|(up|user)value)|getregistry|traceback|upvalue(id|join))\>"
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)\>"
color brightyellow "\<os\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
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)\>"
# File handle methods
color brightyellow ":(close|flush|lines|read|seek|setvbuf|write)\>"
# false, nil, true
color brightmagenta "\<(false|nil|true)\>"
# External files
color brightgreen "\<(dofile|require)\>"
# Numbers
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
# Special words
color brightmagenta "\<(false|nil|true)\>"
# Symbols
color brightmagenta "(\(|\)|\[|\]|\{|\})"
# Decimal and hexadecimal numbers
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
icolor red "\<0x[0-9a-f]+(\.[0-9a-f]*)?(p[+-]?[0-9]+)?\>"
# Brackets
color brightmagenta "\(|\)|\[|\]|\{|\}"
# Shebang
color brightcyan "^#!.*"
color brightcyan "^#!.*"
# Simple comments
color green "\-\-.*$"
# Multiline comments
color green start="\-\-\[\[" end="\]\]"
# Simple comments and multiline comments
color green "--.*"
color green start="--\[\[" end="\]\]"
# Strings
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
##color red start="\[\[" end="\]\]"
# Hex literals
icolor red "\<0x[0-9a-f]+(\.[0-9a-f]*)?(p[+-]?[0-9]+)?\>"