File tree Expand file tree Collapse file tree 5 files changed +15
-12
lines changed
Expand file tree Collapse file tree 5 files changed +15
-12
lines changed Original file line number Diff line number Diff 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.15.0-dev.1018+1a998886c ` or later. Checkout the ` 0.14.x ` branch when using Zig 0.14
13+ > The default branch requires Zig ` 0.15.0-dev.1145+3ae0ba096 ` or later. Checkout the ` 0.14.x ` branch when using Zig 0.14
1414
1515``` bash
1616# Initialize a `zig build` project if you haven't already
Original file line number Diff line number Diff line change 11const std = @import ("std" );
22const builtin = @import ("builtin" );
33
4- const minimum_zig_version = "0.15.0-dev.1018+1a998886c " ;
4+ const minimum_zig_version = "0.15.0-dev.1145+3ae0ba096 " ;
55
66pub fn build (b : * std.Build ) void {
7- comptime if (builtin .zig_version .order (std .SemanticVersion .parse ("0.15.0-dev.1018+1a998886c" ) catch unreachable ) == .lt ) {
7+ comptime if (builtin .zig_version .order (std .SemanticVersion .parse (minimum_zig_version ) catch unreachable ) == .lt ) {
88 @compileError (std .fmt .comptimePrint (
99 \\Your Zig version does not meet the minimum build requirement:
1010 \\ required Zig version: {[minimum_zig_version]s}
Original file line number Diff line number Diff line change 11.{
22 .name = .lsp_kit ,
33 .version = "0.1.0" ,
4- .minimum_zig_version = "0.15.0-dev.1023+f551c7c58 " ,
4+ .minimum_zig_version = "0.15.0-dev.1145+3ae0ba096 " ,
55 .dependencies = .{},
66 .paths = .{
77 "build.zig" ,
Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ pub fn main() !void {
131131 continue ;
132132 }
133133
134- const formatte_source = try tree .render (gpa );
134+ const formatte_source = try tree .renderAlloc (gpa );
135135 defer gpa .free (formatte_source );
136136
137137 if (std .mem .eql (u8 , source , formatte_source )) {
Original file line number Diff line number Diff line change @@ -30,18 +30,21 @@ pub fn main() !void {
3030 var zig_tree : std.zig.Ast = try .parse (gpa , source , .zig );
3131 defer zig_tree .deinit (gpa );
3232
33- const output_source = if (zig_tree .errors .len != 0 ) blk : {
34- std .log .warn ("generated file contains syntax errors! (cannot format file)" , .{});
35- break :blk source ;
36- } else try zig_tree .render (gpa );
37- defer if (zig_tree .errors .len == 0 ) gpa .free (output_source );
38-
3933 std .fs .cwd ().makePath (std .fs .path .dirname (out_file_path ) orelse "." ) catch {};
4034
4135 var out_file = try std .fs .cwd ().createFile (out_file_path , .{});
4236 defer out_file .close ();
4337
44- try out_file .writeAll (output_source );
38+ if (zig_tree .errors .len != 0 ) {
39+ std .log .warn ("generated file contains syntax errors! (cannot format file)" , .{});
40+ try out_file .writeAll (source );
41+ } else {
42+ var buf : [1024 ]u8 = undefined ;
43+ var out = out_file .writer (& buf );
44+ const w = & out .interface ;
45+ try zig_tree .render (gpa , w , .{});
46+ try w .flush ();
47+ }
4548}
4649
4750const FormatDocs = struct {
You can’t perform that action at this time.
0 commit comments