@@ -91,6 +91,8 @@ static int syntax_highlight_c_label(struct state *);
91
91
static int syntax_highlight_c_comment (struct state * );
92
92
static int syntax_highlight_c_preproc (struct state * );
93
93
94
+ static void syntax_highlight_zig (struct state * );
95
+
94
96
static void syntax_highlight_lua (struct state * );
95
97
static int syntax_highlight_lua_comment (struct state * );
96
98
@@ -233,6 +235,20 @@ static const char *go_kw[] = {
233
235
"for" , "import" , "return" , "var" , NULL
234
236
};
235
237
238
+ /* I really should add macro support to my editor.... */
239
+ static const char * zig_kw [] = {
240
+ "addrspace" , "align" , "and" , "asm" , "async" ,
241
+ "await" , "break" , "catch" , "comptime" , "const" ,
242
+ "continue" , "defer" , "else" , "enum" , "errdefer" ,
243
+ "error" , "export" , "extern" , "for" , "if" , "inline" ,
244
+ "noalias" , "noinline" , "nosuspend" , "opaque" , "or" ,
245
+ "orelse" , "packed" , "anyframe" , "pub" , "resume" , "return" ,
246
+ "linksection" , "callconv" , "struct" , "suspend" , "switch" ,
247
+ "test" , "threadlocal" , "try" , "union" , "unreachable" , "usingnamespace" ,
248
+ "var" , "volatile" , "allowzero" , "while" , "anytype" , "fn" ,
249
+ NULL
250
+ };
251
+
236
252
enum {
237
253
SYNTAX_COLOR_BLACK = 0 ,
238
254
SYNTAX_COLOR_RED ,
@@ -400,6 +416,9 @@ ce_syntax_write(struct cebuf *buf, struct celine *line, size_t index,
400
416
case CE_FILE_TYPE_LUA :
401
417
syntax_highlight_lua (& syntax_state );
402
418
break ;
419
+ case CE_FILE_TYPE_ZIG :
420
+ syntax_highlight_zig (& syntax_state );
421
+ break ;
403
422
default :
404
423
syntax_state_color_clear (& syntax_state );
405
424
syntax_write (& syntax_state , 1 );
@@ -1132,6 +1151,25 @@ syntax_highlight_lua_comment(struct state *state)
1132
1151
return (-1 );
1133
1152
}
1134
1153
1154
+ static void
1155
+ syntax_highlight_zig (struct state * state )
1156
+ {
1157
+ if (syntax_highlight_c_comment (state ) == 0 )
1158
+ return ;
1159
+
1160
+ if (syntax_highlight_numeric (state ) == 0 )
1161
+ return ;
1162
+
1163
+ if (syntax_highlight_string (state ) == 0 )
1164
+ return ;
1165
+
1166
+ if (syntax_highlight_word (state , zig_kw ) == 0 )
1167
+ return ;
1168
+
1169
+ syntax_state_color_clear (state );
1170
+ syntax_write (state , 1 );
1171
+ }
1172
+
1135
1173
static void
1136
1174
syntax_highlight_shell (struct state * state )
1137
1175
{
0 commit comments