robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
a412a4a846
master
1" Vim syntax file 2" Language: Zig 3" Upstream: https://codeberg.org/ziglang/zig.vim 4 5if exists ( "b:current_syntax" ) 6finish 7endif 8 9let s: cpo_save = & cpo 10set cpo & vim 11 12let s: zig_syntax_keywords = { 13 \'zigBoolean' : [ "true" 14 \, "false" ] 15 \, 'zigNull' : [ "null" ] 16 \, 'zigType' : [ "bool" 17 \, "f16" 18 \, "f32" 19 \, "f64" 20 \, "f80" 21 \, "f128" 22 \, "void" 23 \, "type" 24 \, "anytype" 25 \, "anyerror" 26 \, "anyframe" 27 \, "volatile" 28 \, "linksection" 29 \, "noreturn" 30 \, "allowzero" 31 \, "i0" 32 \, "u0" 33 \, "isize" 34 \, "usize" 35 \, "comptime_int" 36 \, "comptime_float" 37 \, "c_char" 38 \, "c_short" 39 \, "c_ushort" 40 \, "c_int" 41 \, "c_uint" 42 \, "c_long" 43 \, "c_ulong" 44 \, "c_longlong" 45 \, "c_ulonglong" 46 \, "c_longdouble" 47 \, "anyopaque" ] 48 \, 'zigConstant' : [ "undefined" 49 \, "unreachable" ] 50 \, 'zigConditional' : [ "if" 51 \, "else" 52 \, "switch" ] 53 \, 'zigRepeat' : [ "while" 54 \, "for" ] 55 \, 'zigComparatorWord' : [ "and" 56 \, "or" 57 \, "orelse" ] 58 \, 'zigStructure' : [ "struct" 59 \, "enum" 60 \, "union" 61 \, "error" 62 \, "packed" 63 \, "opaque" ] 64 \, 'zigException' : [ "error" ] 65 \, 'zigVarDecl' : [ "var" 66 \, "const" 67 \, "comptime" 68 \, "threadlocal" ] 69 \, 'zigDummyVariable' : [ "_" ] 70 \, 'zigKeyword' : [ "fn" 71 \, "try" 72 \, "test" 73 \, "pub" 74 \, "usingnamespace" ] 75 \, 'zigExecution' : [ "return" 76 \, "break" 77 \, "continue" ] 78 \, 'zigMacro' : [ "defer" 79 \, "errdefer" 80 \, "async" 81 \, "nosuspend" 82 \, "await" 83 \, "suspend" 84 \, "resume" 85 \, "export" 86 \, "extern" ] 87 \, 'zigPreProc' : [ "catch" 88 \, "inline" 89 \, "noinline" 90 \, "asm" 91 \, "callconv" 92 \, "noalias" ] 93 \, 'zigBuiltinFn' : [ "align" 94 \, "@addWithOverflow" 95 \, "@as" 96 \, "@atomicLoad" 97 \, "@atomicStore" 98 \, "@bitCast" 99 \, "@breakpoint" 100 \, "@trap" 101 \, "@alignCast" 102 \, "@alignOf" 103 \, "@cDefine" 104 \, "@cImport" 105 \, "@cInclude" 106 \, "@cUndef" 107 \, "@clz" 108 \, "@cmpxchgWeak" 109 \, "@cmpxchgStrong" 110 \, "@compileError" 111 \, "@compileLog" 112 \, "@constCast" 113 \, "@ctz" 114 \, "@popCount" 115 \, "@divExact" 116 \, "@divFloor" 117 \, "@divTrunc" 118 \, "@embedFile" 119 \, "@export" 120 \, "@extern" 121 \, "@tagName" 122 \, "@TagType" 123 \, "@errorName" 124 \, "@call" 125 \, "@errorReturnTrace" 126 \, "@fence" 127 \, "@fieldParentPtr" 128 \, "@field" 129 \, "@unionInit" 130 \, "@frameAddress" 131 \, "@import" 132 \, "@inComptime" 133 \, "@newStackCall" 134 \, "@asyncCall" 135 \, "@ptrFromInt" 136 \, "@max" 137 \, "@min" 138 \, "@memcpy" 139 \, "@memset" 140 \, "@mod" 141 \, "@mulAdd" 142 \, "@mulWithOverflow" 143 \, "@splat" 144 \, "@src" 145 \, "@bitOffsetOf" 146 \, "@byteOffsetOf" 147 \, "@offsetOf" 148 \, "@OpaqueType" 149 \, "@panic" 150 \, "@prefetch" 151 \, "@ptrCast" 152 \, "@intFromPtr" 153 \, "@rem" 154 \, "@returnAddress" 155 \, "@setCold" 156 \, "@Type" 157 \, "@shuffle" 158 \, "@reduce" 159 \, "@select" 160 \, "@setRuntimeSafety" 161 \, "@setEvalBranchQuota" 162 \, "@setFloatMode" 163 \, "@shlExact" 164 \, "@This" 165 \, "@hasDecl" 166 \, "@hasField" 167 \, "@shlWithOverflow" 168 \, "@shrExact" 169 \, "@sizeOf" 170 \, "@bitSizeOf" 171 \, "@sqrt" 172 \, "@byteSwap" 173 \, "@subWithOverflow" 174 \, "@intCast" 175 \, "@floatCast" 176 \, "@floatFromInt" 177 \, "@intFromFloat" 178 \, "@intFromBool" 179 \, "@errorCast" 180 \, "@truncate" 181 \, "@typeInfo" 182 \, "@typeName" 183 \, "@TypeOf" 184 \, "@atomicRmw" 185 \, "@errorFromInt" 186 \, "@intFromError" 187 \, "@enumFromInt" 188 \, "@intFromEnum" 189 \, "@setAlignStack" 190 \, "@frame" 191 \, "@Frame" 192 \, "@frameSize" 193 \, "@bitReverse" 194 \, "@Vector" 195 \, "@volatileCast" 196 \, "@sin" 197 \, "@cos" 198 \, "@tan" 199 \, "@exp" 200 \, "@exp2" 201 \, "@log" 202 \, "@log2" 203 \, "@log10" 204 \, "@abs" 205 \, "@floor" 206 \, "@ceil" 207 \, "@trunc" 208 \, "@wasmMemorySize" 209 \, "@wasmMemoryGrow" 210 \, "@round" ] 211 \} 212 213function ! s: syntax_keyword ( dict ) 214for key in keys ( a: dict ) 215execute 'syntax keyword' key join ( a: dict [ key ], ' ' ) 216endfor 217endfunction 218 219call s: syntax_keyword ( s: zig_syntax_keywords ) 220 221syntax match zigType "\v< [ iu ][ 1-9 ] \d * > " 222syntax match zigOperator display "\V\[-+/ * =^&?|!><%~] " 223syntax match zigArrowCharacter display "\V-> " 224 225" 12_34 (. but not ..)? (12_34)? (exponent 12_34)? 226syntax match zigDecNumber display "\v<\d%(_?\d) * %(\.\.@!)?%(\d%(_?\d) * )?%( [ eE ][ +- ] ?\d%(_?\d) * )? " 227syntax match zigHexNumber display "\v<0x\x%(_?\x) * %(\.\.@!)?%(\x%(_?\x) * )?%( [ pP ][ +- ] ?\d%(_?\d) * )? " 228syntax match zigOctNumber display "\v<0o\o%(_?\o) * " 229syntax match zigBinNumber display "\v<0b [ 01 ] %(_? [ 01 ] ) * " 230 231syntax match zigCharacterInvalid display contained /b\?'\zs [ \n\r\t' ] \ze' / 232syntax match zigCharacterInvalidUnicode display contained /b'\zs [ ^[:cntrl: ][ :graph: ][ :alnum: ][ :space: ] ]\ze' / 233syntax match zigCharacter /b'\( [ ^\\ ] \|\\\(.\|x\x\{2}\)\)' /contains = zigEscape , zigEscapeError , zigCharacterInvalid , zigCharacterInvalidUnicode 234syntax match zigCharacter /'\( [ ^\\ ] \|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{6}\)\)' /contains = zigEscape , zigEscapeUnicode , zigEscapeError , zigCharacterInvalid 235 236syntax region zigBlock start = "{ "end = "} "transparent fold 237 238syntax region zigCommentLine start = "// "end = "$ "contains = zigTodo , @Spell 239syntax region zigCommentLineDoc start = "// [ /! ] /\@! "end = "$ "contains = zigTodo , @Spell 240 241syntax match zigMultilineStringPrefix /c\?\\\\ /contained containedin = zigMultilineString 242syntax region zigMultilineString matchgroup = zigMultilineStringDelimiter start = "c\?\\\\ "end = "$ "contains = zigMultilineStringPrefix display 243 244syntax keyword zigTodo contained TODO 245 246syntax region zigString matchgroup = zigStringDelimiter start = +c\?" +skip = +\\\\\|\\" +end = +" +oneline contains = zigEscape , zigEscapeUnicode , zigEscapeError , @Spell 247syntax match zigEscapeError display contained /\\. / 248syntax match zigEscape display contained /\\\( [ nrt\\'" ] \|x\x\{2}\) / 249syntax match zigEscapeUnicode display contained /\\\(u\x\{4}\|U\x\{6}\) / 250 251highlight default link zigDecNumber zigNumber 252highlight default link zigHexNumber zigNumber 253highlight default link zigOctNumber zigNumber 254highlight default link zigBinNumber zigNumber 255 256highlight default link zigBuiltinFn Statement 257highlight default link zigKeyword Keyword 258highlight default link zigType Type 259highlight default link zigCommentLine Comment 260highlight default link zigCommentLineDoc Comment 261highlight default link zigDummyVariable Comment 262highlight default link zigTodo Todo 263highlight default link zigString String 264highlight default link zigStringDelimiter String 265highlight default link zigMultilineString String 266highlight default link zigMultilineStringContent String 267highlight default link zigMultilineStringPrefix String 268highlight default link zigMultilineStringDelimiter Delimiter 269highlight default link zigCharacterInvalid Error 270highlight default link zigCharacterInvalidUnicode zigCharacterInvalid 271highlight default link zigCharacter Character 272highlight default link zigEscape Special 273highlight default link zigEscapeUnicode zigEscape 274highlight default link zigEscapeError Error 275highlight default link zigBoolean Boolean 276highlight default link zigNull Boolean 277highlight default link zigConstant Constant 278highlight default link zigNumber Number 279highlight default link zigArrowCharacter zigOperator 280highlight default link zigOperator Operator 281highlight default link zigStructure Structure 282highlight default link zigExecution Special 283highlight default link zigMacro Macro 284highlight default link zigConditional Conditional 285highlight default link zigComparatorWord Keyword 286highlight default link zigRepeat Repeat 287highlight default link zigSpecial Special 288highlight default link zigVarDecl Function 289highlight default link zigPreProc PreProc 290highlight default link zigException Exception 291 292delfunction s:syntax_keyword 293 294let b: current_syntax = "zig" 295 296let & cpo = s: cpo_save 297unlet ! s: cpo_save