Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/ui/statusline.rs')
| -rw-r--r-- | helix-term/src/ui/statusline.rs | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 88c75fe1..a5b7f95e 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -1,6 +1,7 @@ +use std::borrow::Cow; + use helix_core::indent::IndentStyle; -use helix_core::{coords_at_pos, encoding, unicode::width::UnicodeWidthStr, Position}; -use helix_lsp::lsp::DiagnosticSeverity; +use helix_core::{coords_at_pos, diagnostic::Severity, encoding, Position}; use helix_view::document::DEFAULT_LANGUAGE_NAME; use helix_view::{ document::{Mode, SCRATCH_BUFFER_NAME}, @@ -156,7 +157,6 @@ where helix_view::editor::StatusLineElement::Spacer => render_spacer, helix_view::editor::StatusLineElement::VersionControl => render_version_control, helix_view::editor::StatusLineElement::Register => render_register, - helix_view::editor::StatusLineElement::CurrentWorkingDirectory => render_cwd, } } @@ -167,16 +167,18 @@ where let visible = context.focused; let config = context.editor.config(); let modenames = &config.statusline.mode; - let mode_str = match context.editor.mode() { - Mode::Insert => &modenames.insert, - Mode::Select => &modenames.select, - Mode::Normal => &modenames.normal, - }; let content = if visible { - format!(" {mode_str} ") + Cow::Owned(format!( + " {} ", + match context.editor.mode() { + Mode::Insert => &modenames.insert, + Mode::Select => &modenames.select, + Mode::Normal => &modenames.normal, + } + )) } else { // If not focused, explicitly leave an empty space instead of returning None. - " ".repeat(mode_str.width() + 2) + Cow::Borrowed(" ") }; let style = if visible && config.color_modes { match context.editor.mode() { @@ -215,14 +217,13 @@ fn render_diagnostics<'a, F>(context: &mut RenderContext<'a>, write: F) where F: Fn(&mut RenderContext<'a>, Span<'a>) + Copy, { - use helix_core::diagnostic::Severity; let (hints, info, warnings, errors) = context .doc .diagnostics() .iter() .fold((0, 0, 0, 0), |mut counts, diag| { - match diag.severity { + match diag.inner.severity { Some(Severity::Hint) | None => counts.0 += 1, Some(Severity::Info) => counts.1 += 1, Some(Severity::Warning) => counts.2 += 1, @@ -267,16 +268,16 @@ where use helix_core::diagnostic::Severity; let (hints, info, warnings, errors) = context.editor.diagnostics.values().flatten().fold( (0u32, 0u32, 0u32, 0u32), - |mut counts, (diag, _)| { + |mut counts, diag| { match diag.severity { // PERF: For large workspace diagnostics, this loop can be very tight. // // Most often the diagnostics will be for warnings and errors. // Errors should tend to be fixed fast, leaving warnings as the most common. - Some(DiagnosticSeverity::WARNING) => counts.2 += 1, - Some(DiagnosticSeverity::ERROR) => counts.3 += 1, - Some(DiagnosticSeverity::HINT) => counts.0 += 1, - Some(DiagnosticSeverity::INFORMATION) => counts.1 += 1, + Some(Severity::Warning) => counts.2 += 1, + Some(Severity::Error) => counts.3 += 1, + Some(Severity::Hint) => counts.0 += 1, + Some(Severity::Info) => counts.1 += 1, // Fallback to `hint`. _ => counts.0 += 1, } @@ -570,16 +571,3 @@ where }, ); } - -fn render_cwd<'a, F>(context: &mut RenderContext<'a>, write: F) -where - F: Fn(&mut RenderContext<'a>, Span<'a>) + Copy, -{ - let cwd = helix_stdx::env::current_working_dir(); - let cwd = cwd - .file_name() - .unwrap_or_default() - .to_string_lossy() - .to_string(); - write(context, cwd.into()) -} |