From b602dd399d5304517ce9ee42db59a0637dc41308 Mon Sep 17 00:00:00 2001 From: neva1ack <95966883+neva1ack@users.noreply.github.com> Date: Tue, 6 Dec 2022 22:22:44 +1030 Subject: [PATCH 1/7] Add mode separator to statusline --- helix-term/src/ui/statusline.rs | 43 ++++++++++++++++++++++++++------- helix-view/src/editor.rs | 11 +++++++++ 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 501faea3963e..cf75750f87d1 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -9,6 +9,7 @@ use helix_view::{ use crate::ui::ProgressSpinners; +use helix_view::editor::ModeSeparator; use helix_view::editor::StatusLineElement as StatusLineElementID; use tui::buffer::Buffer as Surface; use tui::text::{Span, Spans}; @@ -164,6 +165,15 @@ where let visible = context.focused; let config = context.editor.config(); let modenames = &config.statusline.mode; + let mode_style = if visible && config.color_modes { + match context.editor.mode() { + Mode::Insert => Some(context.editor.theme.get("ui.statusline.insert")), + Mode::Select => Some(context.editor.theme.get("ui.statusline.select")), + Mode::Normal => Some(context.editor.theme.get("ui.statusline.normal")), + } + } else { + None + }; write( context, format!( @@ -179,16 +189,31 @@ where " " } ), - if visible && config.color_modes { - match context.editor.mode() { - Mode::Insert => Some(context.editor.theme.get("ui.statusline.insert")), - Mode::Select => Some(context.editor.theme.get("ui.statusline.select")), - Mode::Normal => Some(context.editor.theme.get("ui.statusline.normal")), - } - } else { - None - }, + mode_style, ); + + match config.statusline.mode_separator { + ModeSeparator::Flat => {} + _ => { + // invert the mode style background and foreground + let mode_separator_style = mode_style.map(|s| { + let mut c = s.clone(); + c.fg = s.bg; + c.bg = s.fg; + return c; + }); + + let mode_separator_string = match config.statusline.mode_separator { + ModeSeparator::Angled => "", + ModeSeparator::Slanted => "", + ModeSeparator::Rounded => "", + ModeSeparator::Flat => unreachable!(), + } + .to_string(); + + write(context, mode_separator_string, mode_separator_style); + } + }; } fn render_lsp_spinner(context: &mut RenderContext, write: F) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 973cf82ea109..4145bd8a542e 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -271,6 +271,16 @@ pub struct StatusLineConfig { pub right: Vec, pub separator: String, pub mode: ModeConfig, + pub mode_separator: ModeSeparator, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum ModeSeparator { + Flat, + Angled, + Rounded, + Slanted, } impl Default for StatusLineConfig { @@ -283,6 +293,7 @@ impl Default for StatusLineConfig { right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding], separator: String::from("│"), mode: ModeConfig::default(), + mode_separator: ModeSeparator::Flat, } } } From 609bbfbc3466d4a62c6356b9710fd7c548e79b5c Mon Sep 17 00:00:00 2001 From: neva1ack <95966883+neva1ack@users.noreply.github.com> Date: Tue, 6 Dec 2022 22:45:34 +1030 Subject: [PATCH 2/7] Fix: typos and inconsistencies --- helix-term/src/ui/statusline.rs | 11 +++++------ helix-view/src/editor.rs | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index cf75750f87d1..13094cb7210d 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -200,18 +200,17 @@ where let mut c = s.clone(); c.fg = s.bg; c.bg = s.fg; - return c; + c }); - let mode_separator_string = match config.statusline.mode_separator { + let mode_separator = match config.statusline.mode_separator { ModeSeparator::Angled => "", ModeSeparator::Slanted => "", - ModeSeparator::Rounded => "", + ModeSeparator::Round => "", ModeSeparator::Flat => unreachable!(), - } - .to_string(); + }; - write(context, mode_separator_string, mode_separator_style); + write(context, mode_separator.to_string(), mode_separator_style); } }; } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 4145bd8a542e..82c92eb0c87b 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -279,7 +279,7 @@ pub struct StatusLineConfig { pub enum ModeSeparator { Flat, Angled, - Rounded, + Round, Slanted, } From cf679f0caa595c539d84d0079d660ccf464d2139 Mon Sep 17 00:00:00 2001 From: neva1ack <95966883+neva1ack@users.noreply.github.com> Date: Thu, 8 Dec 2022 22:54:25 +1030 Subject: [PATCH 3/7] Fix: use ui.statusline background on mode separator --- helix-term/src/ui/statusline.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 13094cb7210d..4e845b23984b 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -195,12 +195,12 @@ where match config.statusline.mode_separator { ModeSeparator::Flat => {} _ => { - // invert the mode style background and foreground - let mode_separator_style = mode_style.map(|s| { - let mut c = s.clone(); - c.fg = s.bg; - c.bg = s.fg; - c + // use mode style as mode separator style except set + // background to statusline background + let mode_separator_style = mode_style.map(|s| Style { + fg: s.bg, + bg: context.editor.theme.get("ui.statusline").bg, + ..Default::default() }); let mode_separator = match config.statusline.mode_separator { From 1c2b82828194792a3269bdf6d48204ab207c24f5 Mon Sep 17 00:00:00 2001 From: neva1ack <95966883+neva1ack@users.noreply.github.com> Date: Sat, 10 Dec 2022 05:10:35 +1030 Subject: [PATCH 4/7] Fix: mode sep hybrid presents and abitrary, only show when visible --- helix-term/src/ui/statusline.rs | 45 +++++++++++++++++---------------- helix-view/src/editor.rs | 13 ++-------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 4e845b23984b..05f23a2b52a5 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -9,7 +9,6 @@ use helix_view::{ use crate::ui::ProgressSpinners; -use helix_view::editor::ModeSeparator; use helix_view::editor::StatusLineElement as StatusLineElementID; use tui::buffer::Buffer as Surface; use tui::text::{Span, Spans}; @@ -192,27 +191,29 @@ where mode_style, ); - match config.statusline.mode_separator { - ModeSeparator::Flat => {} - _ => { - // use mode style as mode separator style except set - // background to statusline background - let mode_separator_style = mode_style.map(|s| Style { - fg: s.bg, - bg: context.editor.theme.get("ui.statusline").bg, - ..Default::default() - }); - - let mode_separator = match config.statusline.mode_separator { - ModeSeparator::Angled => "", - ModeSeparator::Slanted => "", - ModeSeparator::Round => "", - ModeSeparator::Flat => unreachable!(), - }; - - write(context, mode_separator.to_string(), mode_separator_style); - } - }; + if visible { + match config.statusline.mode_separator.as_str() { + "" => {} + _ => { + // use mode style as mode separator style except set + // background to statusline background + let mode_separator_style = mode_style.map(|s| Style { + fg: s.bg, + bg: context.editor.theme.get("ui.statusline").bg, + ..Default::default() + }); + + let mode_separator = match config.statusline.mode_separator.as_str() { + "angled" => "", + "slanted" => "", + "round" => "", + s => s, + }; + + write(context, mode_separator.to_string(), mode_separator_style); + } + }; + } } fn render_lsp_spinner(context: &mut RenderContext, write: F) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 82c92eb0c87b..3a91daef113c 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -271,16 +271,7 @@ pub struct StatusLineConfig { pub right: Vec, pub separator: String, pub mode: ModeConfig, - pub mode_separator: ModeSeparator, -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "kebab-case")] -pub enum ModeSeparator { - Flat, - Angled, - Round, - Slanted, + pub mode_separator: String, } impl Default for StatusLineConfig { @@ -293,7 +284,7 @@ impl Default for StatusLineConfig { right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding], separator: String::from("│"), mode: ModeConfig::default(), - mode_separator: ModeSeparator::Flat, + mode_separator: String::from(""), } } } From 631349d81f3eca9661b617ee097519fb376d259d Mon Sep 17 00:00:00 2001 From: neva1ack <95966883+neva1ack@users.noreply.github.com> Date: Sat, 10 Dec 2022 06:52:21 +1030 Subject: [PATCH 5/7] Fix: private-use unicode not acceptable for core --- helix-term/src/ui/statusline.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 05f23a2b52a5..76b3efca2002 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -192,9 +192,9 @@ where ); if visible { - match config.statusline.mode_separator.as_str() { - "" => {} - _ => { + match &config.statusline.mode_separator { + separator if separator.is_empty() => {} + separator => { // use mode style as mode separator style except set // background to statusline background let mode_separator_style = mode_style.map(|s| Style { @@ -203,14 +203,7 @@ where ..Default::default() }); - let mode_separator = match config.statusline.mode_separator.as_str() { - "angled" => "", - "slanted" => "", - "round" => "", - s => s, - }; - - write(context, mode_separator.to_string(), mode_separator_style); + write(context, separator.to_string(), mode_separator_style); } }; } From ed44ddeea2bf5776367c8081a977190d882b2426 Mon Sep 17 00:00:00 2001 From: neva1ack <95966883+neva1ack@users.noreply.github.com> Date: Sat, 10 Dec 2022 06:54:07 +1030 Subject: [PATCH 6/7] doc: mode separator config --- helix-view/src/editor.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 3a91daef113c..36f6724ada63 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -271,6 +271,7 @@ pub struct StatusLineConfig { pub right: Vec, pub separator: String, pub mode: ModeConfig, + /// Seperator after statusline mode. Best used with 'color-modes = true'. Defaults to "". pub mode_separator: String, } From 389afe950c2ba9e72c46d9f94c321e7072769bc9 Mon Sep 17 00:00:00 2001 From: neva1ack <95966883+neva1ack@users.noreply.github.com> Date: Fri, 20 Jan 2023 22:03:16 +1030 Subject: [PATCH 7/7] Add: move in picker with ctrl+j-k --- helix-term/src/ui/picker.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 5e9ca3d887a5..7fe8cb6061a7 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -583,10 +583,10 @@ impl Component for Picker { cx.editor.reset_idle_timer(); match key_event { - shift!(Tab) | key!(Up) | ctrl!('p') => { + shift!(Tab) | key!(Up) | ctrl!('p') | ctrl!('k') => { self.move_by(1, Direction::Backward); } - key!(Tab) | key!(Down) | ctrl!('n') => { + key!(Tab) | key!(Down) | ctrl!('n') | ctrl!('j') => { self.move_by(1, Direction::Forward); } key!(PageDown) | ctrl!('d') => {