From 1d59d1e46adf60ad93ad9f01957f9258a7df90fb Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 6 Feb 2025 10:55:42 +0100 Subject: [PATCH] feat: add configuration and command to toggle display of inline diagnostics --- src/config.zig | 1 + src/tui/editor.zig | 3 ++- src/tui/mainview.zig | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/config.zig b/src/config.zig index 3f9f50d..8f74b58 100644 --- a/src/config.zig +++ b/src/config.zig @@ -12,6 +12,7 @@ enable_terminal_color_scheme: bool = builtin.os.tag != .windows, highlight_current_line: bool = true, highlight_current_line_gutter: bool = true, whitespace_mode: []const u8 = "none", +inline_diagnostics: bool = true, animation_min_lag: usize = 0, //milliseconds animation_max_lag: usize = 150, //milliseconds enable_format_on_save: bool = false, diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 76f227b..92fe573 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -1010,7 +1010,8 @@ pub const Editor = struct { self.render_syntax(theme, cache, root) catch {}; self.render_cursors(theme, ctx_.cell_map) catch {}; self.render_whitespace_map(theme, ctx_.cell_map) catch {}; - self.render_diagnostics(theme, hl_row, ctx_.cell_map) catch {}; + if (tui.config().inline_diagnostics) + self.render_diagnostics(theme, hl_row, ctx_.cell_map) catch {}; } fn render_cursors(self: *Self, theme: *const Widget.Theme, cell_map: CellMap) !void { diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index 132bcc6..4d88df6 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -595,6 +595,13 @@ const cmds = struct { } pub const gutter_style_next_meta: Meta = .{ .description = "Next line number style" }; + pub fn toggle_inline_diagnostics(_: *Self, _: Ctx) Result { + const config = tui.config_mut(); + config.inline_diagnostics = !config.inline_diagnostics; + try tui.save_config(); + } + pub const toggle_inline_diagnostics_meta: Meta = .{ .description = "Toggle display of diagnostics inline" }; + pub fn goto_next_file_or_diagnostic(self: *Self, ctx: Ctx) Result { if (self.is_panel_view_showing(filelist_view)) { switch (self.file_list_type) {