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