From 069ca339a67cb770912c512d1a909dd4243feca9 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:18:17 +0000 Subject: [PATCH] feat: complete implementation for toggle diagnostics option --- book/src/editor.md | 1 + book/src/generated/typable-cmd.md | 1 - helix-term/src/ui/editor.rs | 6 +----- helix-view/src/handlers/diagnostics.rs | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/book/src/editor.md b/book/src/editor.md index 624bdff2..d7b023e4 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -53,6 +53,7 @@ | `popup-border` | Draw border around `popup`, `menu`, `all`, or `none` | `none` | | `indent-heuristic` | How the indentation for a newly inserted line is computed: `simple` just copies the indentation level from the previous line, `tree-sitter` computes the indentation based on the syntax tree and `hybrid` combines both approaches. If the chosen heuristic is not available, a different one will be used as a fallback (the fallback order being `hybrid` -> `tree-sitter` -> `simple`). | `hybrid` | `jump-label-alphabet` | The characters that are used to generate two character jump labels. Characters at the start of the alphabet are used first. | `"abcdefghijklmnopqrstuvwxyz"` +| `enable-diagnostics` | Whether to show obtrusive diagnostics, such as inline diagnostics and overlay diagnostics | `true` | | `end-of-line-diagnostics` | Minimum severity of diagnostics to render at the end of the line. Set to `disable` to disable entirely. Refer to the setting about `inline-diagnostics` for more details | "disable" | `clipboard-provider` | Which API to use for clipboard interaction. One of `pasteboard` (MacOS), `wayland`, `x-clip`, `x-sel`, `win-32-yank`, `termux`, `tmux`, `windows`, `termcode`, `none`, or a custom command set. | Platform and environment specific. | diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index 24bb8d7e..f0d9a0f4 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -88,4 +88,3 @@ | `:move`, `:mv` | Move the current buffer and its corresponding file to a different path | | `:yank-diagnostic` | Yank diagnostic(s) under primary cursor to register, or clipboard by default | | `:read`, `:r` | Load a file into buffer | -| `:toggle-diagnostics`, `:td` | Toggle Diagnostics | diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 13f2c5d5..ebf57a2a 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -189,11 +189,8 @@ impl EditorView { primary_cursor, }); } - let config = doc.config.load(); - // view.diagnostics_handler - // .active - // .set(config.enable_diagnostics); + let config = doc.config.load(); if config.enable_diagnostics { let width = view.inner_width(doc); @@ -202,7 +199,6 @@ impl EditorView { .show_cursorline_diagnostics(doc, view.id); let inline_diagnostic_config = config.inline_diagnostics.prepare(width, enable_cursor_line); - decorations.add_decoration(InlineDiagnostics::new( doc, theme, diff --git a/helix-view/src/handlers/diagnostics.rs b/helix-view/src/handlers/diagnostics.rs index b22e04dc..e582197d 100644 --- a/helix-view/src/handlers/diagnostics.rs +++ b/helix-view/src/handlers/diagnostics.rs @@ -106,7 +106,7 @@ impl DiagnosticsHandler { } pub fn show_cursorline_diagnostics(&self, doc: &Document, view: ViewId) -> bool { - if !self.active.take() { + if !self.active || !doc.config.load().enable_diagnostics { return false; } let cursor_line = doc