2020-04-26 18:21:32 +03:00
|
|
|
## Syntax highlighting for (Postgres) SQL scripts.
|
2015-05-20 21:57:18 +03:00
|
|
|
|
2024-06-08 12:28:06 +03:00
|
|
|
## Original author: Devrim Gündüz
|
|
|
|
|
2021-10-25 18:40:24 +03:00
|
|
|
syntax sql "\.sql$"
|
2016-05-25 23:13:50 +03:00
|
|
|
comment "-- "
|
2015-05-20 21:57:18 +03:00
|
|
|
|
|
|
|
# Types.
|
2021-12-07 12:08:43 +03:00
|
|
|
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\>"
|
2015-05-20 21:57:18 +03:00
|
|
|
|
|
|
|
# SQL keywords.
|
2021-12-07 12:08:43 +03:00
|
|
|
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)\>"
|
2021-12-07 14:23:29 +03:00
|
|
|
icolor #48c "\<(END|EXCEPT|EXECUTE|EXISTS|EXPLAIN|EXTENSION|FALSE|FETCH|FOREIGN (DATA WRAPPER|SCHEMA|TABLE))\>"
|
2021-12-07 12:08:43 +03:00
|
|
|
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)\>"
|
2021-12-07 14:23:29 +03:00
|
|
|
icolor #48c "\<(ON|ONLY|OPERATOR( CLASS| FAMILY)?|OR|ORDER BY|PREPARED?|PRIVILEGES|PROCEDURE)\>"
|
|
|
|
icolor #48c "\<(REFERENCES|RELEASE|REPLACE|RESET|RETURN(S|ING)|REVOKE|ROLE|ROLLBACK|RULE|SAVEPOINT|SCHEMA)\>"
|
|
|
|
icolor #48c "\<(SELECT|SEQUENCE|SERVER|SESSION AUTHORIZATION|SET|SHOW|SIMILAR|START|SYSTEM)\>"
|
2021-12-07 12:08:43 +03:00
|
|
|
icolor #48c "\<(TABLE(SPACE)?|TEXT SEARCH (CONFIGURATION|DICTIONARY|PARSER|TEMPLATE))\>"
|
2021-12-07 14:23:29 +03:00
|
|
|
icolor #48c "\<(TO|TRANSACTION|(EVENT )?TRIGGER|TRUE|TRUNCATE|TYPE|UNION|UNIQUE|UPDATE|USER( MAPPING)?|USING)\>"
|
2021-12-07 12:08:43 +03:00
|
|
|
icolor #48c "\<(VACUUM|VALUES|((REFRESH )?MATERIALIZED )?VIEW|WHERE|WITH)\>"
|
2015-05-20 21:57:18 +03:00
|
|
|
|
2021-10-26 16:48:51 +03:00
|
|
|
# Flow control.
|
2021-12-07 12:08:43 +03:00
|
|
|
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)\>"
|
2021-10-26 16:48:51 +03:00
|
|
|
|
2021-12-07 14:23:29 +03:00
|
|
|
# Quoted identifiers.
|
2021-12-02 13:18:57 +03:00
|
|
|
color normal ""[[:alpha:]_][[:alnum:]_$]*""
|
|
|
|
|
|
|
|
# Strings.
|
2021-12-07 12:08:43 +03:00
|
|
|
color #4c0 "'([^']|\\')*'"
|
2021-12-02 13:18:57 +03:00
|
|
|
|
2015-05-20 21:57:18 +03:00
|
|
|
# Trailing whitespace.
|
|
|
|
color ,green "[[:space:]]+$"
|
|
|
|
|
|
|
|
# Comments.
|
2021-12-07 12:08:43 +03:00
|
|
|
color italic,#c44 "(--|//).*"
|
|
|
|
color italic,#c44 start="/\*" end="\*/"
|
2015-05-20 21:57:18 +03:00
|
|
|
|
|
|
|
# PostgreSQL default schemas.
|
2021-12-04 14:05:58 +03:00
|
|
|
color grey "\<(pg_catalog|public)\>"
|
2015-05-20 21:57:18 +03:00
|
|
|
|
|
|
|
# PostgreSQL PLs.
|
2021-12-07 12:08:43 +03:00
|
|
|
color #c08 "\<(SQL|pl(java|perlu?|pgsql|py|pythonu?|r|ruby|scheme|sh|tcl))\>"
|