codekingpro/portable-devtools
115k
1" Vim syntax file2" Language: Lua 4.0, Lua 5.0, Lua 5.1, Lua 5.2 and Lua 5.33" Maintainer: Marcus Aurelius Farias <masserahguard-lua 'at' yahoo com>4" First Author: Carlos Augusto Teixeira Mendes <cmendes 'at' inf puc-rio br>5" Last Change: 2025 Feb 256" Options: lua_version = 4 or 57" 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.310 11" quit when a syntax file was already loaded12if exists("b:current_syntax")13 finish14endif15 16let s:cpo_save = &cpo17set cpo&vim18 19" keep in sync with ftplugin/lua.vim20if !exists("lua_version")21 " Default is lua 5.322 let lua_version = 523 let lua_subversion = 324elseif !exists("lua_subversion")25 " lua_version exists, but lua_subversion doesn't. In this case set it to 026 let lua_subversion = 027endif28 29syn case match30 31" syncing method32syn sync minlines=100033 34if lua_version >= 535 syn keyword luaMetaMethod __add __sub __mul __div __pow __unm __concat36 syn keyword luaMetaMethod __eq __lt __le37 syn keyword luaMetaMethod __index __newindex __call38 syn keyword luaMetaMethod __metatable __mode __gc __tostring39endif40 41if lua_version > 5 || (lua_version == 5 && lua_subversion >= 1)42 syn keyword luaMetaMethod __mod __len43endif44 45if lua_version > 5 || (lua_version == 5 && lua_subversion >= 2)46 syn keyword luaMetaMethod __pairs47endif48 49if lua_version > 5 || (lua_version == 5 && lua_subversion >= 3)50 syn keyword luaMetaMethod __idiv __name51 syn keyword luaMetaMethod __band __bor __bxor __bnot __shl __shr52endif53 54if lua_version > 5 || (lua_version == 5 && lua_subversion >= 4)55 syn keyword luaMetaMethod __close56endif57 58" catch errors caused by wrong parenthesis and wrong curly brackets or59" keywords placed outside their respective blocks60 61syn region luaParen transparent start='(' end=')' contains=TOP,luaParenError62syn match luaParenError ")"63syn match luaError "}"64syn match luaError "\<\%(end\|else\|elseif\|then\|until\|in\)\>"65 66" Function declaration67syn region luaFunctionBlock transparent matchgroup=luaFunction start="\<function\>" end="\<end\>" contains=TOP68 69" else70syn keyword luaCondElse matchgroup=luaCond contained containedin=luaCondEnd else71 72" then ... end73syn region luaCondEnd contained transparent matchgroup=luaCond start="\<then\>" end="\<end\>" contains=TOP74 75" elseif ... then76syn region luaCondElseif contained containedin=luaCondEnd transparent matchgroup=luaCond start="\<elseif\>" end="\<then\>" contains=TOP77 78" if ... then79syn region luaCondStart transparent matchgroup=luaCond start="\<if\>" end="\<then\>"me=e-4 contains=TOP nextgroup=luaCondEnd skipwhite skipempty80 81" do ... end82syn region luaBlock transparent matchgroup=luaStatement start="\<do\>" end="\<end\>" contains=TOP83" repeat ... until84syn region luaRepeatBlock transparent matchgroup=luaRepeat start="\<repeat\>" end="\<until\>" contains=TOP85 86" while ... do87syn region luaWhile transparent matchgroup=luaRepeat start="\<while\>" end="\<do\>"me=e-2 contains=TOP nextgroup=luaBlock skipwhite skipempty88 89" for ... do and for ... in ... do90syn region luaFor transparent matchgroup=luaRepeat start="\<for\>" end="\<do\>"me=e-2 contains=TOP nextgroup=luaBlock skipwhite skipempty91 92syn keyword luaFor contained containedin=luaFor in93 94" other keywords95syn keyword luaStatement return local break96if lua_version > 5 || (lua_version == 5 && lua_subversion >= 2)97 syn keyword luaStatement goto98 syn match luaLabel "::\I\i*::"99endif100 101" operators102syn keyword luaOperator and or not103 104if (lua_version == 5 && lua_subversion >= 3) || lua_version > 5105 syn match luaSymbolOperator "[#<>=~^&|*/%+-]\|\.\{2,3}"106elseif lua_version == 5 && (lua_subversion == 1 || lua_subversion == 2)107 syn match luaSymbolOperator "[#<>=~^*/%+-]\|\.\{2,3}"108else109 syn match luaSymbolOperator "[<>=~^*/+-]\|\.\{2,3}"110endif111 112" comments113syn keyword luaTodo contained TODO FIXME XXX114syn match luaComment "--.*$" contains=luaTodo,@Spell115if lua_version == 5 && lua_subversion == 0116 syn region luaComment matchgroup=luaCommentDelimiter start="--\[\[" end="\]\]" contains=luaTodo,luaInnerComment,@Spell117 syn region luaInnerComment contained transparent start="\[\[" end="\]\]"118elseif lua_version > 5 || (lua_version == 5 && lua_subversion >= 1)119 " Comments in Lua 5.1: --[[ ... ]], [=[ ... ]=], [===[ ... ]===], etc.120 syn region luaComment matchgroup=luaCommentDelimiter start="--\[\z(=*\)\[" end="\]\z1\]" contains=luaTodo,@Spell121endif122 123" first line may start with #!124syn match luaComment "\%^#!.*"125 126syn keyword luaConstant nil127if lua_version > 4128 syn keyword luaConstant true false129endif130 131" strings132syn match luaSpecial contained #\\[\\abfnrtv'"[\]]\|\\[[:digit:]]\{,3}#133if lua_version == 5134 if lua_subversion == 0135 syn region luaString2 matchgroup=luaStringDelimiter start=+\[\[+ end=+\]\]+ contains=luaString2,@Spell136 else137 if lua_subversion >= 2138 syn match luaSpecial contained #\\z\|\\x[[:xdigit:]]\{2}#139 endif140 if lua_subversion >= 3141 syn match luaSpecial contained #\\u{[[:xdigit:]]\+}#142 endif143 syn region luaString2 matchgroup=luaStringDelimiter start="\[\z(=*\)\[" end="\]\z1\]" contains=@Spell144 endif145endif146syn region luaString matchgroup=luaStringDelimiter start=+'+ end=+'+ skip=+\\\\\|\\'+ contains=luaSpecial,@Spell147syn region luaString matchgroup=luaStringDelimiter start=+"+ end=+"+ skip=+\\\\\|\\"+ contains=luaSpecial,@Spell148 149" integer number150syn match luaNumber "\<\d\+\>"151" floating point number, with dot, optional exponent152syn match luaNumber "\<\d\+\.\d*\%([eE][-+]\=\d\+\)\="153" floating point number, starting with a dot, optional exponent154syn match luaNumber "\.\d\+\%([eE][-+]\=\d\+\)\=\>"155" floating point number, without dot, with exponent156syn match luaNumber "\<\d\+[eE][-+]\=\d\+\>"157 158" hex numbers159if lua_version >= 5160 if lua_subversion == 1161 syn match luaNumber "\<0[xX]\x\+\>"162 elseif lua_subversion >= 2163 syn match luaNumber "\<0[xX][[:xdigit:].]\+\%([pP][-+]\=\d\+\)\=\>"164 endif165endif166 167" tables168syn region luaTableBlock transparent matchgroup=luaTable start="{" end="}" contains=TOP,luaStatement169 170" methods171syntax match luaFunc ":\@<=\k\+"172 173" built-in functions174syn keyword luaFunc assert collectgarbage dofile error next175syn keyword luaFunc print rawget rawset self tonumber tostring type _VERSION176 177if lua_version == 4178 syn keyword luaFunc _ALERT _ERRORMESSAGE gcinfo179 syn keyword luaFunc call copytagmethods dostring180 syn keyword luaFunc foreach foreachi getglobal getn181 syn keyword luaFunc gettagmethod globals newtag182 syn keyword luaFunc setglobal settag settagmethod sort183 syn keyword luaFunc tag tinsert tremove184 syn keyword luaFunc _INPUT _OUTPUT _STDIN _STDOUT _STDERR185 syn keyword luaFunc openfile closefile flush seek186 syn keyword luaFunc setlocale execute remove rename tmpname187 syn keyword luaFunc getenv date clock exit188 syn keyword luaFunc readfrom writeto appendto read write189 syn keyword luaFunc PI abs sin cos tan asin190 syn keyword luaFunc acos atan atan2 ceil floor191 syn keyword luaFunc mod frexp ldexp sqrt min max log192 syn keyword luaFunc log10 exp deg rad random193 syn keyword luaFunc randomseed strlen strsub strlower strupper194 syn keyword luaFunc strchar strrep ascii strbyte195 syn keyword luaFunc format strfind gsub196 syn keyword luaFunc getinfo getlocal setlocal setcallhook setlinehook197elseif lua_version == 5198 syn keyword luaFunc getmetatable setmetatable199 syn keyword luaFunc ipairs pairs200 syn keyword luaFunc pcall xpcall201 syn keyword luaFunc _G loadfile rawequal require202 if lua_subversion == 0203 syn keyword luaFunc getfenv setfenv204 syn keyword luaFunc loadstring unpack205 syn keyword luaFunc gcinfo loadlib LUA_PATH _LOADED _REQUIREDNAME206 else207 syn keyword luaFunc load select208 syn match luaFunc /\<package\.cpath\>/209 syn match luaFunc /\<package\.loaded\>/210 syn match luaFunc /\<package\.loadlib\>/211 syn match luaFunc /\<package\.path\>/212 syn match luaFunc /\<package\.preload\>/213 if lua_subversion == 1214 syn keyword luaFunc getfenv setfenv215 syn keyword luaFunc loadstring module unpack216 syn match luaFunc /\<package\.loaders\>/217 syn match luaFunc /\<package\.seeall\>/218 elseif lua_subversion >= 2219 syn keyword luaFunc _ENV rawlen220 syn match luaFunc /\<package\.config\>/221 syn match luaFunc /\<package\.preload\>/222 syn match luaFunc /\<package\.searchers\>/223 syn match luaFunc /\<package\.searchpath\>/224 endif225 226 if lua_subversion >= 3227 syn match luaFunc /\<coroutine\.isyieldable\>/228 endif229 if lua_subversion >= 4230 syn keyword luaFunc warn231 syn match luaFunc /\<coroutine\.close\>/232 endif233 syn match luaFunc /\<coroutine\.running\>/234 endif235 syn match luaFunc /\<coroutine\.create\>/236 syn match luaFunc /\<coroutine\.resume\>/237 syn match luaFunc /\<coroutine\.status\>/238 syn match luaFunc /\<coroutine\.wrap\>/239 syn match luaFunc /\<coroutine\.yield\>/240 241 syn match luaFunc /\<string\.byte\>/242 syn match luaFunc /\<string\.char\>/243 syn match luaFunc /\<string\.dump\>/244 syn match luaFunc /\<string\.find\>/245 syn match luaFunc /\<string\.format\>/246 syn match luaFunc /\<string\.gsub\>/247 syn match luaFunc /\<string\.len\>/248 syn match luaFunc /\<string\.lower\>/249 syn match luaFunc /\<string\.rep\>/250 syn match luaFunc /\<string\.sub\>/251 syn match luaFunc /\<string\.upper\>/252 if lua_subversion == 0253 syn match luaFunc /\<string\.gfind\>/254 else255 syn match luaFunc /\<string\.gmatch\>/256 syn match luaFunc /\<string\.match\>/257 syn match luaFunc /\<string\.reverse\>/258 endif259 if lua_subversion >= 3260 syn match luaFunc /\<string\.pack\>/261 syn match luaFunc /\<string\.packsize\>/262 syn match luaFunc /\<string\.unpack\>/263 syn match luaFunc /\<utf8\.char\>/264 syn match luaFunc /\<utf8\.charpattern\>/265 syn match luaFunc /\<utf8\.codes\>/266 syn match luaFunc /\<utf8\.codepoint\>/267 syn match luaFunc /\<utf8\.len\>/268 syn match luaFunc /\<utf8\.offset\>/269 endif270 271 if lua_subversion == 0272 syn match luaFunc /\<table\.getn\>/273 syn match luaFunc /\<table\.setn\>/274 syn match luaFunc /\<table\.foreach\>/275 syn match luaFunc /\<table\.foreachi\>/276 elseif lua_subversion == 1277 syn match luaFunc /\<table\.maxn\>/278 elseif lua_subversion >= 2279 syn match luaFunc /\<table\.pack\>/280 syn match luaFunc /\<table\.unpack\>/281 if lua_subversion >= 3282 syn match luaFunc /\<table\.move\>/283 endif284 endif285 syn match luaFunc /\<table\.concat\>/286 syn match luaFunc /\<table\.insert\>/287 syn match luaFunc /\<table\.sort\>/288 syn match luaFunc /\<table\.remove\>/289 290 if lua_subversion == 2291 syn match luaFunc /\<bit32\.arshift\>/292 syn match luaFunc /\<bit32\.band\>/293 syn match luaFunc /\<bit32\.bnot\>/294 syn match luaFunc /\<bit32\.bor\>/295 syn match luaFunc /\<bit32\.btest\>/296 syn match luaFunc /\<bit32\.bxor\>/297 syn match luaFunc /\<bit32\.extract\>/298 syn match luaFunc /\<bit32\.lrotate\>/299 syn match luaFunc /\<bit32\.lshift\>/300 syn match luaFunc /\<bit32\.replace\>/301 syn match luaFunc /\<bit32\.rrotate\>/302 syn match luaFunc /\<bit32\.rshift\>/303 endif304 305 syn match luaFunc /\<math\.abs\>/306 syn match luaFunc /\<math\.acos\>/307 syn match luaFunc /\<math\.asin\>/308 syn match luaFunc /\<math\.atan\>/309 if lua_subversion < 3310 syn match luaFunc /\<math\.atan2\>/311 endif312 syn match luaFunc /\<math\.ceil\>/313 syn match luaFunc /\<math\.sin\>/314 syn match luaFunc /\<math\.cos\>/315 syn match luaFunc /\<math\.tan\>/316 syn match luaFunc /\<math\.deg\>/317 syn match luaFunc /\<math\.exp\>/318 syn match luaFunc /\<math\.floor\>/319 syn match luaFunc /\<math\.log\>/320 syn match luaFunc /\<math\.max\>/321 syn match luaFunc /\<math\.min\>/322 if lua_subversion == 0323 syn match luaFunc /\<math\.mod\>/324 syn match luaFunc /\<math\.log10\>/325 elseif lua_subversion == 1326 syn match luaFunc /\<math\.log10\>/327 endif328 if lua_subversion >= 1329 syn match luaFunc /\<math\.huge\>/330 syn match luaFunc /\<math\.fmod\>/331 syn match luaFunc /\<math\.modf\>/332 if lua_subversion == 1 || lua_subversion == 2333 syn match luaFunc /\<math\.cosh\>/334 syn match luaFunc /\<math\.sinh\>/335 syn match luaFunc /\<math\.tanh\>/336 endif337 endif338 syn match luaFunc /\<math\.rad\>/339 syn match luaFunc /\<math\.sqrt\>/340 if lua_subversion < 3341 syn match luaFunc /\<math\.pow\>/342 syn match luaFunc /\<math\.frexp\>/343 syn match luaFunc /\<math\.ldexp\>/344 else345 syn match luaFunc /\<math\.maxinteger\>/346 syn match luaFunc /\<math\.mininteger\>/347 syn match luaFunc /\<math\.tointeger\>/348 syn match luaFunc /\<math\.type\>/349 syn match luaFunc /\<math\.ult\>/350 endif351 syn match luaFunc /\<math\.random\>/352 syn match luaFunc /\<math\.randomseed\>/353 syn match luaFunc /\<math\.pi\>/354 355 syn match luaFunc /\<io\.close\>/356 syn match luaFunc /\<io\.flush\>/357 syn match luaFunc /\<io\.input\>/358 syn match luaFunc /\<io\.lines\>/359 syn match luaFunc /\<io\.open\>/360 syn match luaFunc /\<io\.output\>/361 syn match luaFunc /\<io\.popen\>/362 syn match luaFunc /\<io\.read\>/363 syn match luaFunc /\<io\.stderr\>/364 syn match luaFunc /\<io\.stdin\>/365 syn match luaFunc /\<io\.stdout\>/366 syn match luaFunc /\<io\.tmpfile\>/367 syn match luaFunc /\<io\.type\>/368 syn match luaFunc /\<io\.write\>/369 370 syn match luaFunc /\<os\.clock\>/371 syn match luaFunc /\<os\.date\>/372 syn match luaFunc /\<os\.difftime\>/373 syn match luaFunc /\<os\.execute\>/374 syn match luaFunc /\<os\.exit\>/375 syn match luaFunc /\<os\.getenv\>/376 syn match luaFunc /\<os\.remove\>/377 syn match luaFunc /\<os\.rename\>/378 syn match luaFunc /\<os\.setlocale\>/379 syn match luaFunc /\<os\.time\>/380 syn match luaFunc /\<os\.tmpname\>/381 382 syn match luaFunc /\<debug\.debug\>/383 syn match luaFunc /\<debug\.gethook\>/384 syn match luaFunc /\<debug\.getinfo\>/385 syn match luaFunc /\<debug\.getlocal\>/386 syn match luaFunc /\<debug\.getupvalue\>/387 syn match luaFunc /\<debug\.setlocal\>/388 syn match luaFunc /\<debug\.setupvalue\>/389 syn match luaFunc /\<debug\.sethook\>/390 syn match luaFunc /\<debug\.traceback\>/391 if lua_subversion == 1392 syn match luaFunc /\<debug\.getfenv\>/393 syn match luaFunc /\<debug\.setfenv\>/394 endif395 if lua_subversion >= 1396 syn match luaFunc /\<debug\.getmetatable\>/397 syn match luaFunc /\<debug\.setmetatable\>/398 syn match luaFunc /\<debug\.getregistry\>/399 if lua_subversion >= 2400 syn match luaFunc /\<debug\.getuservalue\>/401 syn match luaFunc /\<debug\.setuservalue\>/402 syn match luaFunc /\<debug\.upvalueid\>/403 syn match luaFunc /\<debug\.upvaluejoin\>/404 endif405 if lua_subversion >= 4406 syn match luaFunc /\<debug.setcstacklimit\>/407 endif408 endif409endif410 411" Define the default highlighting.412" Only when an item doesn't have highlighting yet413 414hi def link luaStatement Statement415hi def link luaRepeat Repeat416hi def link luaFor Repeat417hi def link luaString String418hi def link luaString2 String419hi def link luaStringDelimiter luaString420hi def link luaNumber Number421hi def link luaOperator Operator422hi def link luaSymbolOperator luaOperator423hi def link luaConstant Constant424hi def link luaCond Conditional425hi def link luaCondElse Conditional426hi def link luaFunction Function427hi def link luaMetaMethod Function428hi def link luaComment Comment429hi def link luaCommentDelimiter luaComment430hi def link luaTodo Todo431hi def link luaTable Structure432hi def link luaError Error433hi def link luaParenError Error434hi def link luaSpecial SpecialChar435hi def link luaFunc Identifier436hi def link luaLabel Label437 438 439let b:current_syntax = "lua"440 441let &cpo = s:cpo_save442unlet s:cpo_save443" vim: et ts=8 sw=2444 