Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 1 | ## Syntax highlighting for Lua. |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 2 | # |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 3 | ## Author: Matthew Wild <mwild1 (at) gmail.com> |
| 4 | ## License: GPL 3 or later |
| 5 | ## Version: 2011-05-05 |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 6 | |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 7 | syntax "lua" "\.lua$" |
Mike Scalora | 6a2032f | 2016-05-25 22:13:50 +0200 | [diff] [blame] | 8 | comment "--" |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 9 | |
| 10 | color brightwhite "\[\[.*\]\]" |
| 11 | |
| 12 | # Operators |
| 13 | color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\<(not|and|or)\>" |
| 14 | |
| 15 | # Statements |
| 16 | color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>" |
| 17 | |
| 18 | # Keywords |
Benno Schulenberg | ed2f0b3 | 2015-02-21 10:34:15 +0000 | [diff] [blame] | 19 | color brightyellow "\<(io|math|os|string|table|coroutine|debug)\>\." |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 20 | color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\s*\(" |
| 21 | |
| 22 | # Standard library |
| 23 | color brightyellow "io\.\<(close|flush|input|lines|open|output|popen|read|tmpfile|type|write|stdin|stdout|stderr)\>" |
Benno Schulenberg | ed2f0b3 | 2015-02-21 10:34:15 +0000 | [diff] [blame] | 24 | color brightyellow "math\.\<(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log)\>" |
| 25 | color brightyellow "math\.\<(max|min|mod|modf|pi|pow|rad|random|randomseed|sinh|tan)\>" |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 26 | color brightyellow "os\.\<(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>" |
| 27 | color brightyellow "package\.\<(cpath|loaded|loadlib|path|preload|seeall)\>" |
| 28 | color brightyellow "string\.\<(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)\>" |
| 29 | color brightyellow "table\.\<(concat|insert|maxn|remove|sort)\>" |
| 30 | color brightyellow "coroutine\.\<(create|resume|running|status|wrap|yield)\>" |
Benno Schulenberg | ed2f0b3 | 2015-02-21 10:34:15 +0000 | [diff] [blame] | 31 | color brightyellow "debug\.\<(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue)\>" |
| 32 | color brightyellow "debug\.\<(setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>" |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 33 | |
| 34 | # File handle methods |
| 35 | color brightyellow "\:\<(close|flush|lines|read|seek|setvbuf|write)\>" |
| 36 | |
| 37 | # false, nil, true |
| 38 | color brightmagenta "\<(false|nil|true)\>" |
| 39 | |
| 40 | # External files |
| 41 | color brightgreen "\<(dofile|require)\>" |
| 42 | |
| 43 | # Numbers |
| 44 | color red "\<([0-9]+)\>" |
| 45 | |
| 46 | # Symbols |
| 47 | color brightmagenta "(\(|\)|\[|\]|\{|\})" |
| 48 | |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 49 | # Shebang |
| 50 | color brightcyan "^#!.*" |
| 51 | |
| 52 | # Simple comments |
| 53 | color green "\-\-.*$" |
| 54 | |
| 55 | # Multiline comments |
| 56 | color green start="\-\-\[\[" end="\]\]" |
| 57 | |
| 58 | # Strings |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 59 | color red "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'" |
Benno Schulenberg | c4b344f | 2014-02-23 16:07:44 +0000 | [diff] [blame] | 60 | ##color red start="\[\[" end="\]\]" |
Chris Allegretta | 090e2cf | 2011-05-08 04:23:24 +0000 | [diff] [blame] | 61 | |
| 62 | # Hex literals |
| 63 | color red "0x[0-9a-fA-F]*" |