1" Vim syntax file 2" Language: SQL, PL/SQL (Oracle 11g) 3" Maintainer: Christian Brabandt 4" Repository: https://github.com/chrisbra/vim-sqloracle-syntax 5" License: Vim 6" Previous Maintainer: Paul Moore 7" Last Change: 2016 Jul 22 8 9" Changes: 10" 02.04.2016: Support for when keyword 11" 03.04.2016: Support for join related keywords 12" 22.07.2016: Support Oracle Q-Quote-Syntax 13 14if exists("b:current_syntax") 15 finish 16endif 17 18syn case ignore 19 20" The SQL reserved words, defined as keywords. 21 22syn keyword sqlSpecial false null true 23 24syn keyword sqlKeyword access add as asc begin by case check cluster column 25syn keyword sqlKeyword cache compress connect current cursor decimal default desc 26syn keyword sqlKeyword else elsif end exception exclusive file for from 27syn keyword sqlKeyword function group having identified if immediate increment 28syn keyword sqlKeyword index initial initrans into is level link logging loop 29syn keyword sqlKeyword maxextents maxtrans mode modify monitoring 30syn keyword sqlKeyword nocache nocompress nologging noparallel nowait of offline on online start 31syn keyword sqlKeyword parallel successful synonym table tablespace then to trigger uid 32syn keyword sqlKeyword unique user validate values view when whenever 33syn keyword sqlKeyword where with option order pctfree pctused privileges procedure 34syn keyword sqlKeyword public resource return row rowlabel rownum rows 35syn keyword sqlKeyword session share size smallint type using 36syn keyword sqlKeyword join cross inner outer left right 37 38syn keyword sqlOperator not and or 39syn keyword sqlOperator in any some all between exists 40syn keyword sqlOperator like escape 41syn keyword sqlOperator union intersect minus 42syn keyword sqlOperator prior distinct 43syn keyword sqlOperator sysdate out 44 45syn keyword sqlStatement analyze audit comment commit 46syn keyword sqlStatement delete drop execute explain grant lock noaudit 47syn keyword sqlStatement rename revoke rollback savepoint set 48syn keyword sqlStatement truncate 49" next ones are contained, so folding works. 50syn keyword sqlStatement create update alter select insert contained 51 52syn keyword sqlType boolean char character date float integer long 53syn keyword sqlType mlslabel number raw rowid varchar varchar2 varray 54 55" Strings: 56syn region sqlString matchgroup=Quote start=+"+ skip=+\\\\\|\\"+ end=+"+ 57syn region sqlString matchgroup=Quote start=+'+ skip=+\\\\\|\\'+ end=+'+ 58syn region sqlString matchgroup=Quote start=+n\?q'\z([^[(<{]\)+ end=+\z1'+ 59syn region sqlString matchgroup=Quote start=+n\?q'<+ end=+>'+ 60syn region sqlString matchgroup=Quote start=+n\?q'{+ end=+}'+ 61syn region sqlString matchgroup=Quote start=+n\?q'(+ end=+)'+ 62syn region sqlString matchgroup=Quote start=+n\?q'\[+ end=+]'+ 63 64" Numbers: 65syn match sqlNumber "-\=\<\d*\.\=[0-9_]\>" 66 67" Comments: 68syn region sqlComment start="/\*" end="\*/" contains=sqlTodo,@Spell fold 69syn match sqlComment "--.*$" contains=sqlTodo,@Spell 70 71" Setup Folding: 72" this is a hack, to get certain statements folded. 73" the keywords create/update/alter/select/insert need to 74" have contained option. 75syn region sqlFold start='^\s*\zs\c\(Create\|Update\|Alter\|Select\|Insert\)' end=';$\|^$' transparent fold contains=ALL 76 77syn sync ccomment sqlComment 78 79" Functions: 80" (Oracle 11g) 81" Aggregate Functions 82syn keyword sqlFunction avg collect corr corr_s corr_k count covar_pop covar_samp cume_dist dense_rank first 83syn keyword sqlFunction group_id grouping grouping_id last max median min percentile_cont percentile_disc percent_rank rank 84syn keyword sqlFunction regr_slope regr_intercept regr_count regr_r2 regr_avgx regr_avgy regr_sxx regr_syy regr_sxy 85syn keyword sqlFunction stats_binomial_test stats_crosstab stats_f_test stats_ks_test stats_mode stats_mw_test 86syn keyword sqlFunction stats_one_way_anova stats_t_test_one stats_t_test_paired stats_t_test_indep stats_t_test_indepu 87syn keyword sqlFunction stats_wsr_test stddev stddev_pop stddev_samp sum 88syn keyword sqlFunction sys_xmlagg var_pop var_samp variance xmlagg 89" Char Functions 90syn keyword sqlFunction ascii chr concat initcap instr length lower lpad ltrim 91syn keyword sqlFunction nls_initcap nls_lower nlssort nls_upper regexp_instr regexp_replace 92syn keyword sqlFunction regexp_substr replace rpad rtrim soundex substr translate treat trim upper 93" Comparison Functions 94syn keyword sqlFunction greatest least 95" Conversion Functions 96syn keyword sqlFunction asciistr bin_to_num cast chartorowid compose convert 97syn keyword sqlFunction decompose hextoraw numtodsinterval numtoyminterval rawtohex rawtonhex rowidtochar 98syn keyword sqlFunction rowidtonchar scn_to_timestamp timestamp_to_scn to_binary_double to_binary_float 99syn keyword sqlFunction to_char to_char to_char to_clob to_date to_dsinterval to_lob to_multi_byte 100syn keyword sqlFunction to_nchar to_nchar to_nchar to_nclob to_number to_dsinterval to_single_byte 101syn keyword sqlFunction to_timestamp to_timestamp_tz to_yminterval to_yminterval translate unistr 102" DataMining Functions 103syn keyword sqlFunction cluster_id cluster_probability cluster_set feature_id feature_set 104syn keyword sqlFunction feature_value prediction prediction_bounds prediction_cost 105syn keyword sqlFunction prediction_details prediction_probability prediction_set 106" Datetime Functions 107syn keyword sqlFunction add_months current_date current_timestamp dbtimezone extract 108syn keyword sqlFunction from_tz last_day localtimestamp months_between new_time 109syn keyword sqlFunction next_day numtodsinterval numtoyminterval round sessiontimezone 110syn keyword sqlFunction sys_extract_utc sysdate systimestamp to_char to_timestamp 111syn keyword sqlFunction to_timestamp_tz to_dsinterval to_yminterval trunc tz_offset 112" Numeric Functions 113syn keyword sqlFunction abs acos asin atan atan2 bitand ceil cos cosh exp 114syn keyword sqlFunction floor ln log mod nanvl power remainder round sign 115syn keyword sqlFunction sin sinh sqrt tan tanh trunc width_bucket 116" NLS Functions 117syn keyword sqlFunction ls_charset_decl_len nls_charset_id nls_charset_name 118" Various Functions 119syn keyword sqlFunction bfilename cardin coalesce collect decode dump empty_blob empty_clob 120syn keyword sqlFunction lnnvl nullif nvl nvl2 ora_hash powermultiset powermultiset_by_cardinality 121syn keyword sqlFunction sys_connect_by_path sys_context sys_guid sys_typeid uid user userenv vsizeality 122" XML Functions 123syn keyword sqlFunction appendchildxml deletexml depth extract existsnode extractvalue insertchildxml 124syn keyword sqlFunction insertxmlbefore path sys_dburigen sys_xmlagg sys_xmlgen updatexml xmlagg xmlcast 125syn keyword sqlFunction xmlcdata xmlcolattval xmlcomment xmlconcat xmldiff xmlelement xmlexists xmlforest 126syn keyword sqlFunction xmlparse xmlpatch xmlpi xmlquery xmlroot xmlsequence xmlserialize xmltable xmltransform 127" Todo: 128syn keyword sqlTodo TODO FIXME XXX DEBUG NOTE contained 129 130" Define the default highlighting. 131command -nargs=+ HiLink hi def link <args> 132HiLink Quote Special 133HiLink sqlComment Comment 134HiLink sqlFunction Function 135HiLink sqlKeyword sqlSpecial 136HiLink sqlNumber Number 137HiLink sqlOperator sqlStatement 138HiLink sqlSpecial Special 139HiLink sqlStatement Statement 140HiLink sqlString String 141HiLink sqlType Type 142HiLink sqlTodo Todo 143 144delcommand HiLink 145let b:current_syntax = "sql" 146" vim: ts=8 147