robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
0639f6e41a
master
1" Vim syntax file 2" Language: Luau 3" Maintainer: Lopy (@lopi-py) 4" Last Change: 2026 Jun 17 5 6" quit when a syntax file was already loaded 7if exists ( "b:current_syntax" ) 8finish 9endif 10 11let s: cpo_save = & cpo 12set cpo & vim 13 14syn case match 15syn sync minlines= 300 16 17" comments 18syn keyword luauTodo contained TODO FIXME 19syn match luauDirective contained "--!\%(strict\|nonstrict\|nocheck\|nolint\%(Global\)\=\|native\|optimize\)\>. * " 20 21" strings 22syn match luauSpecial contained #\\ [ [:digit: ] ]\{1,3}\|\\x [ [:xdigit: ] ]\{2}\|\\u{ [ [:xdigit: ] ]\+}\|\\z\s * \|\\\n\|\\ [ ^xu[:digit: ] \r\n] # 23syn region luauString2 matchgroup = luauStringDelimiter start = "\[\z(= * \)\[ "end = "\]\z1\] "contains = @Spell 24syn region luauString matchgroup = luauStringDelimiter start = +' +end = +' + skip=+\\\\\|\\'+ contains =luauSpecial,@Spell 25syn region luauString matchgroup = luauStringDelimiter start = +" +end = +" + skip=+\\\\\|\\"+ contains =luauSpecial,@Spell 26syn region luauInterpString matchgroup = luauStringDelimiter start = +` +end = +` + skip=+\\`+ contains =luauSpecial,luauInterp ,@Spell 27syn region luauInterp contained transparent matchgroup = luauInterpDelimiter start = +\\\@<!{ +end = +} +contains = TOP , luauInterpBlock 28syn region luauInterpBlock contained transparent start = +{ +end = +} +contains = TOP , luauInterpBlock 29 30" numbers 31syn match luauNumber "\<0_ * [ xX ][ [:xdigit: ] _] * [ [:xdigit: ] ] [ [:xdigit: ] _] * \> " 32syn match luauNumber "\<0_ * [ bB ][ 01_ ] * [ 01 ][ 01_ ] * \> " 33syn match luauNumber "\<\d [ [:digit: ] _] * \%(\. [ [:digit: ] _] * \)\=\%( [ eE ][ -+ ] \= [ [:digit: ] _] * \d [ [:digit: ] _] * \)\=\> " 34syn match luauNumber "\.\d [ [:digit: ] _] * \%( [ eE ][ -+ ] \= [ [:digit: ] _] * \d [ [:digit: ] _] * \)\=\> " 35 36" keywords 37syn keyword luauStatement return local break end 38syn keyword luauStatement do nextgroup = luauStatement skipwhite 39syn keyword luauStatement contained continue 40syn match luauStatement "^\s * \zscontinue\>\ze\s * \%(;\|end\>\|else\>\|elseif\>\|until\>\|--. * \|$\) " 41syn match luauStatement ";\s * \zscontinue\>\ze\s * \%(;\|end\>\|else\>\|elseif\>\|until\>\|--. * \|$\) " 42syn keyword luauFunction function nextgroup = luauFunctionName , luauGenericParams skipwhite 43syn match luauStatement "^\s * \%(@\%(\h\w * \|\[ [ ^ ] ] * \]\)\s * \) * \zsconst\>\ze\s\+\%(function\>\|\h\) " 44syn match luauStatement "^\s * \%(@\%(\h\w * \|\[ [ ^ ] ] * \]\)\s * \) * \zsdeclare\>\ze\s\+\%(function\>\|class\>\s\+\h\|extern\s\+type\>\|\h\w * \s * :\) "nextgroup = luauStatement , luauDeclareName , luauFunction skipwhite 45syn match luauStatement contained "\<class\>\ze\s\+\h "nextgroup = luauTypedef skipwhite 46syn match luauDeclareName contained "\h\w * \ze\s * : "nextgroup = luauTypeColon skipwhite 47syn match luauStatement "\<export\>\ze\s\+type\> " 48syn match luauStatement contained "\<extern\>\ze\s\+type\> " 49syn match luauStatement "\<extends\>\ze\s\+\h "nextgroup = luauTypeName skipwhite 50syn match luauStatement "\<with\>\ze\s * \%(--. * \)\=$ " 51syn match luauModifier "\<public\>\ze\s\+\%(function\|\h\) " 52syn match luauTypeKeyword "\<type\>\ze\s\+\h "nextgroup = luauTypeFunction , luauTypedef skipwhite 53syn keyword luauTypeFunction contained function nextgroup = luauFunctionName skipwhite 54syn match luauFunctionName contained transparent "\h\w * \%( [ .: ] \h\w * \) * "nextgroup = luauGenericParams skipwhite 55syn keyword luauCond if elseif 56syn keyword luauCond then else nextgroup = luauStatement skipwhite 57syn keyword luauRepeat while for until in 58syn keyword luauRepeat repeat nextgroup = luauStatement skipwhite 59syn keyword luauOperator and or not 60 61" operators and punctuation 62syn match luauSymbolOperator "[ #+*/%^=<>~?- ] \|\.\{3}\|\.\.=\= " 63syn match luauSymbolOperator "-> "nextgroup = luauSymbolOperator , luauConstant , luauTableType , luauTypePack , luauTypeName skipwhite 64syn match luauSymbolOperator "[ |& ] "nextgroup = luauConstant , luauTableType , luauTypePack , luauTypeName skipwhite 65syn match luauSymbolOperator ":: " 66 67" tables 68syn region luauTableBlock transparent matchgroup = luauTable start = "{ "end = "} "contains = TOP , luauStatement 69 70syn match luauComment "--. * $ "contains = luauTodo , luauDirective , @Spell 71syn region luauComment matchgroup = luauCommentDelimiter start = "--\[\z(= * \)\[ "end = "\]\z1\] "contains = luauTodo , @Spell 72 73" the first line may start with #! 74syn match luauComment "\%^#!. * " 75 76" attributes 77syn match luauAttribute "@\h\w * " 78syn region luauAttributeBlock matchgroup = luauAttributeDelimiter start = "@\[ "end = "\] "contains = luauAttributeName , luauAttributeTable , luauString , luauString2 , luauInterpString , luauNumber , luauConstant 79syn region luauAttributeTable contained transparent matchgroup = luauTable start = "{ "end = "} "contains = luauAttributeTable , luauString , luauString2 , luauInterpString , luauNumber , luauConstant , luauSymbolOperator 80syn keyword luauAttributeName contained checked native deprecated 81 82" constants and types 83syn keyword luauConstant nil true false 84syn match luauConstant "\.\.\. " 85syn keyword luauSelf self 86syn match luauSelf contained "(\s * \zsself\>\ze\s * : " 87syn cluster luauTypeCommon contains = luauGenericParams , luauString , luauString2 , luauInterpString , luauNumber , luauConstant , luauSymbolOperator 88syn cluster luauTypeExpr contains = luauFunctionTypeParams , luauTableType , luauTypeParam , luauType , luauTypeKeyword , @luauTypeCommon 89syn region luauGenericParams contained transparent matchgroup = luauSymbolOperator start = "< "end = "> "contains = @luauTypeExpr 90syn region luauTypedefGenericParams contained transparent matchgroup = luauSymbolOperator start = "< "end = "> "contains = @luauTypeExpr nextgroup = luauTypeAliasAssign skipwhite 91syn region luauExplicitTypeArgs transparent matchgroup = luauSymbolOperator start = "<< "end = ">> "contains = @luauTypeExpr 92syn match luauTypeParam contained "\h\w * \%(\.\.\.\)\= " 93syn match luauTypedef "\h\w * "contained nextgroup = luauTypedefGenericParams , luauTypeAliasAssign skipwhite 94syn match luauTypeAliasAssign contained "= "nextgroup = luauSymbolOperator , luauConstant , luauTableType , luauTypeName skipwhite 95syn region luauTableType contained transparent matchgroup = luauTable start = "{ "end = "} "contains = luauFunctionTypeParams , luauTableType , luauSelf , luauTypeIndexer , luauTableElementType , luauTypeColon , luauTypeKeyword , @luauTypeCommon 96syn match luauTypeIndexer "^\s * \[\s * "nextgroup = luauType skipwhite 97syn match luauTypeIndexer contained transparent "\[\s * "nextgroup = luauType skipwhite 98syn match luauType contained "\h\w * \%(\.\h\w * \) * \ze\s * \]\s * : "nextgroup = luauGenericParams skipwhite 99syn match luauTableElementType contained "\h\w * \%(\.\h\w * \) * \ze\s * [ <?|&,;}) ] "nextgroup = luauGenericParams skipwhite 100syn match luauTypeColon transparent ": "nextgroup = luauSymbolOperator , luauConstant , luauTableType , luauTypeAfterColon skipwhite 101syn match luauTypeAfterColon contained "\h\w * \%(\.\h\w * \) * \%(\.\.\.\)\=\ze\s * \%( [ ?=},)\]|& ] \|,\|<\|->\|$\) "nextgroup = luauGenericParams skipwhite 102syn region luauFunctionTypeParams transparent start = "(\ze\%( [ ^() ] * \))\s * -> "end = ")\ze\s * -> "contains = luauFunctionTypeParam , luauTypeColon , luauSelf , @luauTypeCommon 103syn match luauFunctionTypeParam contained "\h\w * \%(\.\h\w * \) * \%(\.\.\.\)\=\ze\s * ?\=\s * [ ,)|& ] "nextgroup = luauGenericParams skipwhite 104syn match luauFunctionReturnStart transparent ")\s * :\s * "nextgroup = luauSymbolOperator , luauFunctionTypeParams , luauConstant , luauTableType , luauTypePack , luauTypeName skipwhite 105syn region luauTypePack contained transparent start = "(\%( [ ^() ] * )\s * ->\)\@! "end = ") "contains = luauFunctionTypeParams , luauTableType , luauTypeName , @luauTypeCommon 106syn match luauTypeName contained "\h\w * \%(\.\h\w * \) * \%(\.\.\.\)\= "nextgroup = luauGenericParams skipwhite 107syn match luauTypeKeyword "\<\%(read\|write\)\>\ze\s * \%(\[\|\h\+\s * :\) "nextgroup = luauTypeIndexer skipwhite 108 109" metamethods 110syn keyword luauMetaMethod __index __newindex __mode __namecall __call __iter __len 111syn keyword luauMetaMethod __eq __add __sub __mul __div __idiv __mod __pow __unm 112syn keyword luauMetaMethod __lt __le __concat __type __metatable __tostring 113 114" methods 115syn match luauMethodColon transparent ":\ze\s * \h\w * \s * \%(<<.\{-}>>\s * \|< [ ^> ] * >\s * \)\=\%((\|{\|'\|\"\|\[\) "nextgroup = luauFunc skipwhite 116syn match luauFunc contained "\h\w * \ze\s * \%(<<.\{-}>>\s * \|< [ ^> ] * >\s * \)\=\%((\|{\|'\|\"\|\[\) " 117 118" global functions and values 119syn keyword luauFunc assert error gcinfo getfenv getmetatable 120syn keyword luauFunc ipairs loadstring newproxy next pairs pcall syn keyword luauFunc rawequal rawget rawlen rawset require select setfenv 122syn keyword luauFunc setmetatable tonumber tostring unpack xpcall 123syn keyword luauGlobal _G 124syn keyword luauBuiltinConstant _VERSION 125syn match luauFunc "\<type\>\ze\s * \%(<<.\{-}>>\s * \)\=( " 126syn match luauFunc "\<typeof\>\ze\s * \%(<<.\{-}>>\s * \)\=( " 127 128" standard library members 129syn match luauFunc /\<bit32\.\%(arshift\|band\|bnot\|bor\|btest\|bxor\|byteswap\|countlz\|countrz\|extract\|lrotate\|lshift\|replace\|rrotate\|rshift\)\> / 130syn match luauFunc /\<buffer\.\%(copy\|create\|fill\|fromstring\|len\|readbits\|readf32\|readf64\|readi16\|readi32\|readi8\|readstring\|readu16\|readu32\|readu8\)\> / 131syn match luauFunc /\<buffer\.\%(tostring\|writebits\|writef32\|writef64\|writei16\|writei32\|writei8\|writestring\|writeu16\|writeu32\|writeu8\)\> / 132syn match luauFunc /\<coroutine\.\%(close\|create\|isyieldable\|resume\|running\|status\|wrap\|yield\)\> / 133syn match luauFunc /\<debug\.\%(info\|traceback\)\> / 134syn match luauFunc /\<math\.\%(abs\|acos\|asin\|atan2\=\|ceil\|clamp\|cosh\=\|deg\|exp\|floor\|fmod\|frexp\)\> / 135syn match luauFunc /\<math\.\%(isfinite\|isinf\|isnan\|ldexp\|lerp\|log\|log10\|map\|max\|min\|modf\|noise\)\> / 136syn match luauFunc /\<math\.\%(pow\|rad\|random\%(seed\)\=\|round\|sign\|sinh\=\|sqrt\|tanh\=\)\> / 137syn match luauBuiltinConstant /\<math\.\%(huge\|pi\)\> / 138syn match luauFunc /\<os\.\%(clock\|date\|difftime\|time\)\> / 139syn match luauFunc /\<string\.\%(byte\|char\|find\|format\|gmatch\|gsub\|len\|lower\|match\|pack\%(size\)\=\|rep\|reverse\|split\|sub\|unpack\|upper\)\> / 140syn match luauFunc /\<table\.\%(clear\|clone\|concat\|create\|find\|foreachi\=\|freeze\|getn\|insert\|isfrozen\|maxn\|move\|pack\|remove\|sort\|unpack\)\> / 141syn match luauFunc /\<utf8\.\%(char\|codepoint\|codes\|len\|offset\)\> / 142syn match luauBuiltinConstant /\<utf8\.charpattern\> / 143syn match luauFunc /\<vector\.\%(abs\|angle\|ceil\|clamp\|create\|cross\|dot\|floor\|lerp\|magnitude\|max\|min\|normalize\|sign\)\> / 144syn match luauBuiltinConstant /\<vector\.\%(one\|zero\)\> / 145syn match luauFunc /\<types\.\%(any\|boolean\|buffer\|copy\|generic\|intersectionof\|never\|negationof\|newfunction\|newtable\|number\|optional\|singleton\|string\|thread\|unionof\|unknown\)\> / 146 147" define the default highlighting 148hi def link luauStatement Statement 149hi def link luauRepeat Repeat 150hi def link luauString String 151hi def link luauString2 String 152hi def link luauInterpString String 153hi def link luauStringDelimiter luauString 154hi def link luauInterpDelimiter Special 155hi def link luauNumber Number 156hi def link luauOperator Operator 157hi def link luauSymbolOperator luauOperator 158hi def link luauConstant Constant 159hi def link luauCond Conditional 160hi def link luauFunction Function 161hi def link luauMetaMethod Function 162hi def link luauTable Structure 163hi def link luauComment Comment 164hi def link luauCommentDelimiter luauComment 165hi def link luauDirective PreProc 166hi def link luauTodo Todo 167hi def link luauSpecial SpecialChar 168hi def link luauFunc Identifier 169hi def link luauGlobal Identifier 170hi def link luauBuiltinConstant Constant 171hi def link luauSelf Identifier 172hi def link luauModifier StorageClass 173hi def link luauType Type 174hi def link luauTypeAfterColon luauType 175hi def link luauTableElementType luauType 176hi def link luauTypeAliasAssign luauSymbolOperator 177hi def link luauFunctionTypeParam luauType 178hi def link luauTypeName luauType 179hi def link luauTypedef Typedef 180hi def link luauTypeParam Type 181hi def link luauTypeKeyword Keyword 182hi def link luauTypeFunction luauFunction 183hi def link luauDeclareName Identifier 184hi def link luauAttribute PreProc 185hi def link luauAttributeName PreProc 186hi def link luauAttributeDelimiter PreProc 187 188let b: current_syntax = "luau" 189 190let & cpo = s: cpo_save 191unlet s: cpo_save 192 193" vim: nowrap sw=2 sts=2 ts=8 noet: