From 53045123c61d14230fc51a908fbace1b8239baa8 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 4 Feb 2025 22:59:18 +0100 Subject: [PATCH] build: update to zig 0.14.0-dev.3039 --- build.zig.version | 2 +- build.zig.zon | 20 +- src/EventHandler.zig | 6 +- src/LSP.zig | 8 +- src/buffer/Buffer.zig | 66 +++--- src/command.zig | 8 +- src/keybind/parse_flow.zig | 2 +- src/log.zig | 6 +- src/main.zig | 8 +- src/renderer/vaxis/Plane.zig | 2 +- src/renderer/vaxis/input.zig | 2 +- src/renderer/vaxis/renderer.zig | 4 +- src/renderer/vaxis/style.zig | 14 +- src/ripgrep.zig | 4 +- src/shell.zig | 2 +- src/syntax/src/file_type.zig | 4 +- src/syntax/src/file_types.zig | 13 +- src/tui/MessageFilter.zig | 2 +- src/tui/Widget.zig | 2 +- src/tui/WidgetList.zig | 6 +- src/tui/editor.zig | 299 +++++++++++------------ src/tui/editor_gutter.zig | 11 +- src/tui/filelist_view.zig | 11 +- src/tui/home.zig | 11 +- src/tui/inspector_view.zig | 15 +- src/tui/mainview.zig | 115 ++++----- src/tui/mode/helix.zig | 17 +- src/tui/mode/mini/buffer.zig | 15 +- src/tui/mode/mini/file_browser.zig | 23 +- src/tui/mode/mini/find.zig | 59 ++--- src/tui/mode/mini/find_in_files.zig | 49 ++-- src/tui/mode/mini/goto.zig | 11 +- src/tui/mode/mini/move_to_char.zig | 7 +- src/tui/mode/overlay/open_recent.zig | 27 ++- src/tui/mode/overlay/palette.zig | 31 +-- src/tui/mode/vim.zig | 25 +- src/tui/status/blank.zig | 6 +- src/tui/status/filestate.zig | 7 +- src/tui/status/modestate.zig | 5 +- src/tui/status/tabs.zig | 6 +- src/tui/tui.zig | 340 +++++++++++++-------------- 41 files changed, 648 insertions(+), 623 deletions(-) diff --git a/build.zig.version b/build.zig.version index 54d1a4f..871de6e 100644 --- a/build.zig.version +++ b/build.zig.version @@ -1 +1 @@ -0.13.0 +0.14.0-dev.3039+e61acd8eb diff --git a/build.zig.zon b/build.zig.zon index fd5e775..1ee99ab 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -6,8 +6,8 @@ .dependencies = .{ .syntax = .{ .path = "src/syntax" }, .flags = .{ - .url = "https://github.com/n0s4/flags/archive/b3905aa990719ff567f1c5a2f89e6dd3292d8533.tar.gz", - .hash = "1220930a42f8da3fb7f723e3ad3f6dcc6db76327dd8d26274566423192d53e91b2bb", + .url = "https://github.com/n0s4/flags/archive/372501d1576b5723829bcba98e41361132c7b618.tar.gz", + .hash = "1220ae181067a549c7a99cc0868193a7889b151381410419191ab1a79304f914336e", }, .tracy = .{ .url = "https://github.com/neurocyte/zig-tracy/archive/e04e31c64498149a324491b8534758e6af43a5c2.tar.gz", @@ -18,28 +18,28 @@ .hash = "1220220dbc7fe91c1c54438193ca765cebbcb7d58f35cdcaee404a9d2245a42a4362", }, .thespian = .{ - .url = "https://github.com/neurocyte/thespian/archive/db3ad5f45e707a04eaa51aa657995abe43ce967a.tar.gz", - .hash = "1220bbfd147f41fa49d2e5406096f3529c62e9335f4d2a89ae381e679a76ce398f1f", + .url = "https://github.com/neurocyte/thespian/archive/063c441c30aafd212b4d8e97555590594855a082.tar.gz", + .hash = "1220d04b3ac1fd1584796d8047a24cccca834592bb2ee7175e1692a1fc6d6d791fb1", }, .themes = .{ .url = "https://github.com/neurocyte/flow-themes/releases/download/master-618a7801d3383049adfe18cc09f5f5086c66995f/flow-themes.tar.gz", .hash = "1220019ed92f48fb94d4ae82bba17b11d0ba06f17ed31cd66613b3c048b1d2382095", }, .fuzzig = .{ - .url = "https://github.com/fjebaker/fuzzig/archive/0fd156d5097365151e85a85eef9d8cf0eebe7b00.tar.gz", - .hash = "122019f077d09686b1ec47928ca2b4bf264422f3a27afc5b49dafb0129a4ceca0d01", + .url = "https://github.com/fjebaker/fuzzig/archive/44c04733c7c0fee3db83672aaaaf4ed03e943156.tar.gz", + .hash = "1220666c7afe30f6a51ae477f7755e9b6a5341723bfcb5de349817b5d0912b96f9ad", }, .vaxis = .{ - .url = "https://github.com/neurocyte/libvaxis/archive/d899244bc0a3775b59c18e90eb41acee11675f96.tar.gz", - .hash = "12207e33747072d878fce61f587c133124dc95f4ae8aab7d2b3f467699586af07c77", + .url = "https://github.com/neurocyte/libvaxis/archive/eb0fe09b1b3d1ad282b6f372672748f0459211eb.tar.gz", + .hash = "1220cd97dea400cc5a76ceb9d9bbeff4b5aa81e2703d354a5d4de3483b315d4eb437", }, .zeit = .{ .url = "https://github.com/rockorager/zeit/archive/8fd203f85f597f16e0a525c1f1ca1e0bffded809.tar.gz", .hash = "122022233835adc719535a8e7cefdd2902a67bbfb7ef198441ca9ce89c0593f488c2", }, .win32 = .{ - .url = "https://github.com/marlersoft/zigwin32/archive/259b6f353a48968d7e3171573db4fd898b046188.tar.gz", - .hash = "1220925614447b54ccc9894bbba8b202c6a8b750267890edab7732064867e46f3217", + .url = "https://github.com/marlersoft/zigwin32/archive/e8739b32a33ce48a3286aba31918b26a9dfc6ef0.tar.gz", + .hash = "1220219ca4acfa5804ca39945f92554e93507b077c03605b7a4c1c0401f0c7121339", .lazy = true, }, }, diff --git a/src/EventHandler.zig b/src/EventHandler.zig index 37b6bf1..879ba12 100644 --- a/src/EventHandler.zig +++ b/src/EventHandler.zig @@ -16,7 +16,7 @@ pub const VTable = struct { pub fn to_owned(pimpl: anytype) Self { const impl = @typeInfo(@TypeOf(pimpl)); - const child: type = impl.Pointer.child; + const child: type = impl.pointer.child; return .{ .ptr = pimpl, .vtable = comptime &.{ @@ -56,7 +56,7 @@ var none = {}; pub fn to_unowned(pimpl: anytype) Self { const impl = @typeInfo(@TypeOf(pimpl)); - const child: type = impl.Pointer.child; + const child: type = impl.pointer.child; return .{ .ptr = pimpl, .vtable = comptime &.{ @@ -79,7 +79,7 @@ pub fn to_unowned(pimpl: anytype) Self { pub fn bind(pimpl: anytype, comptime f: *const fn (ctx: @TypeOf(pimpl), from: tp.pid_ref, m: tp.message) tp.result) Self { const impl = @typeInfo(@TypeOf(pimpl)); - const child: type = impl.Pointer.child; + const child: type = impl.pointer.child; return .{ .ptr = pimpl, .vtable = comptime &.{ diff --git a/src/LSP.zig b/src/LSP.zig index b14c5a5..61bc845 100644 --- a/src/LSP.zig +++ b/src/LSP.zig @@ -172,9 +172,9 @@ const Process = struct { const frame = tracy.initZone(@src(), .{ .name = module_name }); defer frame.deinit(); errdefer self.deinit(); - var method: []u8 = ""; - var bytes: []u8 = ""; - var err: []u8 = ""; + var method: []const u8 = ""; + var bytes: []const u8 = ""; + var err: []const u8 = ""; var code: u32 = 0; var cbor_id: []const u8 = ""; @@ -259,7 +259,7 @@ const Process = struct { } } - fn handle_output(self: *Process, bytes: []u8) Error!void { + fn handle_output(self: *Process, bytes: []const u8) Error!void { try self.recv_buf.appendSlice(bytes); self.write_log("### RECV:\n{s}\n###\n", .{bytes}); self.frame_message_recv() catch |e| { diff --git a/src/buffer/Buffer.zig b/src/buffer/Buffer.zig index ac3e7db..884ccc1 100644 --- a/src/buffer/Buffer.zig +++ b/src/buffer/Buffer.zig @@ -51,7 +51,7 @@ mtime: i64, utime: i64, pub const EolMode = enum { lf, crlf }; -pub const EolModeTag = @typeInfo(EolMode).Enum.tag_type; +pub const EolModeTag = @typeInfo(EolMode).@"enum".tag_type; const UndoNode = struct { root: Root, @@ -66,26 +66,26 @@ const UndoBranch = struct { }; pub const WalkerMut = struct { - keep_walking: bool = false, - found: bool = false, + keep_walking_: bool = false, + found_: bool = false, replace: ?Root = null, err: ?anyerror = null, - pub const keep_walking = WalkerMut{ .keep_walking = true }; - pub const stop = WalkerMut{ .keep_walking = false }; - pub const found = WalkerMut{ .found = true }; + pub const keep_walking = WalkerMut{ .keep_walking_ = true }; + pub const stop = WalkerMut{ .keep_walking_ = false }; + pub const found = WalkerMut{ .found_ = true }; const F = *const fn (ctx: *anyopaque, leaf: *const Leaf, metrics: Metrics) WalkerMut; }; pub const Walker = struct { - keep_walking: bool = false, - found: bool = false, + keep_walking_: bool = false, + found_: bool = false, err: ?anyerror = null, - pub const keep_walking = Walker{ .keep_walking = true }; - pub const stop = Walker{ .keep_walking = false }; - pub const found = Walker{ .found = true }; + pub const keep_walking = Walker{ .keep_walking_ = true }; + pub const stop = Walker{ .keep_walking_ = false }; + pub const found = Walker{ .found_ = true }; const F = *const fn (ctx: *anyopaque, leaf: *const Leaf, metrics: Metrics) Walker; }; @@ -121,8 +121,8 @@ pub const Branch = struct { fn merge_results_const(_: *const Branch, left: Walker, right: Walker) Walker { var result = Walker{}; result.err = if (left.err) |_| left.err else right.err; - result.keep_walking = left.keep_walking and right.keep_walking; - result.found = left.found or right.found; + result.keep_walking_ = left.keep_walking_ and right.keep_walking_; + result.found_ = left.found_ or right.found_; return result; } @@ -139,8 +139,8 @@ pub const Branch = struct { else Node.new(allocator, new_left, new_right) catch |e| return .{ .err = e }; } - result.keep_walking = left.keep_walking and right.keep_walking; - result.found = left.found or right.found; + result.keep_walking_ = left.keep_walking_ and right.keep_walking_; + result.found_ = left.found_ or right.found_; return result; } }; @@ -345,10 +345,10 @@ const Node = union(enum) { switch (self.*) { .node => |*node| { const left = node.left.walk_const(f, ctx, metrics); - if (!left.keep_walking) { + if (!left.keep_walking_) { var result = Walker{}; result.err = left.err; - result.found = left.found; + result.found_ = left.found_; return result; } const right = node.right.walk_const(f, ctx, metrics); @@ -362,10 +362,10 @@ const Node = union(enum) { switch (self.*) { .node => |*node| { const left = node.left.walk(allocator, f, ctx, metrics); - if (!left.keep_walking) { + if (!left.keep_walking_) { var result = WalkerMut{}; result.err = left.err; - result.found = left.found; + result.found_ = left.found_; if (left.replace) |p| { result.replace = Node.new(allocator, p, node.right) catch |e| return .{ .err = e }; } @@ -385,14 +385,14 @@ const Node = union(enum) { if (line >= left_bols) return node.right.walk_from_line_begin_const_internal(line - left_bols, f, ctx, metrics); const left_result = node.left.walk_from_line_begin_const_internal(line, f, ctx, metrics); - const right_result = if (left_result.found and left_result.keep_walking) node.right.walk_const(f, ctx, metrics) else Walker{}; + const right_result = if (left_result.found_ and left_result.keep_walking_) node.right.walk_const(f, ctx, metrics) else Walker{}; return node.merge_results_const(left_result, right_result); }, .leaf => |*l| { if (line == 0) { var result = f(ctx, l, metrics); if (result.err) |_| return result; - result.found = true; + result.found_ = true; return result; } return Walker.keep_walking; @@ -403,7 +403,7 @@ const Node = union(enum) { pub fn walk_from_line_begin_const(self: *const Node, line: usize, f: Walker.F, ctx: *anyopaque, metrics: Metrics) !bool { const result = self.walk_from_line_begin_const_internal(line, f, ctx, metrics); if (result.err) |e| return e; - return result.found; + return result.found_; } fn walk_from_line_begin_internal(self: *const Node, allocator: Allocator, line: usize, f: WalkerMut.F, ctx: *anyopaque, metrics: Metrics) WalkerMut { @@ -415,8 +415,8 @@ const Node = union(enum) { if (right_result.replace) |p| { var result = WalkerMut{}; result.err = right_result.err; - result.found = right_result.found; - result.keep_walking = right_result.keep_walking; + result.found_ = right_result.found_; + result.keep_walking_ = right_result.keep_walking_; result.replace = if (p.is_empty()) node.left else @@ -427,7 +427,7 @@ const Node = union(enum) { } } const left_result = node.left.walk_from_line_begin_internal(allocator, line, f, ctx, metrics); - const right_result = if (left_result.found and left_result.keep_walking) node.right.walk(allocator, f, ctx, metrics) else WalkerMut{}; + const right_result = if (left_result.found_ and left_result.keep_walking_) node.right.walk(allocator, f, ctx, metrics) else WalkerMut{}; return node.merge_results(allocator, left_result, right_result); }, .leaf => |*l| { @@ -437,7 +437,7 @@ const Node = union(enum) { result.replace = null; return result; } - result.found = true; + result.found_ = true; return result; } return WalkerMut.keep_walking; @@ -448,7 +448,7 @@ const Node = union(enum) { pub fn walk_from_line_begin(self: *const Node, allocator: Allocator, line: usize, f: WalkerMut.F, ctx: *anyopaque, metrics: Metrics) !struct { bool, ?Root } { const result = self.walk_from_line_begin_internal(allocator, line, f, ctx, metrics); if (result.err) |e| return e; - return .{ result.found, result.replace }; + return .{ result.found_, result.replace }; } fn find_line_node(self: *const Node, line: usize) ?*const Node { @@ -503,12 +503,12 @@ const Node = union(enum) { if (ret.err) |e| return .{ .err = e }; buf = buf[bytes..]; ctx.abs_col += @intCast(cols); - if (!ret.keep_walking) return Walker.stop; + if (!ret.keep_walking_) return Walker.stop; } if (leaf.eol) { const ret = ctx.walker_f(ctx.walker_ctx, "\n", 1, metrics); if (ret.err) |e| return .{ .err = e }; - if (!ret.keep_walking) return Walker.stop; + if (!ret.keep_walking_) return Walker.stop; ctx.abs_col = 0; } return Walker.keep_walking; @@ -665,7 +665,7 @@ const Node = union(enum) { var result = WalkerMut.keep_walking; if (ctx.delete_next_bol and ctx.bytes == 0) { result.replace = Leaf.new(ctx.allocator, leaf.buf, false, leaf.eol) catch |e| return .{ .err = e }; - result.keep_walking = false; + result.keep_walking_ = false; ctx.delete_next_bol = false; return result; } @@ -719,7 +719,7 @@ const Node = union(enum) { } } if (ctx.bytes == 0 and !ctx.delete_next_bol) - result.keep_walking = false; + result.keep_walking_ = false; } return result; } @@ -1206,6 +1206,9 @@ pub const LoadFromFileError = error{ DanglingSurrogateHalf, ExpectedSecondSurrogateHalf, UnexpectedSecondSurrogateHalf, + LockViolation, + ProcessNotFound, + Canceled, }; pub fn load_from_file( @@ -1296,6 +1299,7 @@ pub const StoreToFileError = error{ PathAlreadyExists, PipeBusy, ProcessFdQuotaExceeded, + ProcessNotFound, ReadOnlyFileSystem, RenameAcrossMountPoints, SharingViolation, diff --git a/src/command.zig b/src/command.zig index 71b1ea4..b3b0bf6 100644 --- a/src/command.zig +++ b/src/command.zig @@ -26,7 +26,7 @@ const Vtable = struct { meta: Metadata, }; -const Metadata = struct { +pub const Metadata = struct { description: []const u8 = &[_]u8{}, arguments: []const ArgumentType = &[_]ArgumentType{}, }; @@ -216,7 +216,7 @@ fn getTargetType(comptime Namespace: type) type { fn getCommands(comptime Namespace: type) []const CmdDef(*getTargetType(Namespace)) { @setEvalBranchQuota(10_000); comptime switch (@typeInfo(Namespace)) { - .Struct => |info| { + .@"struct" => |info| { var count = 0; const Target = getTargetType(Namespace); // @compileLog(Namespace, Target); @@ -257,14 +257,14 @@ pub fn Collection(comptime Namespace: type) type { fields_var[i] = .{ .name = cmd.name, .type = Clsr, - .default_value = null, + .default_value_ptr = null, .is_comptime = false, .alignment = if (@sizeOf(Clsr) > 0) @alignOf(Clsr) else 0, }; } const fields: [cmds.len]std.builtin.Type.StructField = fields_var; const Fields = @Type(.{ - .Struct = .{ + .@"struct" = .{ .is_tuple = false, .layout = .auto, .decls = &.{}, diff --git a/src/keybind/parse_flow.zig b/src/keybind/parse_flow.zig index 792aa26..4fe04c9 100644 --- a/src/keybind/parse_flow.zig +++ b/src/keybind/parse_flow.zig @@ -29,7 +29,7 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro var iter = std.mem.tokenizeScalar(u8, item, '+'); loop: while (iter.next()) |part| { if (part.len == 0) return parse_error("empty part in '{s}'", .{str}); - const modsInfo = @typeInfo(input.ModSet).Struct; + const modsInfo = @typeInfo(input.ModSet).@"struct"; inline for (modsInfo.fields) |field| { if (std.mem.eql(u8, part, field.name)) { if (@field(mods, field.name)) return parse_error("duplicate modifier '{s}' in '{s}'", .{ part, str }); diff --git a/src/log.zig b/src/log.zig index c0df56a..71d3521 100644 --- a/src/log.zig +++ b/src/log.zig @@ -1,8 +1,6 @@ const std = @import("std"); const tp = @import("thespian"); -const fba = std.heap.FixedBufferAllocator; - const Self = @This(); pub const max_log_message = tp.max_message_size - 128; @@ -11,7 +9,7 @@ allocator: std.mem.Allocator, receiver: Receiver, subscriber: ?tp.pid, heap: [32 + 1024]u8, -fba: fba, +fba: std.heap.FixedBufferAllocator, msg_store: MsgStoreT, const MsgStoreT = std.DoublyLinkedList([]u8); @@ -39,7 +37,7 @@ fn init(args: StartArgs) !*Self { .receiver = Receiver.init(Self.receive, p), .subscriber = null, .heap = undefined, - .fba = fba.init(&p.heap), + .fba = std.heap.FixedBufferAllocator.init(&p.heap), .msg_store = MsgStoreT{}, }; return p; diff --git a/src/main.zig b/src/main.zig index 6ccc4f0..497445f 100644 --- a/src/main.zig +++ b/src/main.zig @@ -24,7 +24,7 @@ pub const application_title = "Flow Control"; pub const application_subtext = "a programmer's text editor"; pub const application_description = application_title ++ ": " ++ application_subtext; -pub const std_options = .{ +pub const std_options: std.Options = .{ // .log_level = if (builtin.mode == .Debug) .debug else .warn, .log_level = if (builtin.mode == .Debug) .info else .warn, .logFn = log.std_log_function, @@ -512,7 +512,7 @@ fn read_cbor_config( else => return e, }) { var known = false; - inline for (@typeInfo(T).Struct.fields) |field_info| + inline for (@typeInfo(T).@"struct".fields) |field_info| if (comptime std.mem.eql(u8, "include_files", field_info.name)) { if (std.mem.eql(u8, field_name, field_info.name)) { known = true; @@ -571,7 +571,7 @@ fn write_text_config_file(comptime T: type, data: T, file_name: []const u8) !voi pub fn write_config_to_writer(comptime T: type, data: T, writer: anytype) !void { const default: T = .{}; - inline for (@typeInfo(T).Struct.fields) |field_info| { + inline for (@typeInfo(T).@"struct".fields) |field_info| { if (config_eql( field_info.type, @field(data, field_info.name), @@ -593,7 +593,7 @@ fn config_eql(comptime T: type, a: T, b: T) bool { else => {}, } switch (@typeInfo(T)) { - .Bool, .Int, .Float, .Enum => return a == b, + .bool, .int, .float, .@"enum" => return a == b, else => {}, } @compileError("unsupported config type " ++ @typeName(T)); diff --git a/src/renderer/vaxis/Plane.zig b/src/renderer/vaxis/Plane.zig index e1dd9d3..a3a5c23 100644 --- a/src/renderer/vaxis/Plane.zig +++ b/src/renderer/vaxis/Plane.zig @@ -37,7 +37,7 @@ pub const option = enum { }; pub fn init(nopts: *const Options, parent_: Plane) !Plane { - const opts = .{ + const opts: vaxis.Window.ChildOptions = .{ .x_off = @as(i17, @intCast(nopts.x)), .y_off = @as(i17, @intCast(nopts.y)), .width = @as(u16, @intCast(nopts.cols)), diff --git a/src/renderer/vaxis/input.zig b/src/renderer/vaxis/input.zig index ea4c8ea..15aaed9 100644 --- a/src/renderer/vaxis/input.zig +++ b/src/renderer/vaxis/input.zig @@ -8,7 +8,7 @@ pub const key = vaxis.Key; pub const Key = u21; pub const Mouse = vaxis.Mouse.Button; -pub const MouseType = @typeInfo(Mouse).Enum.tag_type; +pub const MouseType = @typeInfo(Mouse).@"enum".tag_type; pub const mouse = struct { pub const MOTION: Mouse = vaxis.Mouse.Button.none; diff --git a/src/renderer/vaxis/renderer.zig b/src/renderer/vaxis/renderer.zig index 01d43e6..ff66dfe 100644 --- a/src/renderer/vaxis/renderer.zig +++ b/src/renderer/vaxis/renderer.zig @@ -12,6 +12,7 @@ pub const Cell = @import("Cell.zig"); pub const CursorShape = vaxis.Cell.CursorShape; pub const style = @import("style.zig").StyleBits; +pub const styles = @import("style.zig"); const Self = @This(); pub const log_name = "vaxis"; @@ -80,13 +81,14 @@ var panic_cleanup: ?struct { vx: *vaxis.Vaxis, } = null; pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn { + _ = error_return_trace; // TODO: what to do with this in zig-0.14? const cleanup = panic_cleanup; panic_cleanup = null; if (cleanup) |self| { self.vx.deinit(self.allocator, self.tty.anyWriter()); self.tty.deinit(); } - return std.builtin.default_panic(msg, error_return_trace, ret_addr); + return std.debug.defaultPanic(msg, ret_addr); } pub fn run(self: *Self) !void { diff --git a/src/renderer/vaxis/style.zig b/src/renderer/vaxis/style.zig index 4420bd5..589fa44 100644 --- a/src/renderer/vaxis/style.zig +++ b/src/renderer/vaxis/style.zig @@ -4,11 +4,11 @@ pub const StyleBits = packed struct(u5) { undercurl: bool = false, underline: bool = false, italic: bool = false, - - pub const struck: StyleBits = .{ .struck = true }; - pub const bold: StyleBits = .{ .bold = true }; - pub const undercurl: StyleBits = .{ .undercurl = true }; - pub const underline: StyleBits = .{ .underline = true }; - pub const italic: StyleBits = .{ .italic = true }; - pub const normal: StyleBits = .{}; }; + +pub const struck: StyleBits = .{ .struck = true }; +pub const bold: StyleBits = .{ .bold = true }; +pub const undercurl: StyleBits = .{ .undercurl = true }; +pub const underline: StyleBits = .{ .underline = true }; +pub const italic: StyleBits = .{ .italic = true }; +pub const normal: StyleBits = .{}; diff --git a/src/ripgrep.zig b/src/ripgrep.zig index 3b86f2a..219c4d4 100644 --- a/src/ripgrep.zig +++ b/src/ripgrep.zig @@ -134,7 +134,7 @@ const Process = struct { fn receive(self: *Process, _: tp.pid_ref, m: tp.message) tp.result { errdefer self.deinit(); - var bytes: []u8 = ""; + var bytes: []const u8 = ""; if (try m.match(.{ "input", tp.extract(&bytes) })) { const sp = self.sp orelse return tp.exit_error(error.Closed, null); @@ -155,7 +155,7 @@ const Process = struct { } } - fn handle_output(self: *Process, bytes: []u8) !void { + fn handle_output(self: *Process, bytes: []const u8) !void { try self.output.appendSlice(bytes); } diff --git a/src/shell.zig b/src/shell.zig index 04f6217..05aa4d9 100644 --- a/src/shell.zig +++ b/src/shell.zig @@ -187,7 +187,7 @@ const Process = struct { fn receive(self: *Process, _: tp.pid_ref, m: tp.message) tp.result { errdefer self.deinit(); - var bytes: []u8 = ""; + var bytes: []const u8 = ""; if (try m.match(.{ "input", tp.extract(&bytes) })) { const sp = self.sp orelse return tp.exit_error(error.Closed, null); diff --git a/src/syntax/src/file_type.zig b/src/syntax/src/file_type.zig index dfecb1b..d6c4445 100644 --- a/src/syntax/src/file_type.zig +++ b/src/syntax/src/file_type.zig @@ -88,7 +88,7 @@ fn ft_func_name(comptime lang: []const u8) []const u8 { const LangFn = *const fn () callconv(.C) ?*const treez.Language; -const FirstLineMatch = struct { +pub const FirstLineMatch = struct { prefix: ?[]const u8 = null, content: ?[]const u8 = null, }; @@ -105,7 +105,7 @@ fn vec(comptime args: anytype) []const []const u8 { fn load_file_types(comptime Namespace: type) []const FileType { comptime switch (@typeInfo(Namespace)) { - .Struct => |info| { + .@"struct" => |info| { var count = 0; for (info.decls) |_| { // @compileLog(decl.name, @TypeOf(@field(Namespace, decl.name))); diff --git a/src/syntax/src/file_types.zig b/src/syntax/src/file_types.zig index a634930..c5f0895 100644 --- a/src/syntax/src/file_types.zig +++ b/src/syntax/src/file_types.zig @@ -1,3 +1,6 @@ +const file_type = @import("file_type.zig"); +const FirstLineMatch = file_type.FirstLineMatch; + pub const agda = .{ .description = "Agda", .extensions = .{"agda"}, @@ -10,7 +13,7 @@ pub const bash = .{ .icon = "󱆃", .extensions = .{ "sh", "bash", ".profile" }, .comment = "#", - .first_line_matches = .{ .prefix = "#!", .content = "sh" }, + .first_line_matches = FirstLineMatch{ .prefix = "#!", .content = "sh" }, .formatter = .{ "shfmt", "--indent", "4" }, .language_server = .{ "bash-language-server", "start" }, }; @@ -245,7 +248,7 @@ pub const lua = .{ .extensions = .{"lua"}, .comment = "--", .injections = "tree-sitter-lua/queries/injections.scm", - .first_line_matches = .{ .prefix = "--", .content = "lua" }, + .first_line_matches = FirstLineMatch{ .prefix = "--", .content = "lua" }, .language_server = .{"lua-lsp"}, }; @@ -255,7 +258,7 @@ pub const mail = .{ .extensions = .{ "eml", "mbox" }, .comment = ">", .highlights = "tree-sitter-mail/queries/mail/highlights.scm", - .first_line_matches = .{ .prefix = "From" }, + .first_line_matches = FirstLineMatch{ .prefix = "From" }, }; pub const make = .{ @@ -398,7 +401,7 @@ pub const python = .{ .icon = "󰌠", .extensions = .{ "py", "pyi" }, .comment = "#", - .first_line_matches = .{ .prefix = "#!", .content = "python" }, + .first_line_matches = FirstLineMatch{ .prefix = "#!", .content = "python" }, .language_server = .{"pylsp"}, }; @@ -511,7 +514,7 @@ pub const xml = .{ .extensions = .{"xml"}, .comment = "