From b8be8dd9239f1b08cb578539e634de73751fbad8 Mon Sep 17 00:00:00 2001 From: pommicket Date: Thu, 7 Sep 2023 19:44:44 -0400 Subject: add show-diagnostics setting --- buffer.c | 9 +++++++++ config.c | 1 + ted-internal.h | 1 + 3 files changed, 11 insertions(+) diff --git a/buffer.c b/buffer.c index 19c14a5..7c0e481 100644 --- a/buffer.c +++ b/buffer.c @@ -3315,6 +3315,11 @@ void buffer_render(TextBuffer *buffer, Rect r) { float render_start_y = y1 - (float)(buffer->scroll_y - start_line) * char_height; // where the 1st line is rendered + + if (!settings->show_diagnostics) { + buffer_diagnostics_clear(buffer); + } + const Diagnostic *hover_diagnostic = NULL; // line numbering if (!buffer->is_line_buffer && settings->line_numbers) { @@ -3882,7 +3887,11 @@ static int diagnostic_cmp(const void *av, const void *bv) { } void buffer_publish_diagnostics(TextBuffer *buffer, const LSPRequest *request, LSPDiagnostic *diagnostics) { + const Settings *settings = buffer_settings(buffer); buffer_diagnostics_clear(buffer); + if (!settings->show_diagnostics) { + return; + } arr_foreach_ptr(diagnostics, const LSPDiagnostic, diagnostic) { Diagnostic *d = arr_addp(buffer->diagnostics); d->pos = buffer_pos_from_lsp(buffer, diagnostic->range.start); diff --git a/config.c b/config.c index e575803..c17306a 100644 --- a/config.c +++ b/config.c @@ -122,6 +122,7 @@ static const SettingBool settings_bool[] = { {"crlf-windows", &settings_zero.crlf_windows, true}, {"jump-to-build-error", &settings_zero.jump_to_build_error, true}, {"force-monospace", &settings_zero.force_monospace, true}, + {"show-diagnostics", &settings_zero.show_diagnostics, true}, }; static const SettingU8 settings_u8[] = { {"tab-width", &settings_zero.tab_width, 1, 100, true}, diff --git a/ted-internal.h b/ted-internal.h index e5b9874..42592fb 100644 --- a/ted-internal.h +++ b/ted-internal.h @@ -135,6 +135,7 @@ struct Settings { bool crlf_windows; bool jump_to_build_error; bool force_monospace; + bool show_diagnostics; KeyCombo hover_key; KeyCombo highlight_key; u8 tab_width; -- cgit v1.2.3