if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'pgsql') == -1 " Vim syntax file " Language: pgsql " Maintainer: Devrim GUNDUZ " Contributors: Jacek Wysocki, Ryan Delaney " Last Change: $Fri May 23 09:55:21 PDT 2014$ " Filenames: *.pgsql *.plpgsql " URL: http://www.gunduz.org/postgresql/pgsql.vim " Note: The definitions below are for PostgreSQL 8.4, some versions may differ. " Changelog: Thanks to Todd A. Cook for the updates " Changelog: Thanks a lot to David Fetter for the big update set, that came as of Mar 11, 2010. " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 syntax clear elseif exists("b:current_syntax") finish endif " Always ignore case syn case ignore " Section: Syntax {{{1 " Section: Miscellaneous {{{2 " General keywords which don't fall into other categories {{{3 " " Use match instead of keyword to lower priority and allow data types bits " and other constructs to match too syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" " fun fact: 'create table fetch ()' fails, but not 'create table move ()' syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlOperator "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(begin\|commit\|rollback\|abort\|start\|end\)\(\_s\+work\|\_s\+transaction\)\?\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(commit\|rollback\)\_s\+prepared\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(binary\_s\+\|insensitive\_s\+\|\(no\_s\+\)\?scroll\_s\+\)*cursor\(\_s\+with\(out\)\_s\+hold\)\?\_s\+for\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(alter\|add\|drop\|comment\_s\+on\|create\)\_s\+\(aggregate\|attribute\|cast\|collation\|conversion\|database\|default\_s\+privileges\|domain\|\(event\_s\+\)\?trigger\|extension\|foreign\_s\+\(data\_s\+wrapper\|table\)\|function\|group\|index\(\_s\+concurrently\)\?\|\(procedural\_s\+\)\?language\|materialized\_s\+view\|operator\(\_s\+class\|\_s\+family\)\?\|owned\_s\+by\|role\|rule\|schema\|sequence\|server\|table\|tablespace\|text\_s\+search\_s\+\(configuration\|dictionary\|parser\|template\)\|type\|user\(\_s\+mapping\)\?\|view\)\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(including\|excluding\)\_s\+\(defaults\|constraints\|indexes\|storage\|comments\|all\)\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(before\|after\|instead\_s\+of\)\_s\+\(insert\|update\|delete\|truncate\)\(\_s\+or\_s\+\(insert\|update\|delete\|truncate\)\)*\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(rename\|owner\)\_s\+to\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(drop\|rename\|validate\)\_s\+constraint\>" syn match pgsqlKeyword "\<\(disable\|enable\(\_s\+\(replica\|always\)\)\?\)\(\_s\+trigger\)\?\>" syn match pgsqlKeyword "\<\(no\_s\+\)\?\(handler\|validator\)\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(set\|drop\)\_s\+\(default\|not\_s\+null\)\>" syn match pgsqlKeyword "\<\(set\_s\+data\_s\+\)type\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(enable\|disable\)\_s\+rule\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(initially\_s\+\)\?\(deferred\|immediate\)\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(no\_s\+\)\?inherit\>" syn match pgsqlKeyword "\<\(not\_s\+\)\?of\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(analyze\|verbose\|costs\|buffers\|timing\)\(\_s\+\(true\|on\|1\|false\|off\|0\)\)\?\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(fetch\|move\)\_s\+\(next\|prior\|first\|last\|absolute\|relative\|\(forward\|backward\)\(\_s\+all\)\?\)\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(default\_s\+\)\?values\>" syn match pgsqlKeyword "\<\(called\|returns\_s\+null\)\_s\+on\_s\+null\_s\+input\>" syn match pgsqlKeyword "\<\(external\_s\+\)\?security\_s\+\(definer\|invoker\)\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(reassign\_s\+\)\?owned\_s\+by\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(\(inner\|cross\|\(left\|right\|full\)\(\_s\+outer\)\?\)\_s\+\)\?join\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(unbounded\_s\+\)\?\(preceding\|following\)\>" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\" syn match pgsqlKeyword "\<\(restart\|continue\)\_s\+identity\>" syn match pgsqlKeyword "\" syn keyword pgsqlKeyword and alias asc syn keyword pgsqlKeyword cascade current_date current_time current_timestamp syn keyword pgsqlKeyword checkpoint check cost syn keyword pgsqlKeyword check column columns constraint syn keyword pgsqlKeyword databases distinct declare deallocate desc syn keyword pgsqlKeyword deferrable diagnostics syn keyword pgsqlKeyword explain elsif exclusion found exception except exit syn keyword pgsqlKeyword force syn keyword pgsqlKeyword group global get syn keyword pgsqlKeyword having syn keyword pgsqlKeyword immutable inherits inline intersect syn keyword pgsqlKeyword leakproof lock local limit load loop listen lateral syn keyword pgsqlKeyword notify next nowait syn keyword pgsqlKeyword out open offset syn keyword pgsqlKeyword password privilege syn keyword pgsqlKeyword perform syn keyword pgsqlKeyword replace references restrict returning syn keyword pgsqlKeyword reassing return syn keyword pgsqlKeyword strict sequences stable setof syn keyword pgsqlKeyword truncate tranaction trigger trusted syn keyword pgsqlKeyword unique unlisten syn keyword pgsqlKeyword version volatile syn keyword pgsqlKeyword window " Section: Constants {{{2 " Constant values syn keyword pgsqlConstant false true " weakened to allow matching 'not null' syn match pgsqlConstant "\" " }}} " Section: Strings {{{2 " Strings (single- and double-quote) syn region pgsqlIdentifier start=+"+ skip=+\\\\\|\\"+ end=+"+ syn region pgsqlIdentifier start=+U&"+ skip=+\\\\\|\\"+ end=+"+ syn region pgsqlString start=+'+ skip=+\\\\\|\\'+ end=+'+ syn region pgsqlString start=+U&'+ skip=+\\\\\|\\'+ end=+'+ syn match pgsqlString "\$\w*\$" " }}} " Section: Numbers {{{2 " Numbers and hexidecimal values syn match pgsqlNumber "-\=\<[0-9]*\>" syn match pgsqlNumber "-\=\<[0-9]*\.[0-9]*\>" syn match pgsqlNumber "-\=\<[0-9]*e[+-]\=[0-9]*\>" syn match pgsqlNumber "-\=\<[0-9]*\.[0-9]*e[+-]\=[0-9]*\>" syn match pgsqlNumber "\<0x[abcdefABCDEF0-9]*\>" " }}} " Section: Comments {{{2 " Comments (c-style, sql-style) syn region pgsqlComment start="/\*" end="\*/" contains=pgsqlTodo,pgsqlComment syn match pgsqlComment "--.*" contains=pgsqlTodo syn sync ccomment pgsqlComment syn keyword pgsqlTodo todo note xxx warn warning contained " }}} " Section: Variables {{{2 " " Special variables syn keyword pgsqlVariable old new " Variables available in trigger definitions syn keyword pgsqlVariable tg_name tg_when tg_level tg_op tg_relid tg_relname syn keyword pgsqlVariable tg_table_name tg_table_schema tg_nargs tg_argv " SQL-style variables syn match pgsqlVariable "\$[0-9]\+" syn match pgsqlLabel "<<[^>]\+>>" " Is this a class of things or just a sort of an alien? syn match pgsqlExtschema "@extschema@" " Section: Column types {{{3 syn keyword pgsqlType anyarray anyelement abstime anyenum syn keyword pgsqlType anynonarray aclitem " Would like to have this as type, but even if it's a match it fails " matching of the any() operator, which is more used. " syn match pgsqlType "\" syn keyword pgsqlType bytea bigserial bool boolean bigint box syn keyword pgsqlType cidr cstring cid circle syn keyword pgsqlType date syn keyword pgsqlType enum syn keyword pgsqlType gtsvector syn keyword pgsqlType hstore syn keyword pgsqlType inet syn keyword pgsqlType internal int2vector int int2 int4 int8 integer syn keyword pgsqlType json jsonb syn keyword pgsqlType line lseg language_handler syn keyword pgsqlType macaddr money syn keyword pgsqlType numeric syn keyword pgsqlType opaque oidvector oid syn keyword pgsqlType polygon point path period syn keyword pgsqlType regclass real regtype refcursor regoperator syn keyword pgsqlType reltime record regproc regdictionary regoper syn keyword pgsqlType regprocedure regconfig syn keyword pgsqlType smgr smallint serial smallserial syn keyword pgsqlType serial2 serial4 serial8 syn keyword pgsqlType tsquery tinterval syn keyword pgsqlType trigger tid text syn keyword pgsqlType tsvector txid_snapshot syn keyword pgsqlType unknown uuid syn keyword pgsqlType void varchar syn keyword pgsqlType xml xid " %rowtype, %type PL/pgSQL constructs syn match pgsqlType "%\(row\)\?type\>" " this should actually be the end of a region syn match pgsqlType "\" " Section: Variable types {{{3 syn match pgsqlType "\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn match pgsqlType "\" syn match pgsqlType "\" syn match pgsqlType "\" syn match pgsqlType "\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn region pgsqlType start="\" syn match pgsqlOperator "\" syn region pgsqlOperator start="isnull\_s*(" end=")" contains=ALL syn region pgsqlOperator start="coalesce\_s*(" end=")" contains=ALL syn region pgsqlOperator start="interval\_s*(" end=")" contains=ALL syn region pgsqlOperator start="in\_s*(" end=")" contains=ALL syn region pgsqlOperator start="any\_s*(" end=")" contains=ALL syn region pgsqlOperator start="some\_s*(" end=")" contains=ALL syn region pgsqlOperator start="all\_s*(" end=")" contains=ALL syn region pgsqlOperator start="exists\_s*(" end=")" contains=ALL syn region pgsqlOperator start="array\_s*\[" end="\]" contains=ALL " Let's consider this an operator, not operator + constant syn match pgsqlKeyword "\" " }}} " Section: psql special stuff {{{1 syn region pgsqlCopy start="\= 508 || !exists("did_pgsql_syn_inits") if version < 508 let did_pgsql_syn_inits = 1 command -nargs=+ HiLink hi link else command -nargs=+ HiLink hi def link endif HiLink pgsqlKeyword Statement HiLink pgsqlConstant Constant HiLink pgsqlString String HiLink pgsqlNumber Number HiLink pgsqlVariable Identifier HiLink pgsqlComment Comment HiLink pgsqlType Type HiLink pgsqlOperator Statement HiLink pgsqlFlow Statement HiLink pgsqlFunction Function HiLink pgsqlLabel Label HiLink pgsqlExtschema Special HiLink pgsqlTodo Todo HiLink pgsqlIdentifier Normal HiLink pgsqlCopy Normal HiLink pgsqlBackslash Special delcommand HiLink endif " }}} let b:current_syntax = "pgsql" " Section: Modelines {{{1 " vim600: set foldmethod=marker foldlevel=0 : endif