Skip to content

Commit c1bf170

Browse files
committed
Update to Zig 0.16.0-dev.1458+755a3d957 or later
1 parent 7c4578f commit c1bf170

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Provides the necessary building blocks to develop Language Server Protocol imple
1010
# Installation
1111

1212
> [!NOTE]
13-
> The default branch requires Zig `0.16.0-dev.1204+389368392` or later. Checkout the `0.15.x` branch when using Zig 0.15
13+
> The default branch requires Zig `0.16.0-dev.1458+755a3d957` or later. Checkout the `0.15.x` branch when using Zig 0.15
1414
1515
```bash
1616
# Initialize a `zig build` project if you haven't already

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.{
22
.name = .lsp_kit,
33
.version = "0.1.0",
4-
.minimum_zig_version = "0.16.0-dev.1204+389368392",
4+
.minimum_zig_version = "0.16.0-dev.1458+755a3d957",
55
.dependencies = .{},
66
.paths = .{
77
"build.zig",

src/basic_server.zig

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -618,30 +618,14 @@ fn MessageType(comptime Handler: type) type {
618618
}
619619
}
620620

621-
var enum_fields: [methods.len + 1]std.builtin.Type.EnumField = undefined;
622-
for (enum_fields[0 .. enum_fields.len - 1], methods, 0..) |*field, method, i| field.* = .{ .name = method, .value = i };
623-
enum_fields[methods.len] = .{ .name = "other", .value = methods.len };
624-
625-
const MethodEnum = @Type(.{ .@"enum" = .{
626-
.tag_type = std.math.IntFittingRange(0, methods.len),
627-
.fields = &enum_fields,
628-
.decls = &.{},
629-
.is_exhaustive = true,
630-
} });
631-
632-
var union_fields: [methods.len + 1]std.builtin.Type.UnionField = undefined;
633-
for (union_fields[0 .. union_fields.len - 1], methods) |*field, method| {
634-
const field_type = lsp.ParamsType(method);
635-
field.* = .{ .name = method, .type = field_type, .alignment = @alignOf(field_type) };
636-
}
637-
union_fields[methods.len] = .{ .name = "other", .type = lsp.MethodWithParams, .alignment = @alignOf(lsp.MethodWithParams) };
638-
639-
Params.* = @Type(.{ .@"union" = .{
640-
.layout = .auto,
641-
.tag_type = MethodEnum,
642-
.fields = &union_fields,
643-
.decls = &.{},
644-
} });
621+
const field_names: []const []const u8 = methods ++ .{"other"};
622+
var field_types: [methods.len + 1]type = undefined;
623+
for (field_types[0 .. field_types.len - 1], methods) |*ty, method| ty.* = lsp.ParamsType(method);
624+
field_types[methods.len] = lsp.MethodWithParams;
625+
626+
const IntTag = std.math.IntFittingRange(0, methods.len);
627+
const MethodEnum = @Enum(IntTag, .exhaustive, field_names, &std.simd.iota(IntTag, methods.len + 1));
628+
Params.* = @Union(.auto, MethodEnum, field_names, &field_types, &@splat(.{}));
645629
}
646630

647631
return lsp.Message(RequestParams, NotificationParams, .{});

0 commit comments

Comments
 (0)