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.rs74
1 files changed, 44 insertions, 30 deletions
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs
index 88c75fe1..4c96c816 100644
--- a/helix-term/src/ui/statusline.rs
+++ b/helix-term/src/ui/statusline.rs
@@ -1,5 +1,7 @@
+use std::borrow::Cow;
+
use helix_core::indent::IndentStyle;
-use helix_core::{coords_at_pos, encoding, unicode::width::UnicodeWidthStr, Position};
+use helix_core::{coords_at_pos, encoding, Position};
use helix_lsp::lsp::DiagnosticSeverity;
use helix_view::document::DEFAULT_LANGUAGE_NAME;
use helix_view::{
@@ -156,7 +158,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 +168,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() {
@@ -234,24 +237,36 @@ where
for sev in &context.editor.config().statusline.diagnostics {
match sev {
Severity::Hint if hints > 0 => {
- write(context, Span::styled("●", context.editor.theme.get("hint")));
+ write(
+ context,
+ Span::styled(Severity::Hint.indicator(), context.editor.theme.get("hint")),
+ );
write(context, format!(" {} ", hints).into());
}
Severity::Info if info > 0 => {
- write(context, Span::styled("●", context.editor.theme.get("info")));
+ write(
+ context,
+ Span::styled(Severity::Info.indicator(), context.editor.theme.get("info")),
+ );
write(context, format!(" {} ", info).into());
}
Severity::Warning if warnings > 0 => {
write(
context,
- Span::styled("●", context.editor.theme.get("warning")),
+ Span::styled(
+ Severity::Warning.indicator(),
+ context.editor.theme.get("warning"),
+ ),
);
write(context, format!(" {} ", warnings).into());
}
Severity::Error if errors > 0 => {
write(
context,
- Span::styled("●", context.editor.theme.get("error")),
+ Span::styled(
+ Severity::Error.indicator(),
+ context.editor.theme.get("error"),
+ ),
);
write(context, format!(" {} ", errors).into());
}
@@ -301,24 +316,36 @@ where
for sev in sevs_to_show {
match sev {
Severity::Hint if hints > 0 => {
- write(context, Span::styled("●", context.editor.theme.get("hint")));
+ write(
+ context,
+ Span::styled(Severity::Hint.indicator(), context.editor.theme.get("hint")),
+ );
write(context, format!(" {} ", hints).into());
}
Severity::Info if info > 0 => {
- write(context, Span::styled("●", context.editor.theme.get("info")));
+ write(
+ context,
+ Span::styled(Severity::Info.indicator(), context.editor.theme.get("info")),
+ );
write(context, format!(" {} ", info).into());
}
Severity::Warning if warnings > 0 => {
write(
context,
- Span::styled("●", context.editor.theme.get("warning")),
+ Span::styled(
+ Severity::Warning.indicator(),
+ context.editor.theme.get("warning"),
+ ),
);
write(context, format!(" {} ", warnings).into());
}
Severity::Error if errors > 0 => {
write(
context,
- Span::styled("●", context.editor.theme.get("error")),
+ Span::styled(
+ Severity::Error.indicator(),
+ context.editor.theme.get("error"),
+ ),
);
write(context, format!(" {} ", errors).into());
}
@@ -570,16 +597,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())
-}