Add register statusline element (#7222)

pull/7296/head
spectre256 1 year ago committed by GitHub
parent 993c68ad6f
commit 00b152facd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -160,6 +160,7 @@ where
helix_view::editor::StatusLineElement::Separator => render_separator, helix_view::editor::StatusLineElement::Separator => render_separator,
helix_view::editor::StatusLineElement::Spacer => render_spacer, helix_view::editor::StatusLineElement::Spacer => render_spacer,
helix_view::editor::StatusLineElement::VersionControl => render_version_control, helix_view::editor::StatusLineElement::VersionControl => render_version_control,
helix_view::editor::StatusLineElement::Register => render_register,
} }
} }
@ -489,3 +490,12 @@ where
write(context, head, None); 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)
}
}

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

Loading…
Cancel
Save