Posted 03 July 2015 - 11:09 PM
So I've been doing a bit of work with GNU nano (commonly just 'nano') and I've actually gotten to writing some syntax highlighting scripts. I'm interested in seeing what everyone else has been able to do with this.
## General
color white ".+"
## Statements
color magenta "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return)\>"
## Operators
color brightyellow "&|\||:|\*\*|\*|/|%|\+|-|\^|>>|>|>=|<|<=|<<|~|~=|=|\.\.|,|\<(not|and|or)\>"
## Keywords
color brightyellow "\<(debug|string|math|table|io|coroutine|os)\>\.[A-Za-z_][0-9A-Za-z_]*"
color yellow "(_G|_VERSION)"
color brightcyan "[^\.A-Za-z0-9](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) *[\(\"{]"
## Standard library
color brightyellow "io *\. *\<(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)\>"
color brightyellow "math *\. *\<(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log|max|min|modf|pi|pow|rad|random|randomseed|sinh|tan)\>"
color brightyellow "os *\. *\<(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
color brightyellow "package *\. *\<(cpath|loaded|loadlib|path|preload|seeall)\>"
color brightyellow "string *\. *\<(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)\>"
color brightyellow "table *\. *\<(concat|insert|maxn|remove|sort)\>"
color brightyellow "coroutine *\. *\<(create|resume|running|status|wrap|yield)\>"
color brightyellow "debug *\. *\<(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>"
## false, nil, true
color magenta "\<(false|nil|true)\>"
## vararg
color brightmagenta "\.\.\."
## External files
color brightgreen "(\<(dofile|require|include)|%q|%!|%Q|%r|%x)\>"
## Table indexing
color yellow "[A-Za-z_][A-Za-z_0-9]* *[:\.] *[A-Za-z_][A-Za-z_0-9]*"
## Table index calls
color brightgreen "[\.:] *[A-Za-z_][A-Za-z_0-9]* *[\(\"{]"
## File handle methods
color brightred "\: *\<(close|flush|lines|read|seek|setvbuf|write)\>"
## Numbers
color cyan "\<([0-9]+)\>"
## Symbols
color cyan "\(|\)|\[|\]|\{|\}"
## Strings
color brightgreen "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'"
## Escapes
color brightred "\\[0-7][0-7][0-7]|\\x[0-9a-fA-F][0-9a-fA-F]|\\[abefnrs]|(\\c|\\C-|\\M-|\\M-\\C-)."
## Shebang
color cyan "^#!.*"
## Simple comments
color green "(\-\-[^\[].*$|\-\-\[([^\[].*)?$|–$)"
## Multiline comments
color green start="\-\-\[\[" end="]]?"
syntax "html" "\.html$"
color cyan start="<" end=">"
color green start="<!–" end="–>"
color yellow start="<!DOCTYPE" end=">"
## Fix this later?
color red "&[^;[[:space:]]]*;"
Lua
syntax "lua" ".*\.lua$"## General
color white ".+"
## Statements
color magenta "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return)\>"
## Operators
color brightyellow "&|\||:|\*\*|\*|/|%|\+|-|\^|>>|>|>=|<|<=|<<|~|~=|=|\.\.|,|\<(not|and|or)\>"
## Keywords
color brightyellow "\<(debug|string|math|table|io|coroutine|os)\>\.[A-Za-z_][0-9A-Za-z_]*"
color yellow "(_G|_VERSION)"
color brightcyan "[^\.A-Za-z0-9](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) *[\(\"{]"
## Standard library
color brightyellow "io *\. *\<(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)\>"
color brightyellow "math *\. *\<(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log|max|min|modf|pi|pow|rad|random|randomseed|sinh|tan)\>"
color brightyellow "os *\. *\<(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
color brightyellow "package *\. *\<(cpath|loaded|loadlib|path|preload|seeall)\>"
color brightyellow "string *\. *\<(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)\>"
color brightyellow "table *\. *\<(concat|insert|maxn|remove|sort)\>"
color brightyellow "coroutine *\. *\<(create|resume|running|status|wrap|yield)\>"
color brightyellow "debug *\. *\<(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>"
## false, nil, true
color magenta "\<(false|nil|true)\>"
## vararg
color brightmagenta "\.\.\."
## External files
color brightgreen "(\<(dofile|require|include)|%q|%!|%Q|%r|%x)\>"
## Table indexing
color yellow "[A-Za-z_][A-Za-z_0-9]* *[:\.] *[A-Za-z_][A-Za-z_0-9]*"
## Table index calls
color brightgreen "[\.:] *[A-Za-z_][A-Za-z_0-9]* *[\(\"{]"
## File handle methods
color brightred "\: *\<(close|flush|lines|read|seek|setvbuf|write)\>"
## Numbers
color cyan "\<([0-9]+)\>"
## Symbols
color cyan "\(|\)|\[|\]|\{|\}"
## Strings
color brightgreen "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'"
## Escapes
color brightred "\\[0-7][0-7][0-7]|\\x[0-9a-fA-F][0-9a-fA-F]|\\[abefnrs]|(\\c|\\C-|\\M-|\\M-\\C-)."
## Shebang
color cyan "^#!.*"
## Simple comments
color green "(\-\-[^\[].*$|\-\-\[([^\[].*)?$|–$)"
## Multiline comments
color green start="\-\-\[\[" end="]]?"
HTML
## Highlight tags, comments, and DOCTYPEsyntax "html" "\.html$"
color cyan start="<" end=">"
color green start="<!–" end="–>"
color yellow start="<!DOCTYPE" end=">"
## Fix this later?
color red "&[^;[[:space:]]]*;"