Skip to content

Commit f85dc5a

Browse files
committed
flatten the zig_syntax_keywords dictionary in syntax/zig.vim
This change shouldn't have any functional changes but should make the next commits more readable.
1 parent e55a794 commit f85dc5a

File tree

1 file changed

+20
-213
lines changed

1 file changed

+20
-213
lines changed

syntax/zig.vim

Lines changed: 20 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -10,217 +10,26 @@ endif
1010
let s:cpo_save = &cpo
1111
set cpo&vim
1212

13-
let s:zig_syntax_keywords = {
14-
\ 'zigBoolean': ["true"
15-
\ , "false"]
16-
\ , 'zigNull': ["null"]
17-
\ , 'zigType': ["bool"
18-
\ , "f16"
19-
\ , "f32"
20-
\ , "f64"
21-
\ , "f80"
22-
\ , "f128"
23-
\ , "void"
24-
\ , "type"
25-
\ , "anytype"
26-
\ , "anyerror"
27-
\ , "anyframe"
28-
\ , "volatile"
29-
\ , "linksection"
30-
\ , "noreturn"
31-
\ , "allowzero"
32-
\ , "i0"
33-
\ , "u0"
34-
\ , "isize"
35-
\ , "usize"
36-
\ , "comptime_int"
37-
\ , "comptime_float"
38-
\ , "c_char"
39-
\ , "c_short"
40-
\ , "c_ushort"
41-
\ , "c_int"
42-
\ , "c_uint"
43-
\ , "c_long"
44-
\ , "c_ulong"
45-
\ , "c_longlong"
46-
\ , "c_ulonglong"
47-
\ , "c_longdouble"
48-
\ , "anyopaque"]
49-
\ , 'zigConstant': ["undefined"
50-
\ , "unreachable"]
51-
\ , 'zigConditional': ["if"
52-
\ , "else"
53-
\ , "switch"]
54-
\ , 'zigRepeat': ["while"
55-
\ , "for"]
56-
\ , 'zigComparatorWord': ["and"
57-
\ , "or"
58-
\ , "orelse"]
59-
\ , 'zigStructure': ["struct"
60-
\ , "enum"
61-
\ , "union"
62-
\ , "error"
63-
\ , "packed"
64-
\ , "opaque"]
65-
\ , 'zigException': ["error"]
66-
\ , 'zigVarDecl': ["var"
67-
\ , "const"
68-
\ , "comptime"
69-
\ , "threadlocal"]
70-
\ , 'zigDummyVariable': ["_"]
71-
\ , 'zigKeyword': ["fn"
72-
\ , "try"
73-
\ , "test"
74-
\ , "pub"
75-
\ , "usingnamespace"]
76-
\ , 'zigExecution': ["return"
77-
\ , "break"
78-
\ , "continue"]
79-
\ , 'zigMacro': ["defer"
80-
\ , "errdefer"
81-
\ , "async"
82-
\ , "nosuspend"
83-
\ , "await"
84-
\ , "suspend"
85-
\ , "resume"
86-
\ , "export"
87-
\ , "extern"]
88-
\ , 'zigPreProc': ["addrspace"
89-
\ , "align"
90-
\ , "asm"
91-
\ , "callconv"
92-
\ , "catch"
93-
\ , "inline"
94-
\ , "noalias"
95-
\ , "noinline"]
96-
\ , 'zigBuiltinFn': ["@addrSpaceCast"
97-
\ , "@addWithOverflow"
98-
\ , "@alignCast"
99-
\ , "@alignOf"
100-
\ , "@as"
101-
\ , "@atomicLoad"
102-
\ , "@atomicRmw"
103-
\ , "@atomicStore"
104-
\ , "@bitCast"
105-
\ , "@bitOffsetOf"
106-
\ , "@bitSizeOf"
107-
\ , "@branchHint"
108-
\ , "@breakpoint"
109-
\ , "@mulAdd"
110-
\ , "@byteSwap"
111-
\ , "@bitReverse"
112-
\ , "@offsetOf"
113-
\ , "@call"
114-
\ , "@cDefine"
115-
\ , "@cImport"
116-
\ , "@cInclude"
117-
\ , "@clz"
118-
\ , "@cmpxchgStrong"
119-
\ , "@cmpxchgWeak"
120-
\ , "@compileError"
121-
\ , "@compileLog"
122-
\ , "@constCast"
123-
\ , "@ctz"
124-
\ , "@cUndef"
125-
\ , "@cVaArg"
126-
\ , "@cVaCopy"
127-
\ , "@cVaEnd"
128-
\ , "@cVaStart"
129-
\ , "@disableInstrumentation"
130-
\ , "@disableIntrinsics"
131-
\ , "@divExact"
132-
\ , "@divFloor"
133-
\ , "@divTrunc"
134-
\ , "@embedFile"
135-
\ , "@enumFromInt"
136-
\ , "@errorFromInt"
137-
\ , "@errorName"
138-
\ , "@errorReturnTrace"
139-
\ , "@errorCast"
140-
\ , "@export"
141-
\ , "@extern"
142-
\ , "@field"
143-
\ , "@fieldParentPtr"
144-
\ , "@FieldType"
145-
\ , "@floatCast"
146-
\ , "@floatFromInt"
147-
\ , "@frameAddress"
148-
\ , "@hasDecl"
149-
\ , "@hasField"
150-
\ , "@import"
151-
\ , "@inComptime"
152-
\ , "@intCast"
153-
\ , "@intFromBool"
154-
\ , "@intFromEnum"
155-
\ , "@intFromError"
156-
\ , "@intFromFloat"
157-
\ , "@intFromPtr"
158-
\ , "@max"
159-
\ , "@memcpy"
160-
\ , "@memmove"
161-
\ , "@memset"
162-
\ , "@min"
163-
\ , "@wasmMemorySize"
164-
\ , "@wasmMemoryGrow"
165-
\ , "@mod"
166-
\ , "@mulWithOverflow"
167-
\ , "@panic"
168-
\ , "@popCount"
169-
\ , "@prefetch"
170-
\ , "@ptrCast"
171-
\ , "@ptrFromInt"
172-
\ , "@rem"
173-
\ , "@returnAddress"
174-
\ , "@select"
175-
\ , "@setEvalBranchQuota"
176-
\ , "@setFloatMode"
177-
\ , "@setRuntimeSafety"
178-
\ , "@shlExact"
179-
\ , "@shlWithOverflow"
180-
\ , "@shrExact"
181-
\ , "@shuffle"
182-
\ , "@sizeOf"
183-
\ , "@splat"
184-
\ , "@reduce"
185-
\ , "@src"
186-
\ , "@sqrt"
187-
\ , "@sin"
188-
\ , "@cos"
189-
\ , "@tan"
190-
\ , "@exp"
191-
\ , "@exp2"
192-
\ , "@log"
193-
\ , "@log2"
194-
\ , "@log10"
195-
\ , "@abs"
196-
\ , "@floor"
197-
\ , "@ceil"
198-
\ , "@trunc"
199-
\ , "@round"
200-
\ , "@subWithOverflow"
201-
\ , "@tagName"
202-
\ , "@This"
203-
\ , "@trap"
204-
\ , "@truncate"
205-
\ , "@Type"
206-
\ , "@typeInfo"
207-
\ , "@typeName"
208-
\ , "@TypeOf"
209-
\ , "@unionInit"
210-
\ , "@Vector"
211-
\ , "@volatileCast"
212-
\ , "@workGroupId"
213-
\ , "@workGroupSize"
214-
\ , "@workItemId"]
215-
\ }
216-
217-
function! s:syntax_keyword(dict)
218-
for key in keys(a:dict)
219-
execute 'syntax keyword' key join(a:dict[key], ' ')
220-
endfor
221-
endfunction
222-
223-
call s:syntax_keyword(s:zig_syntax_keywords)
13+
syntax keyword zigBoolean true false
14+
syntax keyword zigNull null
15+
syntax keyword zigType bool void type anytype anyerror anyframe volatile linksection noreturn allowzero anyopaque
16+
syntax keyword zigType i0 u0 isize usize comptime_int comptime_float
17+
syntax keyword zigType f16 f32 f64 f80 f128
18+
syntax keyword zigType c_char c_short c_ushort c_int c_uint c_long c_ulong c_longlong c_ulonglong c_longdouble
19+
syntax keyword zigConstant undefined unreachable
20+
syntax keyword zigConditional if else switch
21+
syntax keyword zigRepeat while for
22+
syntax keyword zigComparatorWord and or orelse
23+
syntax keyword zigStructure struct enum union error packed opaque
24+
syntax keyword zigException error
25+
syntax keyword zigStorageClass
26+
syntax keyword zigVarDecl var const comptime threadlocal
27+
syntax keyword zigDummyVariable _
28+
syntax keyword zigKeyword fn try test pub usingnamespace
29+
syntax keyword zigExecution return break continue
30+
syntax keyword zigMacro defer errdefer async nosuspend await suspend resume export extern
31+
syntax keyword zigPreProc addrspace align asm callconv catch inline noalias noinline
32+
syntax keyword zigBuiltinFn @addrSpaceCast @addWithOverflow @alignCast @alignOf @as @atomicLoad @atomicRmw @atomicStore @bitCast @bitOffsetOf @bitSizeOf @branchHint @breakpoint @mulAdd @byteSwap @bitReverse @offsetOf @call @cDefine @cImport @cInclude @clz @cmpxchgStrong @cmpxchgWeak @compileError @compileLog @constCast @ctz @cUndef @cVaArg @cVaCopy @cVaEnd @cVaStart @disableInstrumentation @disableIntrinsics @divExact @divFloor @divTrunc @embedFile @enumFromInt @errorFromInt @errorName @errorReturnTrace @errorCast @export @extern @field @fieldParentPtr @FieldType @floatCast @floatFromInt @frameAddress @hasDecl @hasField @import @inComptime @intCast @intFromBool @intFromEnum @intFromError @intFromFloat @intFromPtr @max @memcpy @memmove @memset @min @wasmMemorySize @wasmMemoryGrow @mod @mulWithOverflow @panic @popCount @prefetch @ptrCast @ptrFromInt @rem @returnAddress @select @setEvalBranchQuota @setFloatMode @setRuntimeSafety @shlExact @shlWithOverflow @shrExact @shuffle @sizeOf @splat @reduce @src @sqrt @sin @cos @tan @exp @exp2 @log @log2 @log10 @abs @floor @ceil @trunc @round @subWithOverflow @tagName @This @trap @truncate @Type @typeInfo @typeName @TypeOf @unionInit @Vector @volatileCast @workGroupId @workGroupSize @workItemId
22433

22534
syntax match zigType "\v<[iu][1-9]\d*>"
22635
syntax match zigOperator display "\V\[-+/*=^&?|!><%~]"
@@ -293,8 +102,6 @@ highlight default link zigVarDecl Function
293102
highlight default link zigPreProc PreProc
294103
highlight default link zigException Exception
295104

296-
delfunction s:syntax_keyword
297-
298105
let b:current_syntax = "zig"
299106

300107
let &cpo = s:cpo_save

0 commit comments

Comments
 (0)