summaryrefslogtreecommitdiffstats
path: root/runtime/syntax/sqlhana.vim
blob: 2e334bb56e5cd24a8cc008f816c077e45a107344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
" Vim syntax file
" Language:    SQL, SAP HANA In Memory Database
" Maintainer:  David Fishburn <dfishburn dot vim at gmail dot com>
" Last Change: 2012 Oct 23
" Version:     SP4 b (Q2 2012)
" Homepage:    http://www.vim.org/scripts/script.php?script_id=4275

" Description: Updated to SAP HANA SP4
"
" quit when a syntax file was already loaded
if exists("b:current_syntax")
    finish
endif

syn case ignore

" The SQL reserved words, defined as keywords.
" These were pulled from the following SQL reference:
"     http://help.sap.com/hana/hana_sql_en.pdf
" An easy approach is to copy all text from the PDF
" into a Vim buffer.  The keywords are in UPPER case,
" so you can run the following commands to be left with
" mainly the UPPER case words:
"   1.  Delete all words that do not begin with a Capital
"       %s/\(\<[^A-Z]\w*\>\)//g
"   2.  Remove all words where the 2nd letter is not a Capital
"       %s/\(\<[A-Z][^A-Z]\w*\>\)//g
"   3.  Remove all non-word (or space) characters
"       %s/[^0-9A-Za-z_ ]*//g
"   4.  Remove some known words
"       %s/\<\(SAP\|HANA\|OK\|AG\|IBM\|DB2\|AIX\|POWER\d\+\|UNIX\)\>//g
"   5.  Remove blank lines and trailing spaces
"       %s/\s\+$//g
"       %s/^\s\+//g
"       %s/^$\n//g
"   6.  Convert spaces to newlines remove single character
"       %s/[ ]\+/\r/g
"       %g/^\w$/d
"   7.  Sort and remove duplicates
"       :sort
"       :Uniq
"   8.  Use the WhatsMissing plugin against the sqlhana.vim file.
"   9.  Generated a file of all UPPER cased words which should not
"       be in the syntax file.  These items should be removed
"       from the list in step 7.  You can use WhatsNotMissing
"       between step 7 and this new file to weed out the words
"       we know are not syntax related.
"  10.  Use the WhatsMissingRemoveMatches to remove the words
"       from step 9.

syn keyword sqlSpecial  false null true

" Supported Functions for Date/Time types
syn keyword sqlFunction	 ADD_DAYS ADD_MONTHS ADD_SECONDS ADD_YEARS COALESCE
syn keyword sqlFunction	 CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_UTCDATE
syn keyword sqlFunction	 CURRENT_UTCTIME CURRENT_UTCTIMESTAMP
syn keyword sqlFunction	 DAYNAME DAYOFMONTH DAYOFYEAR DAYS_BETWEEN EXTRACT
syn keyword sqlFunction	 GREATEST HOUR IFNULL ISOWEEK LAST_DAY LEAST LOCALTOUTC
syn keyword sqlFunction	 MINUTE MONTH MONTHNAME NEXT_DAY NOW QUARTER SECOND
syn keyword sqlFunction	 SECONDS_BETWEEN UTCTOLOCAL WEEK WEEKDAY YEAR

syn keyword sqlFunction	 TO_CHAR TO_DATE TO_DATS TO_NCHAR TO_TIME TO_TIMESTAMP UTCTOLOCAL

" Aggregate
syn keyword sqlFunction	 COUNT MIN MAX SUM AVG STDDEV VAR

" Datatype conversion
syn keyword sqlFunction	 CAST TO_ALPHANUM TO_BIGINT TO_BINARY TO_BLOB TO_CHAR TO_CLOB
syn keyword sqlFunction	 TO_DATE TO_DATS TO_DECIMAL TO_DOUBLE TO_INT TO_INTEGER TO_NCHAR
syn keyword sqlFunction	 TO_NCLOB TO_NVARCHAR TO_REAL TO_SECONDDATE TO_SMALLDECIMAL
syn keyword sqlFunction	 TO_SMALLINT TO_TIME TO_TIMESTAMP TO_TINYINT TO_VARCHAR TO_VARBINARY

" Number functions
syn keyword sqlFunction	 ABS ACOS ASIN ATAN ATAN2 BINTOHEX BITAND CEIL COS COSH COT
syn keyword sqlFunction	 EXP FLOOR GREATEST HEXTOBIN LEAST LN LOG MOD POWER ROUND
syn keyword sqlFunction	 SIGN SIN SINH SQRT TAN TANH UMINUS

" String functions
syn keyword sqlFunction	 ASCII CHAR CONCAT LCASE LENGTH LOCATE LOWER LPAD LTRIM
syn keyword sqlFunction	 NCHAR REPLACE RPAD RTRIM SUBSTR_AFTER SUBSTR_BEFORE
syn keyword sqlFunction	 SUBSTRING TRIM UCASE UNICODE UPPER

" Miscellaneous functions
syn keyword sqlFunction	 COALESCE CURRENT_CONNECTION CURRENT_SCHEMA CURRENT_USER
syn keyword sqlFunction	 GROUPING_ID IFNULL MAP NULLIF SESSION_CONTEXT SESSION_USER SYSUUIDSQL
syn keyword sqlFunction	 GET_NUM_SERVERS


" sp_ procedures
" syn keyword sqlFunction  sp_addalias


" Reserved keywords
syn keyword sqlkeyword   ALL AS AT BEFORE
syn keyword sqlkeyword   BEGIN BOTH BY
syn keyword sqlkeyword   CONDITION
syn keyword sqlkeyword   CURRVAL CURSOR DECLARE
syn keyword sqlkeyword   DISTINCT DO ELSE ELSEIF ELSIF
syn keyword sqlkeyword   END EXCEPTION EXEC
syn keyword sqlkeyword   FOR FROM GROUP
syn keyword sqlkeyword   HAVING IN
syn keyword sqlkeyword   INOUT INTO IS
syn keyword sqlkeyword   LEADING
syn keyword sqlkeyword   LOOP MINUS NATURAL NEXTVAL
syn keyword sqlkeyword   OF ON ORDER OUT
syn keyword sqlkeyword   PRIOR RETURN RETURNS REVERSE
syn keyword sqlkeyword   ROWID SELECT
syn keyword sqlkeyword   SQL START STOP SYSDATE
syn keyword sqlkeyword   SYSTIME SYSTIMESTAMP SYSUUID
syn keyword sqlkeyword   TRAILING USING UTCDATE
syn keyword sqlkeyword   UTCTIME UTCTIMESTAMP VALUES
syn keyword sqlkeyword   WHILE
syn keyword sqlkeyword   ANY SOME EXISTS ESCAPE

" IF keywords
syn keyword sqlkeyword	 IF

" CASE keywords
syn keyword sqlKeyword	 WHEN THEN

" Syntax rules common to TEXT and SHORTTEXT keywords
syn keyword sqlKeyword	 LANGUAGE DETECTION LINGUISTIC
syn keyword sqlkeyword   MIME TYPE
syn keyword sqlkeyword   EXACT WEIGHT FUZZY FUZZINESSTHRESHOLD SEARCH
syn keyword sqlkeyword   PHRASE INDEX RATIO REBUILD
syn keyword sqlkeyword   CONFIGURATION
syn keyword sqlkeyword   SEARCH ONLY
syn keyword sqlkeyword   FAST PREPROCESS
syn keyword sqlkeyword   SYNC SYNCHRONOUS ASYNC ASYNCHRONOUS FLUSH QUEUE
syn keyword sqlkeyword   EVERY AFTER MINUTES DOCUMENTS SUSPEND

" Statement keywords (i.e. after ALTER or CREATE)
syn keyword sqlkeyword   AUDIT POLICY
syn keyword sqlkeyword   FULLTEXT
syn keyword sqlkeyword   SEQUENCE RESTART
syn keyword sqlkeyword   TABLE
syn keyword sqlkeyword   PROCEDURE STATISTICS
syn keyword sqlkeyword   SCHEMA
syn keyword sqlkeyword   SYNONYM
syn keyword sqlkeyword   VIEW
syn keyword sqlkeyword   COLUMN
syn keyword sqlkeyword   SYSTEM LICENSE
syn keyword sqlkeyword   SESSION
syn keyword sqlkeyword   CANCEL WORK
syn keyword sqlkeyword   PLAN CACHE
syn keyword sqlkeyword   LOGGING NOLOGGING RETENTION
syn keyword sqlkeyword   RECONFIGURE SERVICE
syn keyword sqlkeyword   RESET MONITORING
syn keyword sqlkeyword   SAVE DURATION PERFTRACE FUNCTION_PROFILER
syn keyword sqlkeyword   SAVEPOINT
syn keyword sqlkeyword   USER
syn keyword sqlkeyword   ROLE
syn keyword sqlkeyword   ASC DESC
syn keyword sqlkeyword   OWNED
syn keyword sqlkeyword   DEPENDENCIES SCRAMBLE

" Create sequence
syn keyword sqlkeyword   INCREMENT MAXVALUE MINVALUE CYCLE

" Create table
syn keyword sqlkeyword   HISTORY GLOBAL LOCAL TEMPORARY

" Create trigger
syn keyword sqlkeyword   TRIGGER REFERENCING EACH DEFAULT
syn keyword sqlkeyword   SIGNAL RESIGNAL MESSAGE_TEXT OLD NEW
syn keyword sqlkeyword   EXIT HANDLER SQL_ERROR_CODE
syn keyword sqlkeyword   TARGET CONDITION SIGNAL

" Alter table
syn keyword sqlkeyword   ADD DROP MODIFY GENERATED ALWAYS
syn keyword sqlkeyword   UNIQUE BTREE CPBTREE PRIMARY KEY
syn keyword sqlkeyword   CONSTRAINT PRELOAD NONE
syn keyword sqlkeyword   ROW THREADS BATCH
syn keyword sqlkeyword   MOVE PARTITION TO LOCATION PHYSICAL OTHERS
syn keyword sqlkeyword   ROUNDROBIN PARTITIONS HASH RANGE VALUE
syn keyword sqlkeyword   PERSISTENT DELTA AUTO AUTOMERGE

" Create audit policy
syn keyword sqlkeyword   AUDITING SUCCESSFUL UNSUCCESSFUL
syn keyword sqlkeyword	 PRIVILEGE STRUCTURED CHANGE LEVEL
syn keyword sqlkeyword	 EMERGENCY ALERT CRITICAL WARNING INFO

" Privileges
syn keyword sqlkeyword   DEBUG EXECUTE

" Schema
syn keyword sqlkeyword   CASCADE RESTRICT PARAMETERS SCAN

" Traces
syn keyword sqlkeyword   CLIENT CRASHDUMP EMERGENCYDUMP
syn keyword sqlkeyword   INDEXSERVER NAMESERVER DAEMON
syn keyword sqlkeyword   CLEAR REMOVE TRACES

" Reclaim
syn keyword sqlkeyword   RECLAIM DATA VOLUME VERSION SPACE DEFRAGMENT SPARSIFY

" Join
syn keyword sqlkeyword   INNER OUTER LEFT RIGHT FULL CROSS JOIN
syn keyword sqlkeyword   GROUPING SETS ROLLUP CUBE
syn keyword sqlkeyword   BEST LIMIT OFFSET
syn keyword sqlkeyword   WITH SUBTOTAL BALANCE TOTAL
syn keyword sqlkeyword   TEXT_FILTER FILL UP SORT MATCHES TOP
syn keyword sqlkeyword   RESULT OVERVIEW PREFIX MULTIPLE RESULTSETS

" Lock
syn keyword sqlkeyword   EXCLUSIVE MODE NOWAIT

" Transaction
syn keyword sqlkeyword   TRANSACTION ISOLATION READ COMMITTED
syn keyword sqlkeyword   REPEATABLE SERIALIZABLE WRITE

" Saml
syn keyword sqlkeyword   SAML ASSERTION PROVIDER SUBJECT ISSUER

" User
syn keyword sqlkeyword   PASSWORD IDENTIFIED EXTERNALLY ATTEMPTS ATTEMPTS
syn keyword sqlkeyword	 ENABLE DISABLE OFF LIFETIME FORCE DEACTIVATE
syn keyword sqlkeyword	 ACTIVATE IDENTITY KERBEROS

" Grant
syn keyword sqlkeyword   ADMIN BACKUP CATALOG SCENARIO INIFILE MONITOR
syn keyword sqlkeyword   OPTIMIZER OPTION
syn keyword sqlkeyword   RESOURCE STRUCTUREDPRIVILEGE TRACE

" Import
syn keyword sqlkeyword   CSV FILE CONTROL NO CHECK SKIP FIRST LIST
syn keyword sqlkeyword	 RECORD DELIMITED FIELD OPTIONALLY ENCLOSED FORMAT

" Roles
syn keyword sqlkeyword   PUBLIC CONTENT_ADMIN MODELING MONITORING

" Miscellaneous
syn keyword sqlkeyword   APPLICATION BINARY IMMEDIATE COREFILE SECURITY DEFINER
syn keyword sqlkeyword   DUMMY INVOKER MATERIALIZED MESSEGE_TEXT PARAMETER PARAMETERS
syn keyword sqlkeyword   PART
syn keyword sqlkeyword   CONSTANT SQLEXCEPTION SQLWARNING

syn keyword sqlOperator  WHERE BETWEEN LIKE NULL CONTAINS
syn keyword sqlOperator  AND OR NOT CASE
syn keyword sqlOperator  UNION INTERSECT EXCEPT

syn keyword sqlStatement ALTER CALL CALLS CREATE DROP RENAME TRUNCATE
syn keyword sqlStatement DELETE INSERT UPDATE EXPLAIN
syn keyword sqlStatement MERGE REPLACE UPSERT SELECT
syn keyword sqlStatement SET UNSET LOAD UNLOAD
syn keyword sqlStatement CONNECT DISCONNECT COMMIT LOCK ROLLBACK
syn keyword sqlStatement GRANT REVOKE
syn keyword sqlStatement EXPORT IMPORT


syn keyword sqlType	 DATE TIME SECONDDATE TIMESTAMP TINYINT SMALLINT
syn keyword sqlType	 INT INTEGER BIGINT SMALLDECIMAL DECIMAL
syn keyword sqlType	 REAL DOUBLE FLOAT
syn keyword sqlType	 VARCHAR NVARCHAR ALPHANUM SHORTTEXT VARBINARY
syn keyword sqlType	 BLOB CLOB NCLOB TEXT DAYDATE

syn keyword sqlOption    Webservice_namespace_host

" Strings and characters:
syn region sqlString		start=+"+    end=+"+ contains=@Spell
syn region sqlString		start=+'+    end=+'+ contains=@Spell

" Numbers:
syn match sqlNumber		"-\=\<\d*\.\=[0-9_]\>"

" Comments:
syn region sqlDashComment	start=/--/ end=/$/ contains=@Spell
syn region sqlSlashComment	start=/\/\// end=/$/ contains=@Spell
syn region sqlMultiComment	start="/\*" end="\*/" contains=sqlMultiComment,@Spell
syn cluster sqlComment	contains=sqlDashComment,sqlSlashComment,sqlMultiComment,@Spell
syn sync ccomment sqlComment
syn sync ccomment sqlDashComment
syn sync ccomment sqlSlashComment

hi def link sqlDashComment	Comment
hi def link sqlSlashComment	Comment
hi def link sqlMultiComment	Comment
hi def link sqlNumber	        Number
hi def link sqlOperator	        Operator
hi def link sqlSpecial	        Special
hi def link sqlKeyword	        Keyword
hi def link sqlStatement	Statement
hi def link sqlString	        String
hi def link sqlType	        Type
hi def link sqlFunction	        Function
hi def link sqlOption	        PreProc

let b:current_syntax = "sqlhana"

" vim:sw=4: