syntax: sql: colorize keywords regardless of case, and tweak the colors

Make types a bluish green, for more contrast with strings, so that the
latter can be made greener, for more contrast with the yellow keywords.
Make the main keywords bluer and less bright, and unbold and soften the
yellow ones.  Soften the comments too.

Reference for case-insensitivity:
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
This commit is contained in:
Benno Schulenberg 2021-12-07 10:08:43 +01:00
parent 350cdd9827
commit d6f101daef
1 changed files with 26 additions and 26 deletions

View File

@ -4,49 +4,49 @@ syntax sql "\.sql$"
comment "-- "
# Types.
color green "\<(integer|int[248]|(big|small)?(int|serial)|decimal|numeric|real|double precision)\>"
color green "\<(bit( varying)?|boolean|bytea|enum|money|tsquery|tsvector|uuid|xml)\>"
color green "\<(char|varchar|character( varying)?|text|cidr|inet|macaddr8?)\>"
color green "\<(date|interval|time(stamp)?( with(out)? time zone)?)\>"
color green "\<(box|circle|line|lseg|path|point|polygon)\>"
color green "\<(date|int[48]|num|ts|tstz)range\>"
icolor #0a4 "\<(integer|int[248]|(big|small)?(int|serial)|decimal|numeric|real|double precision)\>"
icolor #0a4 "\<(bit( varying)?|boolean|bytea|enum|money|tsquery|tsvector|uuid|xml)\>"
icolor #0a4 "\<(char|varchar|character( varying)?|text|cidr|inet|macaddr8?)\>"
icolor #0a4 "\<(date|interval|time(stamp)?( with(out)? time zone)?)\>"
icolor #0a4 "\<(box|circle|line|lseg|path|point|polygon)\>"
icolor #0a4 "\<(date|int[48]|num|ts|tstz)range\>"
# SQL keywords.
color lagoon "\<(ABORT|AGGREGATE|ALL|ALTER|ANALYZE|AND|ANY|AS|BEGIN|BETWEEN|CAST|CHECKPOINT)\>"
color lagoon "\<(CLOSE|CLUSTER|COLLATION|COMMENT|COMMIT|CONSTRAINTS?|CONVERSION|COPY|CREATE)\>"
color lagoon "\<(DATABASE|DEALLOCATE|DECLARE|DEFAULT|DELETE|DISCARD|DISTINCT|DO|DOMAIN|DROP)\>"
color lagoon "\<(END|EXCEPT|EXECUTE|EXISTS|EXPLAIN|EXTENSION|FETCH|FOREIGN (DATA WRAPPER|SCHEMA|TABLE))\>"
color lagoon "\<(FROM|FUNCTION|GRANT|GROUP( BY)?|HAVING|IN|INDEX|INSERT|INTERSECT|INTO|IS)\>"
color lagoon "\<(NATURAL )?(INNER |OUTER |CROSS |(LEFT|RIGHT|FULL)( OUTER)? )?JOIN\>"
color lagoon "\<((PRIMARY|FOREIGN) KEY|LANGUAGE|LOAD|LIKE|LOCK|MOVE|NOT|NOTIFY|NULL)\>"
color lagoon "\<(ON|ONLY|OPERATOR( CLASS| FAMILY)?|OR|ORDER BY|PREPARED?|PRIVILEGES)\>"
color lagoon "\<(RELEASE|RESET|RETURN(S|ING)|REVOKE|ROLE|ROLLBACK|RULE|SAVEPOINT|SCHEMA)\>"
color lagoon "\<(SELECT|SEQUENCE|SERVER|SESSION AUTHORIZATION|SET|SHOW|START|SYSTEM)\>"
color lagoon "\<(TABLE(SPACE)?|TEXT SEARCH (CONFIGURATION|DICTIONARY|PARSER|TEMPLATE))\>"
color lagoon "\<(TO|TRANSACTION|(EVENT )?TRIGGER|TYPE|UNION|UPDATE|USER( MAPPING)?|USING)\>"
color lagoon "\<(VACUUM|VALUES|((REFRESH )?MATERIALIZED )?VIEW|WHERE|WITH)\>"
icolor #48c "\<(ABORT|AGGREGATE|ALL|ALTER|ANALYZE|AND|ANY|AS|BEGIN|BETWEEN|CAST|CHECKPOINT)\>"
icolor #48c "\<(CLOSE|CLUSTER|COLLATION|COMMENT|COMMIT|CONSTRAINTS?|CONVERSION|COPY|CREATE)\>"
icolor #48c "\<(DATABASE|DEALLOCATE|DECLARE|DEFAULT|DELETE|DISCARD|DISTINCT|DO|DOMAIN|DROP)\>"
icolor #48c "\<(END|EXCEPT|EXECUTE|EXISTS|EXPLAIN|EXTENSION|FETCH|FOREIGN (DATA WRAPPER|SCHEMA|TABLE))\>"
icolor #48c "\<(FROM|FUNCTION|GRANT|GROUP( BY)?|HAVING|IN|INDEX|INSERT|INTERSECT|INTO|IS)\>"
icolor #48c "\<(NATURAL )?(INNER |OUTER |CROSS |(LEFT|RIGHT|FULL)( OUTER)? )?JOIN\>"
icolor #48c "\<((PRIMARY|FOREIGN) KEY|LANGUAGE|LOAD|LIKE|LOCK|MOVE|NOT|NOTIFY|NULL)\>"
icolor #48c "\<(ON|ONLY|OPERATOR( CLASS| FAMILY)?|OR|ORDER BY|PREPARED?|PRIVILEGES)\>"
icolor #48c "\<(RELEASE|RESET|RETURN(S|ING)|REVOKE|ROLE|ROLLBACK|RULE|SAVEPOINT|SCHEMA)\>"
icolor #48c "\<(SELECT|SEQUENCE|SERVER|SESSION AUTHORIZATION|SET|SHOW|START|SYSTEM)\>"
icolor #48c "\<(TABLE(SPACE)?|TEXT SEARCH (CONFIGURATION|DICTIONARY|PARSER|TEMPLATE))\>"
icolor #48c "\<(TO|TRANSACTION|(EVENT )?TRIGGER|TYPE|UNION|UPDATE|USER( MAPPING)?|USING)\>"
icolor #48c "\<(VACUUM|VALUES|((REFRESH )?MATERIALIZED )?VIEW|WHERE|WITH)\>"
# Flow control.
color brightyellow "\<(CASE|WHEN|IF|THEN|ELSE|ELSE?IF|LOOP|CONTINUE|EXIT)\>"
color brightyellow "\<(FOR|FOREACH|IN|WHILE|END (CASE|IF|LOOP))\>"
color magenta "\<(RAISE|EXCEPTION|NOTICE|RETURN)\>"
icolor #cc0 "\<(CASE|WHEN|IF|THEN|ELSE|ELSE?IF|LOOP|CONTINUE|EXIT)\>"
icolor #cc0 "\<(FOR|FOREACH|IN|WHILE|END (CASE|IF|LOOP))\>"
icolor #a4a "\<(RAISE|EXCEPTION|NOTICE|RETURN)\>"
# Quoted identifiers. (First scare-color all, then uncolor what is valid.)
color ,red ""[^"]+""
color normal ""[[:alpha:]_][[:alnum:]_$]*""
# Strings.
color lime "'([^']|\\')*'"
color #4c0 "'([^']|\\')*'"
# Trailing whitespace.
color ,green "[[:space:]]+$"
# Comments.
color pink "(--|//).*"
color pink start="/\*" end="\*/"
color italic,#c44 "(--|//).*"
color italic,#c44 start="/\*" end="\*/"
# PostgreSQL default schemas.
color grey "\<(pg_catalog|public)\>"
# PostgreSQL PLs.
color mauve "\<(SQL|pl(java|perlu?|pgsql|py|pythonu?|r|ruby|scheme|sh|tcl))\>"
color #c08 "\<(SQL|pl(java|perlu?|pgsql|py|pythonu?|r|ruby|scheme|sh|tcl))\>"