@@ -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
0 commit comments