3920
|
1 " Vim syntax file
|
|
2 " Language: SQL, SAP HANA In Memory Database
|
|
3 " Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
|
|
4 " Last Change: 2012 Oct 23
|
|
5 " Version: SP4 b (Q2 2012)
|
|
6 " Homepage: http://www.vim.org/scripts/script.php?script_id=4275
|
|
7
|
|
8 " Description: Updated to SAP HANA SP4
|
|
9 "
|
|
10 " For version 5.x: Clear all syntax items
|
|
11 " For version 6.x: Quit when a syntax file was already loaded
|
|
12 if version < 600
|
|
13 syntax clear
|
|
14 elseif exists("b:current_syntax")
|
|
15 finish
|
|
16 endif
|
|
17
|
|
18 syn case ignore
|
|
19
|
|
20 " The SQL reserved words, defined as keywords.
|
|
21 " These were pulled from the following SQL reference:
|
|
22 " http://help.sap.com/hana/hana_sql_en.pdf
|
|
23 " An easy approach is to copy all text from the PDF
|
|
24 " into a Vim buffer. The keywords are in UPPER case,
|
|
25 " so you can run the following commands to be left with
|
|
26 " mainly the UPPER case words:
|
|
27 " 1. Delete all words that do not begin with a Capital
|
|
28 " %s/\(\<[^A-Z]\w*\>\)//g
|
|
29 " 2. Remove all words where the 2nd letter is not a Capital
|
|
30 " %s/\(\<[A-Z][^A-Z]\w*\>\)//g
|
|
31 " 3. Remove all non-word (or space) characters
|
|
32 " %s/[^0-9A-Za-z_ ]*//g
|
|
33 " 4. Remove some known words
|
|
34 " %s/\<\(SAP\|HANA\|OK\|AG\|IBM\|DB2\|AIX\|POWER\d\+\|UNIX\)\>//g
|
|
35 " 5. Remove blank lines and trailing spaces
|
|
36 " %s/\s\+$//g
|
|
37 " %s/^\s\+//g
|
|
38 " %s/^$\n//g
|
|
39 " 6. Convert spaces to newlines remove single character
|
|
40 " %s/[ ]\+/\r/g
|
|
41 " %g/^\w$/d
|
|
42 " 7. Sort and remove duplicates
|
|
43 " :sort
|
|
44 " :Uniq
|
|
45 " 8. Use the WhatsMissing plugin against the sqlhana.vim file.
|
|
46 " 9. Generated a file of all UPPER cased words which should not
|
|
47 " be in the syntax file. These items should be removed
|
|
48 " from the list in step 7. You can use WhatsNotMissing
|
|
49 " between step 7 and this new file to weed out the words
|
|
50 " we know are not syntax related.
|
|
51 " 10. Use the WhatsMissingRemoveMatches to remove the words
|
|
52 " from step 9.
|
|
53
|
|
54 syn keyword sqlSpecial false null true
|
|
55
|
|
56 " Supported Functions for Date/Time types
|
|
57 syn keyword sqlFunction ADD_DAYS ADD_MONTHS ADD_SECONDS ADD_YEARS COALESCE
|
|
58 syn keyword sqlFunction CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_UTCDATE
|
|
59 syn keyword sqlFunction CURRENT_UTCTIME CURRENT_UTCTIMESTAMP
|
|
60 syn keyword sqlFunction DAYNAME DAYOFMONTH DAYOFYEAR DAYS_BETWEEN EXTRACT
|
|
61 syn keyword sqlFunction GREATEST HOUR IFNULL ISOWEEK LAST_DAY LEAST LOCALTOUTC
|
|
62 syn keyword sqlFunction MINUTE MONTH MONTHNAME NEXT_DAY NOW QUARTER SECOND
|
|
63 syn keyword sqlFunction SECONDS_BETWEEN UTCTOLOCAL WEEK WEEKDAY YEAR
|
|
64
|
|
65 syn keyword sqlFunction TO_CHAR TO_DATE TO_DATS TO_NCHAR TO_TIME TO_TIMESTAMP UTCTOLOCAL
|
|
66
|
|
67 " Aggregate
|
|
68 syn keyword sqlFunction COUNT MIN MAX SUM AVG STDDEV VAR
|
|
69
|
|
70 " Datatype conversion
|
|
71 syn keyword sqlFunction CAST TO_ALPHANUM TO_BIGINT TO_BINARY TO_BLOB TO_CHAR TO_CLOB
|
|
72 syn keyword sqlFunction TO_DATE TO_DATS TO_DECIMAL TO_DOUBLE TO_INT TO_INTEGER TO_NCHAR
|
|
73 syn keyword sqlFunction TO_NCLOB TO_NVARCHAR TO_REAL TO_SECONDDATE TO_SMALLDECIMAL
|
|
74 syn keyword sqlFunction TO_SMALLINT TO_TIME TO_TIMESTAMP TO_TINYINT TO_VARCHAR TO_VARBINARY
|
|
75
|
|
76 " Number functions
|
|
77 syn keyword sqlFunction ABS ACOS ASIN ATAN ATAN2 BINTOHEX BITAND CEIL COS COSH COT
|
|
78 syn keyword sqlFunction EXP FLOOR GREATEST HEXTOBIN LEAST LN LOG MOD POWER ROUND
|
|
79 syn keyword sqlFunction SIGN SIN SINH SQRT TAN TANH UMINUS
|
|
80
|
|
81 " String functions
|
|
82 syn keyword sqlFunction ASCII CHAR CONCAT LCASE LENGTH LOCATE LOWER LPAD LTRIM
|
|
83 syn keyword sqlFunction NCHAR REPLACE RPAD RTRIM SUBSTR_AFTER SUBSTR_BEFORE
|
|
84 syn keyword sqlFunction SUBSTRING TRIM UCASE UNICODE UPPER
|
|
85
|
|
86 " Miscellaneous functions
|
|
87 syn keyword sqlFunction COALESCE CURRENT_CONNECTION CURRENT_SCHEMA CURRENT_USER
|
|
88 syn keyword sqlFunction GROUPING_ID IFNULL MAP NULLIF SESSION_CONTEXT SESSION_USER SYSUUIDSQL
|
|
89 syn keyword sqlFunction GET_NUM_SERVERS
|
|
90
|
|
91
|
|
92 " sp_ procedures
|
|
93 " syn keyword sqlFunction sp_addalias
|
|
94
|
|
95
|
|
96 " Reserved keywords
|
|
97 syn keyword sqlkeyword ALL AS AT BEFORE
|
|
98 syn keyword sqlkeyword BEGIN BOTH BY
|
|
99 syn keyword sqlkeyword CONDITION
|
|
100 syn keyword sqlkeyword CURRVAL CURSOR DECLARE
|
|
101 syn keyword sqlkeyword DISTINCT DO ELSE ELSEIF ELSIF
|
|
102 syn keyword sqlkeyword END EXCEPTION EXEC
|
|
103 syn keyword sqlkeyword FOR FROM GROUP
|
|
104 syn keyword sqlkeyword HAVING IN
|
|
105 syn keyword sqlkeyword INOUT INTO IS
|
|
106 syn keyword sqlkeyword LEADING
|
|
107 syn keyword sqlkeyword LOOP MINUS NATURAL NEXTVAL
|
|
108 syn keyword sqlkeyword OF ON ORDER OUT
|
|
109 syn keyword sqlkeyword PRIOR RETURN RETURNS REVERSE
|
|
110 syn keyword sqlkeyword ROWID SELECT
|
|
111 syn keyword sqlkeyword SQL START STOP SYSDATE
|
|
112 syn keyword sqlkeyword SYSTIME SYSTIMESTAMP SYSUUID
|
|
113 syn keyword sqlkeyword TRAILING USING UTCDATE
|
|
114 syn keyword sqlkeyword UTCTIME UTCTIMESTAMP VALUES
|
|
115 syn keyword sqlkeyword WHILE
|
|
116 syn keyword sqlkeyword ANY SOME EXISTS ESCAPE
|
|
117
|
|
118 " IF keywords
|
|
119 syn keyword sqlkeyword IF
|
|
120
|
|
121 " CASE keywords
|
|
122 syn keyword sqlKeyword WHEN THEN
|
|
123
|
|
124 " Syntax rules common to TEXT and SHORTTEXT keywords
|
|
125 syn keyword sqlKeyword LANGUAGE DETECTION LINGUISTIC
|
|
126 syn keyword sqlkeyword MIME TYPE
|
|
127 syn keyword sqlkeyword EXACT WEIGHT FUZZY FUZZINESSTHRESHOLD SEARCH
|
|
128 syn keyword sqlkeyword PHRASE INDEX RATIO REBUILD
|
|
129 syn keyword sqlkeyword CONFIGURATION
|
|
130 syn keyword sqlkeyword SEARCH ONLY
|
|
131 syn keyword sqlkeyword FAST PREPROCESS
|
|
132 syn keyword sqlkeyword SYNC SYNCHRONOUS ASYNC ASYNCHRONOUS FLUSH QUEUE
|
|
133 syn keyword sqlkeyword EVERY AFTER MINUTES DOCUMENTS SUSPEND
|
|
134
|
|
135 " Statement keywords (i.e. after ALTER or CREATE)
|
|
136 syn keyword sqlkeyword AUDIT POLICY
|
|
137 syn keyword sqlkeyword FULLTEXT
|
|
138 syn keyword sqlkeyword SEQUENCE RESTART
|
|
139 syn keyword sqlkeyword TABLE
|
|
140 syn keyword sqlkeyword PROCEDURE STATISTICS
|
|
141 syn keyword sqlkeyword SCHEMA
|
|
142 syn keyword sqlkeyword SYNONYM
|
|
143 syn keyword sqlkeyword VIEW
|
|
144 syn keyword sqlkeyword COLUMN
|
|
145 syn keyword sqlkeyword SYSTEM LICENSE
|
|
146 syn keyword sqlkeyword SESSION
|
|
147 syn keyword sqlkeyword CANCEL WORK
|
|
148 syn keyword sqlkeyword PLAN CACHE
|
|
149 syn keyword sqlkeyword LOGGING NOLOGGING RETENTION
|
|
150 syn keyword sqlkeyword RECONFIGURE SERVICE
|
|
151 syn keyword sqlkeyword RESET MONITORING
|
|
152 syn keyword sqlkeyword SAVE DURATION PERFTRACE FUNCTION_PROFILER
|
|
153 syn keyword sqlkeyword SAVEPOINT
|
|
154 syn keyword sqlkeyword USER
|
|
155 syn keyword sqlkeyword ROLE
|
|
156 syn keyword sqlkeyword ASC DESC
|
|
157 syn keyword sqlkeyword OWNED
|
|
158 syn keyword sqlkeyword DEPENDENCIES SCRAMBLE
|
|
159
|
|
160 " Create sequence
|
|
161 syn keyword sqlkeyword INCREMENT MAXVALUE MINVALUE CYCLE
|
|
162
|
|
163 " Create table
|
|
164 syn keyword sqlkeyword HISTORY GLOBAL LOCAL TEMPORARY
|
|
165
|
|
166 " Create trigger
|
|
167 syn keyword sqlkeyword TRIGGER REFERENCING EACH DEFAULT
|
|
168 syn keyword sqlkeyword SIGNAL RESIGNAL MESSAGE_TEXT OLD NEW
|
|
169 syn keyword sqlkeyword EXIT HANDLER SQL_ERROR_CODE
|
|
170 syn keyword sqlkeyword TARGET CONDITION SIGNAL
|
|
171
|
|
172 " Alter table
|
|
173 syn keyword sqlkeyword ADD DROP MODIFY GENERATED ALWAYS
|
|
174 syn keyword sqlkeyword UNIQUE BTREE CPBTREE PRIMARY KEY
|
|
175 syn keyword sqlkeyword CONSTRAINT PRELOAD NONE
|
|
176 syn keyword sqlkeyword ROW THREADS BATCH
|
|
177 syn keyword sqlkeyword MOVE PARTITION TO LOCATION PHYSICAL OTHERS
|
|
178 syn keyword sqlkeyword ROUNDROBIN PARTITIONS HASH RANGE VALUE
|
|
179 syn keyword sqlkeyword PERSISTENT DELTA AUTO AUTOMERGE
|
|
180
|
|
181 " Create audit policy
|
|
182 syn keyword sqlkeyword AUDITING SUCCESSFUL UNSUCCESSFUL
|
|
183 syn keyword sqlkeyword PRIVILEGE STRUCTURED CHANGE LEVEL
|
|
184 syn keyword sqlkeyword EMERGENCY ALERT CRITICAL WARNING INFO
|
|
185
|
|
186 " Privileges
|
|
187 syn keyword sqlkeyword DEBUG EXECUTE
|
|
188
|
|
189 " Schema
|
|
190 syn keyword sqlkeyword CASCADE RESTRICT PARAMETERS SCAN
|
|
191
|
|
192 " Traces
|
|
193 syn keyword sqlkeyword CLIENT CRASHDUMP EMERGENCYDUMP
|
|
194 syn keyword sqlkeyword INDEXSERVER NAMESERVER DAEMON
|
|
195 syn keyword sqlkeyword CLEAR REMOVE TRACES
|
|
196
|
|
197 " Reclaim
|
|
198 syn keyword sqlkeyword RECLAIM DATA VOLUME VERSION SPACE DEFRAGMENT SPARSIFY
|
|
199
|
|
200 " Join
|
|
201 syn keyword sqlkeyword INNER OUTER LEFT RIGHT FULL CROSS JOIN
|
|
202 syn keyword sqlkeyword GROUPING SETS ROLLUP CUBE
|
|
203 syn keyword sqlkeyword BEST LIMIT OFFSET
|
|
204 syn keyword sqlkeyword WITH SUBTOTAL BALANCE TOTAL
|
|
205 syn keyword sqlkeyword TEXT_FILTER FILL UP SORT MATCHES TOP
|
|
206 syn keyword sqlkeyword RESULT OVERVIEW PREFIX MULTIPLE RESULTSETS
|
|
207
|
|
208 " Lock
|
|
209 syn keyword sqlkeyword EXCLUSIVE MODE NOWAIT
|
|
210
|
|
211 " Transaction
|
|
212 syn keyword sqlkeyword TRANSACTION ISOLATION READ COMMITTED
|
|
213 syn keyword sqlkeyword REPEATABLE SERIALIZABLE WRITE
|
|
214
|
|
215 " Saml
|
|
216 syn keyword sqlkeyword SAML ASSERTION PROVIDER SUBJECT ISSUER
|
|
217
|
|
218 " User
|
|
219 syn keyword sqlkeyword PASSWORD IDENTIFIED EXTERNALLY ATTEMPTS ATTEMPTS
|
|
220 syn keyword sqlkeyword ENABLE DISABLE OFF LIFETIME FORCE DEACTIVATE
|
|
221 syn keyword sqlkeyword ACTIVATE IDENTITY KERBEROS
|
|
222
|
|
223 " Grant
|
|
224 syn keyword sqlkeyword ADMIN BACKUP CATALOG SCENARIO INIFILE MONITOR
|
|
225 syn keyword sqlkeyword OPTIMIZER OPTION
|
|
226 syn keyword sqlkeyword RESOURCE STRUCTUREDPRIVILEGE TRACE
|
|
227
|
|
228 " Import
|
|
229 syn keyword sqlkeyword CSV FILE CONTROL NO CHECK SKIP FIRST LIST
|
|
230 syn keyword sqlkeyword RECORD DELIMITED FIELD OPTIONALLY ENCLOSED FORMAT
|
|
231
|
|
232 " Roles
|
|
233 syn keyword sqlkeyword PUBLIC CONTENT_ADMIN MODELING MONITORING
|
|
234
|
|
235 " Miscellaneous
|
|
236 syn keyword sqlkeyword APPLICATION BINARY IMMEDIATE COREFILE SECURITY DEFINER
|
|
237 syn keyword sqlkeyword DUMMY INVOKER MATERIALIZED MESSEGE_TEXT PARAMETER PARAMETERS
|
|
238 syn keyword sqlkeyword PART
|
|
239 syn keyword sqlkeyword CONSTANT SQLEXCEPTION SQLWARNING
|
|
240
|
|
241 syn keyword sqlOperator WHERE BETWEEN LIKE NULL CONTAINS
|
|
242 syn keyword sqlOperator AND OR NOT CASE
|
|
243 syn keyword sqlOperator UNION INTERSECT EXCEPT
|
|
244
|
|
245 syn keyword sqlStatement ALTER CALL CALLS CREATE DROP RENAME TRUNCATE
|
|
246 syn keyword sqlStatement DELETE INSERT UPDATE EXPLAIN
|
|
247 syn keyword sqlStatement MERGE REPLACE UPSERT SELECT
|
|
248 syn keyword sqlStatement SET UNSET LOAD UNLOAD
|
|
249 syn keyword sqlStatement CONNECT DISCONNECT COMMIT LOCK ROLLBACK
|
|
250 syn keyword sqlStatement GRANT REVOKE
|
|
251 syn keyword sqlStatement EXPORT IMPORT
|
|
252
|
|
253
|
|
254 syn keyword sqlType DATE TIME SECONDDATE TIMESTAMP TINYINT SMALLINT
|
|
255 syn keyword sqlType INT INTEGER BIGINT SMALLDECIMAL DECIMAL
|
|
256 syn keyword sqlType REAL DOUBLE FLOAT
|
|
257 syn keyword sqlType VARCHAR NVARCHAR ALPHANUM SHORTTEXT VARBINARY
|
|
258 syn keyword sqlType BLOB CLOB NCLOB TEXT DAYDATE
|
|
259
|
|
260 syn keyword sqlOption Webservice_namespace_host
|
|
261
|
|
262 " Strings and characters:
|
|
263 syn region sqlString start=+"+ end=+"+ contains=@Spell
|
|
264 syn region sqlString start=+'+ end=+'+ contains=@Spell
|
|
265
|
|
266 " Numbers:
|
|
267 syn match sqlNumber "-\=\<\d*\.\=[0-9_]\>"
|
|
268
|
|
269 " Comments:
|
|
270 syn region sqlDashComment start=/--/ end=/$/ contains=@Spell
|
|
271 syn region sqlSlashComment start=/\/\// end=/$/ contains=@Spell
|
|
272 syn region sqlMultiComment start="/\*" end="\*/" contains=sqlMultiComment,@Spell
|
|
273 syn cluster sqlComment contains=sqlDashComment,sqlSlashComment,sqlMultiComment,@Spell
|
|
274 syn sync ccomment sqlComment
|
|
275 syn sync ccomment sqlDashComment
|
|
276 syn sync ccomment sqlSlashComment
|
|
277
|
|
278 hi def link sqlDashComment Comment
|
|
279 hi def link sqlSlashComment Comment
|
|
280 hi def link sqlMultiComment Comment
|
|
281 hi def link sqlNumber Number
|
|
282 hi def link sqlOperator Operator
|
|
283 hi def link sqlSpecial Special
|
|
284 hi def link sqlKeyword Keyword
|
|
285 hi def link sqlStatement Statement
|
|
286 hi def link sqlString String
|
|
287 hi def link sqlType Type
|
|
288 hi def link sqlFunction Function
|
|
289 hi def link sqlOption PreProc
|
|
290
|
|
291 let b:current_syntax = "sqlhana"
|
|
292
|
|
293 " vim:sw=4:
|