summaryrefslogtreecommitdiff
path: root/src/Syntax.zig
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2024-02-19 23:38:33 +0200
committerGravatar Uko Kokņevičs2024-02-19 23:38:33 +0200
commitd5d5f7f06397d73f497d352f2f38b1a53d932b0d (patch)
tree63e34f5f945f4ecf28f844ee02a5a0b7fc581459 /src/Syntax.zig
parentCreate parent directory if doesn't exist on save (diff)
downloades-d5d5f7f06397d73f497d352f2f38b1a53d932b0d.tar.gz
es-d5d5f7f06397d73f497d352f2f38b1a53d932b0d.tar.xz
es-d5d5f7f06397d73f497d352f2f38b1a53d932b0d.zip
Big update to modern zig
Diffstat (limited to 'src/Syntax.zig')
-rw-r--r--src/Syntax.zig12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/Syntax.zig b/src/Syntax.zig
index 6858027..18ed477 100644
--- a/src/Syntax.zig
+++ b/src/Syntax.zig
@@ -10,8 +10,7 @@ const Syntax = @This();
10 10
11pub const chooseSyntax = ComptimeStringMap( 11pub const chooseSyntax = ComptimeStringMap(
12 Syntax, 12 Syntax,
13 pairWith(&makefile.filematch, makefile.syntax) 13 pairWith(&makefile.filematch, makefile.syntax) ++ pairWith(&zig.filematch, zig.syntax),
14 ++ pairWith(&zig.filematch, zig.syntax),
15).get; 14).get;
16 15
17pub const Flags = struct { 16pub const Flags = struct {
@@ -20,7 +19,7 @@ pub const Flags = struct {
20}; 19};
21 20
22name: []const u8, 21name: []const u8,
23keyword_classifier: fn([]const u8) ?Highlight, 22keyword_classifier: *const fn ([]const u8) ?Highlight,
24singleline_comment_start: ?[]const u8, 23singleline_comment_start: ?[]const u8,
25multiline_comment_start: ?[]const u8, 24multiline_comment_start: ?[]const u8,
26multiline_comment_end: ?[]const u8, 25multiline_comment_end: ?[]const u8,
@@ -28,7 +27,7 @@ separators: []const u8,
28flags: Flags, 27flags: Flags,
29 28
30pub fn isSeparator(self: Syntax, char: u8) bool { 29pub fn isSeparator(self: Syntax, char: u8) bool {
31 return std.ascii.isSpace(char) or std.mem.indexOfScalar(u8, self.separators, char) != null; 30 return std.ascii.isWhitespace(char) or std.mem.indexOfScalar(u8, self.separators, char) != null;
32} 31}
33 32
34pub fn pairWith( 33pub fn pairWith(
@@ -37,8 +36,8 @@ pub fn pairWith(
37) [keys.len]KeyValue(@TypeOf(value)) { 36) [keys.len]KeyValue(@TypeOf(value)) {
38 @setEvalBranchQuota(20000); 37 @setEvalBranchQuota(20000);
39 38
40 var pairs = [_]KeyValue(@TypeOf(value)) {undefined} ** keys.len; 39 var pairs = [_]KeyValue(@TypeOf(value)){undefined} ** keys.len;
41 for (keys) |key, i| { 40 for (keys, 0..) |key, i| {
42 pairs[i] = .{ .@"0" = key, .@"1" = value }; 41 pairs[i] = .{ .@"0" = key, .@"1" = value };
43 } 42 }
44 43
@@ -51,4 +50,3 @@ fn KeyValue(comptime V: type) type {
51 @"1": V, 50 @"1": V,
52 }; 51 };
53} 52}
54