From b744f19bd089147590878b53413d1f27865322a6 Mon Sep 17 00:00:00 2001 From: Johan Persson Date: Fri, 6 Feb 2026 21:46:00 +0100 Subject: [PATCH 1/4] Fixes according to zig/ziglang#31084 See https://codeberg.org/ziglang/zig/pulls/31084 --- build.zig.zon | 2 +- examples/hello_client.zig | 2 +- src/lsp.zig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index e2ffaf9..c13c199 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,7 +1,7 @@ .{ .name = .lsp_kit, .version = "0.1.0", - .minimum_zig_version = "0.16.0-dev.1976+8e091047b", + .minimum_zig_version = "0.16.0-dev.2510+bcb5218a2", .dependencies = .{}, .paths = .{ "build.zig", diff --git a/examples/hello_client.zig b/examples/hello_client.zig index 62ceae1..7e11195 100644 --- a/examples/hello_client.zig +++ b/examples/hello_client.zig @@ -71,7 +71,7 @@ pub fn main(init: std.process.Init) !void { // // The `lsp.Transport.Stdio` implements the necessary logic to read and write messages over stdio. var read_buffer: [256]u8 = undefined; - var stdio_transport: lsp.Transport.Stdio = .init(&read_buffer, .{ .handle = child_process.stdout.?.handle }, child_process.stdin.?); + var stdio_transport: lsp.Transport.Stdio = .init(&read_buffer, .{ .handle = child_process.stdout.?.handle, .flags = .{ .nonblocking = true } }, child_process.stdin.?); const transport: *lsp.Transport = &stdio_transport.transport; // The order of exchanged messages will look similar to this: diff --git a/src/lsp.zig b/src/lsp.zig index 632ac2c..5cbec58 100644 --- a/src/lsp.zig +++ b/src/lsp.zig @@ -1244,7 +1244,7 @@ pub const ThreadSafeTransportConfig = struct { thread_safe_read: bool, /// Makes `writeJsonMessage` thread-safe. thread_safe_write: bool, - MutexType: type = std.Thread.Mutex, + MutexType: type = std.Io.Mutex, }; /// Wraps a non-thread-safe transport and makes it thread-safe. From 4f75d3af5b664148137aff1e0f63927af80efc02 Mon Sep 17 00:00:00 2001 From: Johan Persson Date: Fri, 6 Feb 2026 23:54:15 +0100 Subject: [PATCH 2/4] Some additions to reflect the new API --- src/lsp.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lsp.zig b/src/lsp.zig index 5cbec58..81b6c4c 100644 --- a/src/lsp.zig +++ b/src/lsp.zig @@ -1273,8 +1273,8 @@ pub fn ThreadSafeTransport(config: ThreadSafeTransportConfig) type { pub fn readJsonMessage(transport: *Transport, io: std.Io, allocator: std.mem.Allocator) Transport.ReadError![]u8 { const self: *Self = @fieldParentPtr("transport", transport); - self.in_mutex.lock(); - defer self.in_mutex.unlock(); + try self.in_mutex.lock(io); + defer self.in_mutex.unlock(io); return try self.child_transport.readJsonMessage(io, allocator); } @@ -1282,25 +1282,25 @@ pub fn ThreadSafeTransport(config: ThreadSafeTransportConfig) type { pub fn writeJsonMessage(transport: *Transport, io: std.Io, json_message: []const u8) Transport.WriteError!void { const self: *Self = @fieldParentPtr("transport", transport); - self.out_mutex.lock(); - defer self.out_mutex.unlock(); + try self.out_mutex.lock(io); + defer self.out_mutex.unlock(io); return try self.child_transport.writeJsonMessage(io, json_message); } const in_mutex_init = if (config.thread_safe_read) - config.MutexType{} + config.MutexType.init else DummyMutex{}; const out_mutex_init = if (config.thread_safe_write) - config.MutexType{} + config.MutexType.init else DummyMutex{}; const DummyMutex = struct { - fn lock(_: *DummyMutex) void {} - fn unlock(_: *DummyMutex) void {} + pub fn lock(_: *DummyMutex, _: std.Io) !void {} + pub fn unlock(_: *DummyMutex, _: std.Io) void {} }; }; } From 4d84402b2daf5adb7be8c913ccd2b7f1369de296 Mon Sep 17 00:00:00 2001 From: Techatrix Date: Sat, 7 Feb 2026 09:39:30 +0100 Subject: [PATCH 3/4] simplify initialization of lsp.Transport.Stdio --- examples/hello_client.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/hello_client.zig b/examples/hello_client.zig index 7e11195..942999b 100644 --- a/examples/hello_client.zig +++ b/examples/hello_client.zig @@ -71,7 +71,7 @@ pub fn main(init: std.process.Init) !void { // // The `lsp.Transport.Stdio` implements the necessary logic to read and write messages over stdio. var read_buffer: [256]u8 = undefined; - var stdio_transport: lsp.Transport.Stdio = .init(&read_buffer, .{ .handle = child_process.stdout.?.handle, .flags = .{ .nonblocking = true } }, child_process.stdin.?); + var stdio_transport: lsp.Transport.Stdio = .init(&read_buffer, child_process.stdout.?, child_process.stdin.?); const transport: *lsp.Transport = &stdio_transport.transport; // The order of exchanged messages will look similar to this: From b959c4402de31570d0f5ef9411da5cb39c7f8f67 Mon Sep 17 00:00:00 2001 From: Techatrix Date: Sat, 7 Feb 2026 09:39:41 +0100 Subject: [PATCH 4/4] sync minimum zig version in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 97070bc..98bdd14 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Provides the necessary building blocks to develop Language Server Protocol imple # Installation > [!NOTE] -> The default branch requires Zig `0.16.0-dev.1976+8e091047b` or later. Checkout the `0.15.x` branch when using Zig 0.15 +> The default branch requires Zig `0.16.0-dev.2510+bcb5218a2` or later. Checkout the `0.15.x` branch when using Zig 0.15 ```bash # Initialize a `zig build` project if you haven't already