Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mode separator to statusline #5022

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,10 @@ impl<T: Item + 'static> Component for Picker<T> {
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') => {
Comment on lines +586 to +589
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated to the PR and should be removed

self.move_by(1, Direction::Forward);
}
key!(PageDown) | ctrl!('d') => {
Expand Down
36 changes: 27 additions & 9 deletions helix-term/src/ui/statusline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,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!(
Expand All @@ -179,16 +188,25 @@ 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,
);

if visible {
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 {
fg: s.bg,
bg: context.editor.theme.get("ui.statusline").bg,
..Default::default()
});

write(context, separator.to_string(), mode_separator_style);
}
};
}
}

fn render_lsp_spinner<F>(context: &mut RenderContext, write: F)
Expand Down
3 changes: 3 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ pub struct StatusLineConfig {
pub right: Vec<StatusLineElement>,
pub separator: String,
pub mode: ModeConfig,
/// Seperator after statusline mode. Best used with 'color-modes = true'. Defaults to "".
pub mode_separator: String,
}

impl Default for StatusLineConfig {
Expand All @@ -283,6 +285,7 @@ impl Default for StatusLineConfig {
right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding],
separator: String::from("│"),
mode: ModeConfig::default(),
mode_separator: String::from(""),
}
}
}
Expand Down