Add register statusline element (#7222)

This commit is contained in:
spectre256 2023-06-08 15:34:07 -04:00 committed by GitHub
parent 993c68ad6f
commit 00b152facd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View file

@ -117,6 +117,7 @@ The following statusline elements can be configured:
| `separator` | The string defined in `editor.statusline.separator` (defaults to `"│"`) |
| `spacer` | Inserts a space between elements (multiple/contiguous spacers may be specified) |
| `version-control` | The current branch name or detached commit hash of the opened workspace |
| `register` | The current selected register |
### `[editor.lsp]` Section

View file

@ -160,6 +160,7 @@ where
helix_view::editor::StatusLineElement::Separator => render_separator,
helix_view::editor::StatusLineElement::Spacer => render_spacer,
helix_view::editor::StatusLineElement::VersionControl => render_version_control,
helix_view::editor::StatusLineElement::Register => render_register,
}
}
@ -489,3 +490,12 @@ where
write(context, head, None);
}
fn render_register<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
{
if let Some(reg) = context.editor.selected_register {
write(context, format!(" reg={} ", reg), None)
}
}

View file

@ -403,7 +403,13 @@ impl Default for StatusLineConfig {
E::FileModificationIndicator,
],
center: vec![],
right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding],
right: vec![
E::Diagnostics,
E::Selections,
E::Register,
E::Position,
E::FileEncoding,
],
separator: String::from(""),
mode: ModeConfig::default(),
}
@ -484,6 +490,9 @@ pub enum StatusLineElement {
/// Current version control information
VersionControl,
/// Indicator for selected register
Register,
}
// Cursor shape is read and used on every rendered frame and so needs