mirror of https://github.com/helix-editor/helix
Add configureable statusline mode names (#3311)
* Added 'long-mode' statusline element * Added customizable statusline mode names * Removed a string clone * Added documentation * Updated documentation, moved modenames to a seperate section * Update configuration.md * Documentation update * Documentation update * Documentation update * Update configuration.md * Update configuration.md * Fixed merge error * Update configuration.md * Update configuration.mdpull/4085/head
parent
589d17c758
commit
77f33e7b20
|
@ -68,13 +68,27 @@ left = ["mode", "spinner"]
|
||||||
center = ["file-name"]
|
center = ["file-name"]
|
||||||
right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
|
right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
|
||||||
separator = "│"
|
separator = "│"
|
||||||
|
mode.normal = "NORMAL"
|
||||||
|
mode.insert = "INSERT"
|
||||||
|
mode.select = "SELECT"
|
||||||
```
|
```
|
||||||
|
The `[editor.statusline]` key takes the following sub-keys:
|
||||||
|
|
||||||
The following elements can be configured:
|
| Key | Description | Default |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `left` | A list of elements aligned to the left of the statusline | `["mode", "spinner", "file-name"]` |
|
||||||
|
| `center` | A list of elements aligned to the middle of the statusline | `[]` |
|
||||||
|
| `right` | A list of elements aligned to the right of the statusline | `["diagnostics", "selections", "position", "file-encoding"]` |
|
||||||
|
| `separator` | The character used to separate elements in the statusline | `"│"` |
|
||||||
|
| `mode.normal` | The text shown in the `mode` element for normal mode | `"NOR"` |
|
||||||
|
| `mode.insert` | The text shown in the `mode` element for insert mode | `"INS"` |
|
||||||
|
| `mode.select` | The text shown in the `mode` element for select mode | `"SEL"` |
|
||||||
|
|
||||||
|
The following statusline elements can be configured:
|
||||||
|
|
||||||
| Key | Description |
|
| Key | Description |
|
||||||
| ------ | ----------- |
|
| ------ | ----------- |
|
||||||
| `mode` | The current editor mode (`NOR`/`INS`/`SEL`) |
|
| `mode` | The current editor mode (`mode.normal`/`mode.insert`/`mode.select`) |
|
||||||
| `spinner` | A progress spinner indicating LSP activity |
|
| `spinner` | A progress spinner indicating LSP activity |
|
||||||
| `file-name` | The path/name of the opened file |
|
| `file-name` | The path/name of the opened file |
|
||||||
| `file-encoding` | The encoding of the opened file if it differs from UTF-8 |
|
| `file-encoding` | The encoding of the opened file if it differs from UTF-8 |
|
||||||
|
|
|
@ -154,16 +154,16 @@ where
|
||||||
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
||||||
{
|
{
|
||||||
let visible = context.focused;
|
let visible = context.focused;
|
||||||
|
let modenames = &context.editor.config().statusline.mode;
|
||||||
write(
|
write(
|
||||||
context,
|
context,
|
||||||
format!(
|
format!(
|
||||||
" {} ",
|
" {} ",
|
||||||
if visible {
|
if visible {
|
||||||
match context.editor.mode() {
|
match context.editor.mode() {
|
||||||
Mode::Insert => "INS",
|
Mode::Insert => &modenames.insert,
|
||||||
Mode::Select => "SEL",
|
Mode::Select => &modenames.select,
|
||||||
Mode::Normal => "NOR",
|
Mode::Normal => &modenames.normal,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If not focused, explicitly leave an empty space instead of returning None.
|
// If not focused, explicitly leave an empty space instead of returning None.
|
||||||
|
|
|
@ -260,6 +260,7 @@ pub struct StatusLineConfig {
|
||||||
pub center: Vec<StatusLineElement>,
|
pub center: Vec<StatusLineElement>,
|
||||||
pub right: Vec<StatusLineElement>,
|
pub right: Vec<StatusLineElement>,
|
||||||
pub separator: String,
|
pub separator: String,
|
||||||
|
pub mode: ModeConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for StatusLineConfig {
|
impl Default for StatusLineConfig {
|
||||||
|
@ -271,6 +272,25 @@ impl Default for StatusLineConfig {
|
||||||
center: vec![],
|
center: vec![],
|
||||||
right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding],
|
right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding],
|
||||||
separator: String::from("│"),
|
separator: String::from("│"),
|
||||||
|
mode: ModeConfig::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
|
||||||
|
pub struct ModeConfig {
|
||||||
|
pub normal: String,
|
||||||
|
pub insert: String,
|
||||||
|
pub select: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ModeConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
normal: String::from("NOR"),
|
||||||
|
insert: String::from("INS"),
|
||||||
|
select: String::from("SEL"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue