blob: 9c5a4905826485f7850366eabee856719b42c820 [file] [log] [blame]
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00001" Vim syntax file
Bram Moolenaar9712ff12022-09-18 13:04:22 +01002" Language: Lua 4.0, Lua 5.0, Lua 5.1, Lua 5.2 and Lua 5.3
Bram Moolenaar71b6d332022-09-10 13:13:14 +01003" Maintainer: Marcus Aurelius Farias <masserahguard-lua 'at' yahoo com>
4" First Author: Carlos Augusto Teixeira Mendes <cmendes 'at' inf puc-rio br>
Bram Moolenaar9712ff12022-09-18 13:04:22 +01005" Last Change: 2022 Sep 07
Bram Moolenaar71b6d332022-09-10 13:13:14 +01006" Options: lua_version = 4 or 5
Bram Moolenaar9712ff12022-09-18 13:04:22 +01007" lua_subversion = 0 (for 4.0 or 5.0)
8" or 1, 2, 3 (for 5.1, 5.2 or 5.3)
9" the default is 5.3
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020011" quit when a syntax file was already loaded
12if exists("b:current_syntax")
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000013 finish
14endif
15
Bram Moolenaar5dc62522012-02-13 00:05:22 +010016let s:cpo_save = &cpo
17set cpo&vim
18
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000019if !exists("lua_version")
Bram Moolenaar9712ff12022-09-18 13:04:22 +010020 " Default is lua 5.3
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000021 let lua_version = 5
Bram Moolenaar9712ff12022-09-18 13:04:22 +010022 let lua_subversion = 3
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000023elseif !exists("lua_subversion")
Bram Moolenaar9712ff12022-09-18 13:04:22 +010024 " lua_version exists, but lua_subversion doesn't. In this case set it to 0
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000025 let lua_subversion = 0
26endif
27
28syn case match
29
30" syncing method
Bram Moolenaar9712ff12022-09-18 13:04:22 +010031syn sync minlines=1000
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000032
Bram Moolenaar9712ff12022-09-18 13:04:22 +010033if lua_version >= 5
34 syn keyword luaMetaMethod __add __sub __mul __div __pow __unm __concat
35 syn keyword luaMetaMethod __eq __lt __le
36 syn keyword luaMetaMethod __index __newindex __call
37 syn keyword luaMetaMethod __metatable __mode __gc __tostring
38endif
39
40if lua_version > 5 || (lua_version == 5 && lua_subversion >= 1)
41 syn keyword luaMetaMethod __mod __len
42endif
43
44if lua_version > 5 || (lua_version == 5 && lua_subversion >= 2)
45 syn keyword luaMetaMethod __pairs
46endif
47
48if lua_version > 5 || (lua_version == 5 && lua_subversion >= 3)
49 syn keyword luaMetaMethod __idiv __name
50 syn keyword luaMetaMethod __band __bor __bxor __bnot __shl __shr
51endif
52
53if lua_version > 5 || (lua_version == 5 && lua_subversion >= 4)
54 syn keyword luaMetaMethod __close
55endif
56
57" catch errors caused by wrong parenthesis and wrong curly brackets or
58" keywords placed outside their respective blocks
59
60syn region luaParen transparent start='(' end=')' contains=TOP,luaParenError
61syn match luaParenError ")"
62syn match luaError "}"
63syn match luaError "\<\%(end\|else\|elseif\|then\|until\|in\)\>"
64
65" Function declaration
66syn region luaFunctionBlock transparent matchgroup=luaFunction start="\<function\>" end="\<end\>" contains=TOP
67
68" else
69syn keyword luaCondElse matchgroup=luaCond contained containedin=luaCondEnd else
70
71" then ... end
72syn region luaCondEnd contained transparent matchgroup=luaCond start="\<then\>" end="\<end\>" contains=TOP
73
74" elseif ... then
75syn region luaCondElseif contained containedin=luaCondEnd transparent matchgroup=luaCond start="\<elseif\>" end="\<then\>" contains=TOP
76
77" if ... then
78syn region luaCondStart transparent matchgroup=luaCond start="\<if\>" end="\<then\>"me=e-4 contains=TOP nextgroup=luaCondEnd skipwhite skipempty
79
80" do ... end
81syn region luaBlock transparent matchgroup=luaStatement start="\<do\>" end="\<end\>" contains=TOP
82" repeat ... until
83syn region luaRepeatBlock transparent matchgroup=luaRepeat start="\<repeat\>" end="\<until\>" contains=TOP
84
85" while ... do
86syn region luaWhile transparent matchgroup=luaRepeat start="\<while\>" end="\<do\>"me=e-2 contains=TOP nextgroup=luaBlock skipwhite skipempty
87
88" for ... do and for ... in ... do
89syn region luaFor transparent matchgroup=luaRepeat start="\<for\>" end="\<do\>"me=e-2 contains=TOP nextgroup=luaBlock skipwhite skipempty
90
91syn keyword luaFor contained containedin=luaFor in
92
93" other keywords
94syn keyword luaStatement return local break
95if lua_version > 5 || (lua_version == 5 && lua_subversion >= 2)
96 syn keyword luaStatement goto
97 syn match luaLabel "::\I\i*::"
98endif
99
100" operators
101syn keyword luaOperator and or not
102
103if (lua_version == 5 && lua_subversion >= 3) || lua_version > 5
104 syn match luaSymbolOperator "[#<>=~^&|*/%+-]\|\.\{2,3}"
105elseif lua_version == 5 && (lua_subversion == 1 || lua_subversion == 2)
106 syn match luaSymbolOperator "[#<>=~^*/%+-]\|\.\{2,3}"
107else
108 syn match luaSymbolOperator "[<>=~^*/+-]\|\.\{2,3}"
109endif
110
111" comments
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100112syn keyword luaTodo contained TODO FIXME XXX
113syn match luaComment "--.*$" contains=luaTodo,@Spell
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000114if lua_version == 5 && lua_subversion == 0
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100115 syn region luaComment matchgroup=luaCommentDelimiter start="--\[\[" end="\]\]" contains=luaTodo,luaInnerComment,@Spell
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100116 syn region luaInnerComment contained transparent start="\[\[" end="\]\]"
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000117elseif lua_version > 5 || (lua_version == 5 && lua_subversion >= 1)
118 " Comments in Lua 5.1: --[[ ... ]], [=[ ... ]=], [===[ ... ]===], etc.
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100119 syn region luaComment matchgroup=luaCommentDelimiter start="--\[\z(=*\)\[" end="\]\z1\]" contains=luaTodo,@Spell
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000120endif
121
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100122" first line may start with #!
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000123syn match luaComment "\%^#!.*"
124
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100125syn keyword luaConstant nil
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000126if lua_version > 4
127 syn keyword luaConstant true false
128endif
129
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100130" strings
131syn match luaSpecial contained #\\[\\abfnrtv'"[\]]\|\\[[:digit:]]\{,3}#
132if lua_version == 5
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100133 if lua_subversion == 0
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100134 syn region luaString2 matchgroup=luaStringDelimiter start=+\[\[+ end=+\]\]+ contains=luaString2,@Spell
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100135 else
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100136 if lua_subversion >= 2
137 syn match luaSpecial contained #\\z\|\\x[[:xdigit:]]\{2}#
138 endif
139 if lua_subversion >= 3
140 syn match luaSpecial contained #\\u{[[:xdigit:]]\+}#
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100141 endif
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100142 syn region luaString2 matchgroup=luaStringDelimiter start="\[\z(=*\)\[" end="\]\z1\]" contains=@Spell
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100143 endif
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000144endif
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100145syn region luaString matchgroup=luaStringDelimiter start=+'+ end=+'+ skip=+\\\\\|\\'+ contains=luaSpecial,@Spell
146syn region luaString matchgroup=luaStringDelimiter start=+"+ end=+"+ skip=+\\\\\|\\"+ contains=luaSpecial,@Spell
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000147
148" integer number
Bram Moolenaar9964e462007-05-05 17:54:07 +0000149syn match luaNumber "\<\d\+\>"
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000150" floating point number, with dot, optional exponent
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100151syn match luaNumber "\<\d\+\.\d*\%([eE][-+]\=\d\+\)\="
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000152" floating point number, starting with a dot, optional exponent
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100153syn match luaNumber "\.\d\+\%([eE][-+]\=\d\+\)\=\>"
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000154" floating point number, without dot, with exponent
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100155syn match luaNumber "\<\d\+[eE][-+]\=\d\+\>"
Bram Moolenaar9964e462007-05-05 17:54:07 +0000156
157" hex numbers
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100158if lua_version >= 5
159 if lua_subversion == 1
160 syn match luaNumber "\<0[xX]\x\+\>"
161 elseif lua_subversion >= 2
162 syn match luaNumber "\<0[xX][[:xdigit:].]\+\%([pP][-+]\=\d\+\)\=\>"
163 endif
Bram Moolenaar9964e462007-05-05 17:54:07 +0000164endif
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000165
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100166" tables
167syn region luaTableBlock transparent matchgroup=luaTable start="{" end="}" contains=TOP,luaStatement
168
169" methods
170syntax match luaFunc ":\@<=\k\+"
171
172" built-in functions
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000173syn keyword luaFunc assert collectgarbage dofile error next
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100174syn keyword luaFunc print rawget rawset self tonumber tostring type _VERSION
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000175
176if lua_version == 4
177 syn keyword luaFunc _ALERT _ERRORMESSAGE gcinfo
178 syn keyword luaFunc call copytagmethods dostring
179 syn keyword luaFunc foreach foreachi getglobal getn
180 syn keyword luaFunc gettagmethod globals newtag
181 syn keyword luaFunc setglobal settag settagmethod sort
182 syn keyword luaFunc tag tinsert tremove
183 syn keyword luaFunc _INPUT _OUTPUT _STDIN _STDOUT _STDERR
184 syn keyword luaFunc openfile closefile flush seek
185 syn keyword luaFunc setlocale execute remove rename tmpname
186 syn keyword luaFunc getenv date clock exit
187 syn keyword luaFunc readfrom writeto appendto read write
188 syn keyword luaFunc PI abs sin cos tan asin
189 syn keyword luaFunc acos atan atan2 ceil floor
190 syn keyword luaFunc mod frexp ldexp sqrt min max log
191 syn keyword luaFunc log10 exp deg rad random
192 syn keyword luaFunc randomseed strlen strsub strlower strupper
193 syn keyword luaFunc strchar strrep ascii strbyte
194 syn keyword luaFunc format strfind gsub
195 syn keyword luaFunc getinfo getlocal setlocal setcallhook setlinehook
196elseif lua_version == 5
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100197 syn keyword luaFunc getmetatable setmetatable
198 syn keyword luaFunc ipairs pairs
199 syn keyword luaFunc pcall xpcall
200 syn keyword luaFunc _G loadfile rawequal require
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000201 if lua_subversion == 0
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100202 syn keyword luaFunc getfenv setfenv
203 syn keyword luaFunc loadstring unpack
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000204 syn keyword luaFunc gcinfo loadlib LUA_PATH _LOADED _REQUIREDNAME
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100205 else
206 syn keyword luaFunc load select
207 syn match luaFunc /\<package\.cpath\>/
208 syn match luaFunc /\<package\.loaded\>/
209 syn match luaFunc /\<package\.loadlib\>/
210 syn match luaFunc /\<package\.path\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100211 syn match luaFunc /\<package\.preload\>/
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100212 if lua_subversion == 1
213 syn keyword luaFunc getfenv setfenv
214 syn keyword luaFunc loadstring module unpack
215 syn match luaFunc /\<package\.loaders\>/
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100216 syn match luaFunc /\<package\.seeall\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100217 elseif lua_subversion >= 2
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100218 syn keyword luaFunc _ENV rawlen
219 syn match luaFunc /\<package\.config\>/
220 syn match luaFunc /\<package\.preload\>/
221 syn match luaFunc /\<package\.searchers\>/
222 syn match luaFunc /\<package\.searchpath\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100223 endif
224
225 if lua_subversion >= 3
226 syn match luaFunc /\<coroutine\.isyieldable\>/
227 endif
228 if lua_subversion >= 4
229 syn keyword luaFunc warn
230 syn match luaFunc /\<coroutine\.close\>/
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100231 endif
232 syn match luaFunc /\<coroutine\.running\>/
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000233 endif
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100234 syn match luaFunc /\<coroutine\.create\>/
235 syn match luaFunc /\<coroutine\.resume\>/
236 syn match luaFunc /\<coroutine\.status\>/
237 syn match luaFunc /\<coroutine\.wrap\>/
238 syn match luaFunc /\<coroutine\.yield\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100239
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100240 syn match luaFunc /\<string\.byte\>/
241 syn match luaFunc /\<string\.char\>/
242 syn match luaFunc /\<string\.dump\>/
243 syn match luaFunc /\<string\.find\>/
244 syn match luaFunc /\<string\.format\>/
245 syn match luaFunc /\<string\.gsub\>/
246 syn match luaFunc /\<string\.len\>/
247 syn match luaFunc /\<string\.lower\>/
248 syn match luaFunc /\<string\.rep\>/
249 syn match luaFunc /\<string\.sub\>/
250 syn match luaFunc /\<string\.upper\>/
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000251 if lua_subversion == 0
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100252 syn match luaFunc /\<string\.gfind\>/
253 else
254 syn match luaFunc /\<string\.gmatch\>/
255 syn match luaFunc /\<string\.match\>/
256 syn match luaFunc /\<string\.reverse\>/
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000257 endif
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100258 if lua_subversion >= 3
259 syn match luaFunc /\<string\.pack\>/
260 syn match luaFunc /\<string\.packsize\>/
261 syn match luaFunc /\<string\.unpack\>/
262 syn match luaFunc /\<utf8\.char\>/
263 syn match luaFunc /\<utf8\.charpattern\>/
264 syn match luaFunc /\<utf8\.codes\>/
265 syn match luaFunc /\<utf8\.codepoint\>/
266 syn match luaFunc /\<utf8\.len\>/
267 syn match luaFunc /\<utf8\.offset\>/
268 endif
269
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000270 if lua_subversion == 0
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100271 syn match luaFunc /\<table\.getn\>/
272 syn match luaFunc /\<table\.setn\>/
273 syn match luaFunc /\<table\.foreach\>/
274 syn match luaFunc /\<table\.foreachi\>/
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000275 elseif lua_subversion == 1
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100276 syn match luaFunc /\<table\.maxn\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100277 elseif lua_subversion >= 2
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100278 syn match luaFunc /\<table\.pack\>/
279 syn match luaFunc /\<table\.unpack\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100280 if lua_subversion >= 3
281 syn match luaFunc /\<table\.move\>/
282 endif
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000283 endif
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100284 syn match luaFunc /\<table\.concat\>/
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100285 syn match luaFunc /\<table\.insert\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100286 syn match luaFunc /\<table\.sort\>/
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100287 syn match luaFunc /\<table\.remove\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100288
289 if lua_subversion == 2
290 syn match luaFunc /\<bit32\.arshift\>/
291 syn match luaFunc /\<bit32\.band\>/
292 syn match luaFunc /\<bit32\.bnot\>/
293 syn match luaFunc /\<bit32\.bor\>/
294 syn match luaFunc /\<bit32\.btest\>/
295 syn match luaFunc /\<bit32\.bxor\>/
296 syn match luaFunc /\<bit32\.extract\>/
297 syn match luaFunc /\<bit32\.lrotate\>/
298 syn match luaFunc /\<bit32\.lshift\>/
299 syn match luaFunc /\<bit32\.replace\>/
300 syn match luaFunc /\<bit32\.rrotate\>/
301 syn match luaFunc /\<bit32\.rshift\>/
302 endif
303
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100304 syn match luaFunc /\<math\.abs\>/
305 syn match luaFunc /\<math\.acos\>/
306 syn match luaFunc /\<math\.asin\>/
307 syn match luaFunc /\<math\.atan\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100308 if lua_subversion < 3
309 syn match luaFunc /\<math\.atan2\>/
310 endif
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100311 syn match luaFunc /\<math\.ceil\>/
312 syn match luaFunc /\<math\.sin\>/
313 syn match luaFunc /\<math\.cos\>/
314 syn match luaFunc /\<math\.tan\>/
315 syn match luaFunc /\<math\.deg\>/
316 syn match luaFunc /\<math\.exp\>/
317 syn match luaFunc /\<math\.floor\>/
318 syn match luaFunc /\<math\.log\>/
319 syn match luaFunc /\<math\.max\>/
320 syn match luaFunc /\<math\.min\>/
321 if lua_subversion == 0
322 syn match luaFunc /\<math\.mod\>/
323 syn match luaFunc /\<math\.log10\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100324 elseif lua_subversion == 1
325 syn match luaFunc /\<math\.log10\>/
326 endif
327 if lua_subversion >= 1
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100328 syn match luaFunc /\<math\.huge\>/
329 syn match luaFunc /\<math\.fmod\>/
330 syn match luaFunc /\<math\.modf\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100331 if lua_subversion == 1 || lua_subversion == 2
332 syn match luaFunc /\<math\.cosh\>/
333 syn match luaFunc /\<math\.sinh\>/
334 syn match luaFunc /\<math\.tanh\>/
335 endif
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100336 endif
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100337 syn match luaFunc /\<math\.rad\>/
338 syn match luaFunc /\<math\.sqrt\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100339 if lua_subversion < 3
340 syn match luaFunc /\<math\.pow\>/
341 syn match luaFunc /\<math\.frexp\>/
342 syn match luaFunc /\<math\.ldexp\>/
343 else
344 syn match luaFunc /\<math\.maxinteger\>/
345 syn match luaFunc /\<math\.mininteger\>/
346 syn match luaFunc /\<math\.tointeger\>/
347 syn match luaFunc /\<math\.type\>/
348 syn match luaFunc /\<math\.ult\>/
349 endif
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100350 syn match luaFunc /\<math\.random\>/
351 syn match luaFunc /\<math\.randomseed\>/
352 syn match luaFunc /\<math\.pi\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100353
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100354 syn match luaFunc /\<io\.close\>/
355 syn match luaFunc /\<io\.flush\>/
356 syn match luaFunc /\<io\.input\>/
357 syn match luaFunc /\<io\.lines\>/
358 syn match luaFunc /\<io\.open\>/
359 syn match luaFunc /\<io\.output\>/
360 syn match luaFunc /\<io\.popen\>/
361 syn match luaFunc /\<io\.read\>/
362 syn match luaFunc /\<io\.stderr\>/
363 syn match luaFunc /\<io\.stdin\>/
364 syn match luaFunc /\<io\.stdout\>/
365 syn match luaFunc /\<io\.tmpfile\>/
366 syn match luaFunc /\<io\.type\>/
367 syn match luaFunc /\<io\.write\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100368
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100369 syn match luaFunc /\<os\.clock\>/
370 syn match luaFunc /\<os\.date\>/
371 syn match luaFunc /\<os\.difftime\>/
372 syn match luaFunc /\<os\.execute\>/
373 syn match luaFunc /\<os\.exit\>/
374 syn match luaFunc /\<os\.getenv\>/
375 syn match luaFunc /\<os\.remove\>/
376 syn match luaFunc /\<os\.rename\>/
377 syn match luaFunc /\<os\.setlocale\>/
378 syn match luaFunc /\<os\.time\>/
379 syn match luaFunc /\<os\.tmpname\>/
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100380
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100381 syn match luaFunc /\<debug\.debug\>/
382 syn match luaFunc /\<debug\.gethook\>/
383 syn match luaFunc /\<debug\.getinfo\>/
384 syn match luaFunc /\<debug\.getlocal\>/
385 syn match luaFunc /\<debug\.getupvalue\>/
386 syn match luaFunc /\<debug\.setlocal\>/
387 syn match luaFunc /\<debug\.setupvalue\>/
388 syn match luaFunc /\<debug\.sethook\>/
389 syn match luaFunc /\<debug\.traceback\>/
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000390 if lua_subversion == 1
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100391 syn match luaFunc /\<debug\.getfenv\>/
392 syn match luaFunc /\<debug\.setfenv\>/
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000393 endif
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100394 if lua_subversion >= 1
395 syn match luaFunc /\<debug\.getmetatable\>/
396 syn match luaFunc /\<debug\.setmetatable\>/
397 syn match luaFunc /\<debug\.getregistry\>/
398 if lua_subversion >= 2
399 syn match luaFunc /\<debug\.getuservalue\>/
400 syn match luaFunc /\<debug\.setuservalue\>/
401 syn match luaFunc /\<debug\.upvalueid\>/
402 syn match luaFunc /\<debug\.upvaluejoin\>/
403 endif
404 if lua_subversion >= 4
405 syn match luaFunc /\<debug.setcstacklimit\>/
406 endif
Bram Moolenaarcbaff5e2022-04-08 17:45:08 +0100407 endif
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000408endif
409
410" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200411" Only when an item doesn't have highlighting yet
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000412
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100413hi def link luaStatement Statement
414hi def link luaRepeat Repeat
415hi def link luaFor Repeat
416hi def link luaString String
417hi def link luaString2 String
418hi def link luaStringDelimiter luaString
419hi def link luaNumber Number
420hi def link luaOperator Operator
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100421hi def link luaSymbolOperator luaOperator
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100422hi def link luaConstant Constant
423hi def link luaCond Conditional
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100424hi def link luaCondElse Conditional
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100425hi def link luaFunction Function
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100426hi def link luaMetaMethod Function
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100427hi def link luaComment Comment
428hi def link luaCommentDelimiter luaComment
429hi def link luaTodo Todo
430hi def link luaTable Structure
431hi def link luaError Error
432hi def link luaParenError Error
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100433hi def link luaSpecial SpecialChar
434hi def link luaFunc Identifier
435hi def link luaLabel Label
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000436
Bram Moolenaarfc1421e2006-04-20 22:17:20 +0000437
438let b:current_syntax = "lua"
439
Bram Moolenaar5dc62522012-02-13 00:05:22 +0100440let &cpo = s:cpo_save
441unlet s:cpo_save
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100442" vim: et ts=8 sw=2