| 1 | ############################################################################## |
| 2 | # |
| 3 | # Lua syntax highlighting for Nano. |
| 4 | # |
| 5 | # Author: Matthew Wild <mwild1 (at) gmail.com> |
| 6 | # License: GPL 3 or later |
| 7 | # |
| 8 | # Version: 2011-05-05 |
| 9 | # |
| 10 | # Notes: Originally based on Ruby syntax rc by Josef 'Jupp' Schugt |
| 11 | ############################################################################## |
| 12 | |
| 13 | |
| 14 | # Automatically use for '.lua' files |
| 15 | syntax "lua" "\.lua$" |
| 16 | |
| 17 | # General |
| 18 | color brightwhite ".+" |
| 19 | |
| 20 | color brightwhite "\[\[.*\]\]" |
| 21 | |
| 22 | # Operators |
| 23 | color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\<(not|and|or)\>" |
| 24 | |
| 25 | # Statements |
| 26 | color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>" |
| 27 | |
| 28 | # Keywords |
| 29 | color brightyellow "\<(debug|string|math|table|io|coroutine|os)\>\." |
| 30 | 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*\(" |
| 31 | |
| 32 | # Standard library |
| 33 | color brightyellow "io\.\<(close|flush|input|lines|open|output|popen|read|tmpfile|type|write|stdin|stdout|stderr)\>" |
| 34 | color brightyellow "math\.\<(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log|max|min|mod|modf|pi|pow|rad|random|randomseed|sinh|tan)\>" |
| 35 | color brightyellow "os\.\<(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>" |
| 36 | color brightyellow "package\.\<(cpath|loaded|loadlib|path|preload|seeall)\>" |
| 37 | color brightyellow "string\.\<(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)\>" |
| 38 | color brightyellow "table\.\<(concat|insert|maxn|remove|sort)\>" |
| 39 | color brightyellow "coroutine\.\<(create|resume|running|status|wrap|yield)\>" |
| 40 | color brightyellow "debug\.\<(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>" |
| 41 | |
| 42 | # File handle methods |
| 43 | color brightyellow "\:\<(close|flush|lines|read|seek|setvbuf|write)\>" |
| 44 | |
| 45 | # false, nil, true |
| 46 | color brightmagenta "\<(false|nil|true)\>" |
| 47 | |
| 48 | # External files |
| 49 | color brightgreen "\<(dofile|require)\>" |
| 50 | |
| 51 | # Numbers |
| 52 | color red "\<([0-9]+)\>" |
| 53 | |
| 54 | # Symbols |
| 55 | color brightmagenta "(\(|\)|\[|\]|\{|\})" |
| 56 | |
| 57 | |
| 58 | # Shebang |
| 59 | color brightcyan "^#!.*" |
| 60 | |
| 61 | # Simple comments |
| 62 | color green "\-\-.*$" |
| 63 | |
| 64 | # Multiline comments |
| 65 | color green start="\-\-\[\[" end="\]\]" |
| 66 | |
| 67 | # Strings |
| 68 | #color green "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'" |
| 69 | |
| 70 | # Strings |
| 71 | color red "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'" |
| 72 | |
| 73 | # color red start="\[\[" end="\]\]" |
| 74 | |
| 75 | |
| 76 | # Hex literals |
| 77 | color red "0x[0-9a-fA-F]*" |