Skip to content

Commit f34a177

Browse files
authored
update to zig 0.16.0-dev.1976+8e091047b
1 parent 1d4a410 commit f34a177

6 files changed

Lines changed: 22 additions & 61 deletions

File tree

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.1859+212968c57` or later. Checkout the `0.15.x` branch when using Zig 0.15
13+
> The default branch requires Zig `0.16.0-dev.1976+8e091047b` 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.1859+212968c57",
4+
.minimum_zig_version = "0.16.0-dev.1976+8e091047b",
55
.dependencies = .{},
66
.paths = .{
77
"build.zig",

examples/hello_client.zig

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,11 @@ const usage =
4646
\\
4747
;
4848

49-
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
50-
51-
pub fn main() !void {
52-
const gpa, const is_debug = switch (builtin.mode) {
53-
.Debug, .ReleaseSafe => .{ debug_allocator.allocator(), true },
54-
.ReleaseFast, .ReleaseSmall => .{ std.heap.smp_allocator, false },
55-
};
56-
defer if (is_debug) {
57-
_ = debug_allocator.deinit();
58-
};
59-
60-
var threaded: std.Io.Threaded = .init(gpa, .{});
61-
defer threaded.deinit();
62-
const io = threaded.ioBasic();
63-
64-
const args = try std.process.argsAlloc(gpa);
65-
defer std.process.argsFree(gpa, args);
49+
pub fn main(init: std.process.Init) !void {
50+
const io = init.io;
51+
const gpa = init.gpa;
52+
const arena = init.arena.allocator();
53+
const args = try init.minimal.args.toSlice(arena);
6654

6755
if (args.len < 3) fatalWithUsage("expected at least 2 arguments but got {d}", .{args.len - 1});
6856

@@ -71,13 +59,12 @@ pub fn main() !void {
7159
defer gpa.free(input_file);
7260

7361
// Spawn the language server as a child process.
74-
var child_process: std.process.Child = .init(args[2..], gpa);
75-
child_process.stdin_behavior = .Pipe;
76-
child_process.stdout_behavior = .Pipe;
77-
child_process.stderr_behavior = if (show_langauge_server_stderr) .Inherit else .Ignore;
78-
79-
child_process.spawn(io) catch |err| fatal("child process could not be created: {}", .{err});
80-
child_process.waitForSpawn() catch |err| fatal("child process could not be created: {}", .{err});
62+
var child_process = std.process.spawn(io, .{
63+
.argv = args[2..],
64+
.stdin = .pipe,
65+
.stdout = .pipe,
66+
.stderr = if (show_langauge_server_stderr) .inherit else .ignore,
67+
}) catch |err| fatal("child process could not be created: {}", .{err});
8168

8269
// Language servers can support multiple communication channels (e.g. stdio, pipes, sockets).
8370
// See https://microsoft.github.io/language-server-protocol/specifications/specification-current/#implementationConsiderations

examples/hello_server.zig

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,9 @@ pub const std_options: std.Options = .{
3030
.log_level = std.log.default_level, // Customize the log level here
3131
};
3232

33-
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
34-
35-
pub fn main() !void {
36-
const gpa, const is_debug = switch (builtin.mode) {
37-
.Debug, .ReleaseSafe => .{ debug_allocator.allocator(), true },
38-
.ReleaseFast, .ReleaseSmall => .{ std.heap.smp_allocator, false },
39-
};
40-
defer if (is_debug) {
41-
_ = debug_allocator.deinit();
42-
};
43-
44-
var threaded: std.Io.Threaded = .init(gpa, .{});
45-
defer threaded.deinit();
46-
const io = threaded.ioBasic();
47-
33+
pub fn main(init: std.process.Init) !void {
34+
const io = init.io;
35+
const gpa = init.gpa;
4836
// Language servers can support multiple communication channels (e.g. stdio, pipes, sockets).
4937
// See https://microsoft.github.io/language-server-protocol/specifications/specification-current/#implementationConsiderations
5038
//

examples/my_first_server.zig

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,19 @@ const std = @import("std");
44
const builtin = @import("builtin");
55
const lsp = @import("lsp");
66

7-
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
8-
9-
pub fn main() !void {
10-
const gpa, const is_debug = switch (builtin.mode) {
11-
.Debug, .ReleaseSafe => .{ debug_allocator.allocator(), true },
12-
.ReleaseFast, .ReleaseSmall => .{ std.heap.smp_allocator, false },
13-
};
14-
defer if (is_debug) {
15-
_ = debug_allocator.deinit();
16-
};
17-
18-
var threaded: std.Io.Threaded = .init(gpa, .{});
19-
defer threaded.deinit();
20-
const io = threaded.ioBasic();
21-
7+
pub fn main(init: std.process.Init) !void {
228
// LSP implementations typically communicate over stdio (stdin and stdout)
239
var read_buffer: [256]u8 = undefined;
24-
var stdio_transport: lsp.Transport.Stdio = .init(io, &read_buffer, .stdin(), .stdout());
10+
var stdio_transport: lsp.Transport.Stdio = .init(init.io, &read_buffer, .stdin(), .stdout());
2511
const transport: *lsp.Transport = &stdio_transport.transport;
2612

2713
// The handler is a user provided type that stores the state of the
2814
// language server and provides callbacks for the desired LSP messages.
29-
var handler: Handler = .init(gpa);
15+
var handler: Handler = .init(init.gpa);
3016
defer handler.deinit();
3117

3218
try lsp.basic_server.run(
33-
gpa,
19+
init.gpa,
3420
transport,
3521
&handler,
3622
std.log.err,

src/codegen/codegen.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const std = @import("std");
44
const MetaModel = @import("MetaModel.zig");
55

6-
pub fn main() !u8 {
6+
pub fn main(init: std.process.Init.Minimal) !u8 {
77
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
88
defer _ = debug_allocator.deinit();
99

@@ -12,7 +12,7 @@ pub fn main() !u8 {
1212
var threaded: std.Io.Threaded = .init_single_threaded;
1313
const io = threaded.ioBasic();
1414

15-
var arg_it: std.process.ArgIterator = try .initWithAllocator(gpa);
15+
var arg_it = try init.args.iterateAllocator(gpa);
1616
defer arg_it.deinit();
1717

1818
_ = arg_it.skip(); // skip self exe

0 commit comments

Comments
 (0)