diff --git a/src/LSP.zig b/src/LSP.zig index 171bbb1..99bf74f 100644 --- a/src/LSP.zig +++ b/src/LSP.zig @@ -41,7 +41,8 @@ pub fn send_request( var cb = std.ArrayList(u8).init(self.allocator); defer cb.deinit(); try cbor.writeValue(cb.writer(), m); - return RequestContext(@TypeOf(ctx)).send(allocator, self.pid.ref(), ctx, tp.message.fmt(.{ "REQ", method, cb.items })); + const request_timeout: u64 = @intCast(std.time.ns_per_s * tp.env.get().num("lsp-request-timeout")); + return RequestContext(@TypeOf(ctx)).send(allocator, self.pid.ref(), ctx, request_timeout, tp.message.fmt(.{ "REQ", method, cb.items })); } pub fn send_notification(self: Self, method: []const u8, m: anytype) (OutOfMemoryError || SendError)!void { @@ -71,7 +72,8 @@ fn RequestContext(T: type) type { const Self = @This(); const ReceiverT = tp.Receiver(*@This()); - fn send(a: std.mem.Allocator, to: tp.pid_ref, ctx: T, request: tp.message) (OutOfMemoryError || SpawnError)!void { + fn send(a: std.mem.Allocator, to: tp.pid_ref, ctx: T, timeout_ns: u64, request: tp.message) (OutOfMemoryError || SpawnError)!void { + _ = timeout_ns; const self = try a.create(@This()); self.* = .{ .receiver = undefined, diff --git a/src/config.zig b/src/config.zig index 4d4a078..eb37c6d 100644 --- a/src/config.zig +++ b/src/config.zig @@ -25,6 +25,8 @@ bottom_bar: []const u8 = "mode file log selection diagnostics keybind linenumber show_scrollbars: bool = true, show_fileicons: bool = true, +lsp_request_timeout: usize = 10, + include_files: []const u8 = "", pub const DigitStyle = enum { diff --git a/src/tui/status/clock.zig b/src/tui/status/clock.zig index d6e8391..1945bca 100644 --- a/src/tui/status/clock.zig +++ b/src/tui/status/clock.zig @@ -9,22 +9,16 @@ const Plane = @import("renderer").Plane; const Widget = @import("../Widget.zig"); const MessageFilter = @import("../MessageFilter.zig"); const tui = @import("../tui.zig"); -const fonts = @import("../fonts.zig"); - -const DigitStyle = fonts.DigitStyle; allocator: std.mem.Allocator, plane: Plane, tick_timer: ?tp.Cancellable = null, on_event: ?EventHandler, tz: zeit.timezone.TimeZone, -style: ?DigitStyle, const Self = @This(); -pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?EventHandler, arg: ?[]const u8) @import("widget.zig").CreateError!Widget { - const style: ?DigitStyle = if (arg) |style| std.meta.stringToEnum(DigitStyle, style) orelse null else null; - +pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget { var env = std.process.getEnvMap(allocator) catch |e| { std.log.err("clock: std.process.getEnvMap failed with {any}", .{e}); return error.WidgetInitFailed; @@ -39,7 +33,6 @@ pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?Event std.log.err("clock: zeit.local failed with {any}", .{e}); return error.WidgetInitFailed; }, - .style = style, }; try tui.message_filters().add(MessageFilter.bind(self, receive_tick)); self.update_tick_timer(.init); @@ -81,14 +74,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { const now = zeit.instant(.{ .timezone = &self.tz }) catch return false; const dt = now.time(); - - var buf: [64]u8 = undefined; - var fbs = std.io.fixedBufferStream(&buf); - const writer = fbs.writer(); - std.fmt.format(writer, "{d:0>2}:{d:0>2}", .{ dt.hour, dt.minute }) catch {}; - - const value_str = fbs.getWritten(); - for (value_str, 0..) |_, i| _ = self.plane.putstr(fonts.get_digit_ascii(value_str[i .. i + 1], self.style orelse .ascii)) catch {}; + _ = self.plane.print("{d:0>2}:{d:0>2}", .{ dt.hour, dt.minute }) catch {}; return false; } diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 49d6e11..5e047ab 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -114,6 +114,7 @@ fn init(allocator: Allocator) InitError!*Self { if (frame_rate != 0) conf.frame_rate = frame_rate; tp.env.get().num_set("frame-rate", @intCast(conf.frame_rate)); + tp.env.get().num_set("lsp-request-timeout", @intCast(conf.lsp_request_timeout)); const frame_time = std.time.us_per_s / conf.frame_rate; const frame_clock = try tp.metronome.init(frame_time);