From e17719d4e9e93df5185b41459e59b473e99480e4 Mon Sep 17 00:00:00 2001 From: Gaurav Tyagi Date: Wed, 2 Nov 2022 21:09:20 +0530 Subject: [PATCH 1/7] add global error and warnings on status line --- helix-term/src/ui/statusline.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index b0e8ec5d2546..bdae5eb8c5e4 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -1,4 +1,5 @@ use helix_core::{coords_at_pos, encoding, Position}; +use helix_lsp::lsp::DiagnosticSeverity; use helix_view::{ document::{Mode, SCRATCH_BUFFER_NAME}, graphics::Rect, @@ -223,13 +224,28 @@ where counts }); + let (g_warnings, g_errors) = + context + .editor + .diagnostics + .values() + .flatten() + .fold((0, 0), |mut counts, diag| { + match diag.severity { + Some(DiagnosticSeverity::WARNING) => counts.0 += 1, + Some(DiagnosticSeverity::ERROR) | None => counts.1 += 1, + _ => {} + } + counts + }); + if warnings > 0 { write( context, "●".to_string(), Some(context.editor.theme.get("warning")), ); - write(context, format!(" {} ", warnings), None); + write(context, format!(" {}/{} ", warnings, g_warnings), None); } if errors > 0 { @@ -238,7 +254,7 @@ where "●".to_string(), Some(context.editor.theme.get("error")), ); - write(context, format!(" {} ", errors), None); + write(context, format!(" {}/{} ", errors, g_errors), None); } } From 7d06af842432a30fe9da3bb93bd49627eb3fbe9b Mon Sep 17 00:00:00 2001 From: Gaurav Tyagi Date: Thu, 3 Nov 2022 21:07:22 +0530 Subject: [PATCH 2/7] seprate dignostic count func to editor and docs and add config for workspace statusline diagnostic --- helix-term/src/ui/statusline.rs | 62 ++++++++++++++++----------------- helix-view/src/document.rs | 13 +++++++ helix-view/src/editor.rs | 20 ++++++++++- 3 files changed, 63 insertions(+), 32 deletions(-) diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index bdae5eb8c5e4..f4df46542082 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -1,5 +1,4 @@ use helix_core::{coords_at_pos, encoding, Position}; -use helix_lsp::lsp::DiagnosticSeverity; use helix_view::{ document::{Mode, SCRATCH_BUFFER_NAME}, graphics::Rect, @@ -142,6 +141,7 @@ where helix_view::editor::StatusLineElement::FileLineEnding => render_file_line_ending, helix_view::editor::StatusLineElement::FileType => render_file_type, helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics, + helix_view::editor::StatusLineElement::WorkspaceDiagnostics => render_workspace_diagnostics, helix_view::editor::StatusLineElement::Selections => render_selections, helix_view::editor::StatusLineElement::Position => render_position, helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage, @@ -210,34 +210,7 @@ fn render_diagnostics(context: &mut RenderContext, write: F) where F: Fn(&mut RenderContext, String, Option