sqloracle.vim 7.5 KB

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