· 7 years ago · Oct 12, 2018, 02:50 AM
1" Vim syntax file
2" Language: SQL, PGSQL (postgres 9.1)
3" Last Change: 2012 May 21st
4" Maintainer: Grégoire Hubert <greg DOT hubert AT gmail DOT com>
5" Based on the work of Paul Moore <pf_moore AT yahoo.co.uk>
6
7" For version 5.x: Clear all syntax items
8" For version 6.x: Quit when a syntax file was already loaded
9if version < 600
10 syntax clear
11elseif exists("b:current_syntax")
12 finish
13endif
14
15syn case ignore
16
17" postgresql reserved words, defined as keywords.
18
19syn keyword sqlSpecial false null true
20
21syn keyword sqlKeyword all analyse analyze any array as asc asymmetric
22syn keyword sqlKeyword authorization binary both by case cast check collate
23syn keyword sqlKeyword column concurrently constraint create cross
24syn keyword sqlKeyword current_catalog current_date current_role
25syn keyword sqlKeyword current_schema current_time current_timestamp current_user default
26syn keyword sqlKeyword deferrable desc do each else end enum except execute fetch for
27syn keyword sqlKeyword foreign from function grant group having initially
28syn keyword sqlKeyword inner into is isnull join language leading left
29syn keyword sqlKeyword limit localtime localtimestamp natural notnull offset
30syn keyword sqlKeyword on only order outer over overlaps placing partition
31syn keyword sqlKeyword primary recursive references returning right set
32syn keyword sqlKeyword session_user similar some symmetric table then to
33syn keyword sqlKeyword using variadic values verbose view when where window
34syn keyword sqlKeyword with trailing trigger unique user
35
36syn keyword sqlOperator not and or escape
37syn keyword sqlOperator in any some every all between exists
38syn keyword sqlOperator like ilike document
39syn keyword sqlOperator union intersect
40syn keyword sqlOperator distinct
41
42syn keyword sqlStatement alter analyze comment commit create
43syn keyword sqlStatement delete drop execute explain grant insert lock noaudit
44syn keyword sqlStatement rename revoke rollback savepoint select replace
45syn keyword sqlStatement truncate update
46
47syn keyword sqlType boolean char character date float float4 float8 integer long
48syn keyword sqlType int4 int8 numeric serial money varying text bytea time
49syn keyword sqlType timestamp timestamptz interval point line circle lseg
50syn keyword sqlType box path polygon cidr inet macaddr bit bitvar tsvector uuid
51syn keyword sqlType xml json anyarray anyelement anyenum anynonarray cstring
52
53syn keyword sqlFunc abs avg cbrt ceil ceiling degrees div exp floor ln log mod
54syn keyword sqlFunc pi power radians random round setseed sign sqrt trunc
55syn keyword sqlFunc width_bucket cos cot sin tan acos asin atan atan2
56syn keyword sqlFunc bit_length char_length lower octet_length overlay position
57syn keyword sqlFunc substring substring substring trim upper ascii btrim
58syn keyword sqlFunc chr concat convert convert_from convert_to decode encode
59syn keyword sqlFunc format initcap left length lpad ltrim md5 pg_client_encoding
60syn keyword sqlFunc quote_ident quote_literal quote_nullable regexp_matches
61syn keyword sqlFunc regexp_replace regexp_split_to_array regexp_split_to_table
62syn keyword sqlFunc repeat reverse rpad rtrim split_part strpos substr to_ascii
63syn keyword sqlFunc to_hex translate get_bit get_byte set_bit set_byte to_char
64syn keyword sqlFunc to_timestamp to_date to_number age clock_timestamp
65syn keyword sqlFunc current_date current_time current_timestamp date_part
66syn keyword sqlFunc date_trunc extract isfinite justify_days justify_hours
67syn keyword sqlFunc justify_interval localtime localtimestamp now
68syn keyword sqlFunc statement_timestamp timeofday transaction_timestamp
69syn keyword sqlFunc enum_first enum_last enum_range enum_range area center
70syn keyword sqlFunc diameter height isclosed isopen npoints pclose popen
71syn keyword sqlFunc radius width abbrev abbrev broadcast family host
72syn keyword sqlFunc hostmask masklen netmask network set_masklen numnode
73syn keyword sqlFunc get_current_ts_config plainto_tsquery querytree setweight
74syn keyword sqlFunc strip to_tsquery to_tsvector ts_headline ts_rank ts_rank_cd
75syn keyword sqlFunc ts_rewrite ts_rewrite tsvector_update_trigger
76syn keyword sqlFunc tsvector_update_trigger_column ts_debug ts_lexize ts_parse
77syn keyword sqlFunc ts_parse ts_token_type ts_stat xmlcomment xmlconcat
78syn keyword sqlFunc xmlelement xmlforest xmlpi xmlroot xmlagg xmlexists
79syn keyword sqlFunc xml_is_well_formed xpath table_to_xml query_to_xml
80syn keyword sqlFunc cursor_to_xml currval lastval nextval setval array_append
81syn keyword sqlFunc array_cat array_ndims array_dims array_fill array_length
82syn keyword sqlFunc array_lower array_prepend array_to_string array_upper
83syn keyword sqlFunc string_to_array unnest array_agg bit_and bit_or bool_and
84syn keyword sqlFunc bool_or count max min string_agg sum corr covar_pop
85syn keyword sqlFunc covar_samp regr_avgx regr_avgy regr_count regr_intercept
86syn keyword sqlFunc regr_r2 regr_slope regr_sxx regr_sxy regr_syy stddev
87syn keyword sqlFunc stddev_pop stddev_samp variance var_pop var_samp row_number
88syn keyword sqlFunc rank dense_rank percent_rank cume_dist ntile lag lead
89syn keyword sqlFunc first_value last_value nth_value generate_series
90syn keyword sqlFunc current_catalog current_database current_query
91syn keyword sqlFunc current_schema current_user inet_client_addr
92syn keyword sqlFunc inet_client_port inet_server_addr inet_server_port
93syn keyword sqlFunc pg_backend_pid pg_conf_load_time pg_is_other_temp_schema
94syn keyword sqlFunc pg_listening_channels pg_my_temp_schema
95syn keyword sqlFunc pg_postmaster_start_time session_user version
96syn keyword sqlFunc current_setting
97
98
99" Strings and characters:
100syn region sqlString start=+"+ skip=+\\\\\|\\"+ end=+"+
101syn region sqlString start=+'+ skip=+\\\\\|\\'+ end=+'+
102
103" Numbers:
104syn match sqlNumber "-\=\<\d*\.\=[0-9_]\>"
105
106" Comments:
107syn region sqlComment start="/\*" end="\*/" contains=sqlTodo
108syn match sqlComment "--.*$" contains=sqlTodo
109
110syn sync ccomment sqlComment
111
112" Todo.
113syn keyword sqlTodo contained TODO FIXME XXX DEBUG NOTE
114
115" Define the default highlighting.
116" For version 5.7 and earlier: only when not done already
117" For version 5.8 and later: only when an item doesn't have highlighting yet
118if version >= 508 || !exists("did_sql_syn_inits")
119 if version < 508
120 let did_sql_syn_inits = 1
121 command -nargs=+ HiLink hi link <args>
122 else
123 command -nargs=+ HiLink hi def link <args>
124 endif
125
126 HiLink sqlComment Comment
127 HiLink sqlKeyword sqlSpecial
128 HiLink sqlNumber Number
129 HiLink sqlOperator sqlStatement
130 HiLink sqlSpecial Special
131 HiLink sqlStatement Statement
132 HiLink sqlString String
133 HiLink sqlType Type
134 HiLink sqlTodo Todo
135 HiLink sqlFunc Function
136
137 delcommand HiLink
138endif
139
140let b:current_syntax = "sql"
141
142" vim: ts=8