From 39638b639427d31d1e8d58834bd51212b55529fd Mon Sep 17 00:00:00 2001 From: Rolo Date: Mon, 30 Dec 2024 04:57:13 -0800 Subject: [PATCH 01/16] feat: add support for basic icons --- helix-term/src/ui/editor.rs | 12 +- helix-term/src/ui/statusline.rs | 43 ++++-- helix-view/src/editor.rs | 6 + helix-view/src/editor/config.rs | 250 ++++++++++++++++++++++++++++++++ helix-view/src/gutter.rs | 18 ++- 5 files changed, 307 insertions(+), 22 deletions(-) create mode 100644 helix-view/src/editor/config.rs diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 5d028415e85f..14c61536a3fc 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -24,7 +24,7 @@ use helix_core::{ }; use helix_view::{ annotations::diagnostics::DiagnosticFilter, - document::{Mode, SavePoint, SCRATCH_BUFFER_NAME}, + document::{Mode, SavePoint, DEFAULT_LANGUAGE_NAME, SCRATCH_BUFFER_NAME}, editor::{CompleteAction, CursorShapeConfig}, graphics::{Color, CursorKind, Modifier, Rect, Style}, input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind}, @@ -646,7 +646,15 @@ impl EditorView { bufferline_inactive }; - let text = format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" }); + let lang = doc.language_name().unwrap_or(DEFAULT_LANGUAGE_NAME); + let config = editor.config(); + let icon = config.icons.mime.lang(lang); + + let text = format!( + " {icon} {}{} ", + fname, + if doc.is_modified() { "[+]" } else { "" } + ); let used_width = viewport.x.saturating_sub(x); let rem_width = surface.area.width.saturating_sub(used_width); diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 7437cbd074e5..b096a4753422 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -243,7 +243,13 @@ where if warnings > 0 { write( context, - "●".to_string(), + context + .editor + .config() + .icons + .diagnostic + .warning() + .to_string(), Some(context.editor.theme.get("warning")), ); write(context, format!(" {} ", warnings), None); @@ -252,7 +258,7 @@ where if errors > 0 { write( context, - "●".to_string(), + context.editor.config().icons.diagnostic.error().to_string(), Some(context.editor.theme.get("error")), ); write(context, format!(" {} ", errors), None); @@ -285,7 +291,13 @@ where if warnings > 0 { write( context, - "●".to_string(), + context + .editor + .config() + .icons + .diagnostic + .warning() + .to_string(), Some(context.editor.theme.get("warning")), ); write(context, format!(" {} ", warnings), None); @@ -294,7 +306,7 @@ where if errors > 0 { write( context, - "●".to_string(), + context.editor.config().icons.diagnostic.error().to_string(), Some(context.editor.theme.get("error")), ); write(context, format!(" {} ", errors), None); @@ -410,9 +422,11 @@ fn render_file_type(context: &mut RenderContext, write: F) where F: Fn(&mut RenderContext, String, Option