From 846a6b65c3d13f49b571beee2189d17b71c92e3f Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Wed, 27 Jul 2022 01:47:22 +0200 Subject: [PATCH] add configurable / theme-able statusline separator string (#3175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add configurable separator element to statusline * themable separator * clippy fixes * changed default separator to │ * doc updates --- book/src/configuration.md | 2 ++ book/src/themes.md | 1 + helix-term/src/ui/statusline.rs | 14 ++++++++++++++ helix-view/src/editor.rs | 6 ++++++ 4 files changed, 23 insertions(+) diff --git a/book/src/configuration.md b/book/src/configuration.md index 5372b9f03..5eb94c4e9 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -63,6 +63,7 @@ Statusline elements can be defined as follows: left = ["mode", "spinner"] center = ["file-name"] right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"] +separator = "│" ``` The following elements can be configured: @@ -79,6 +80,7 @@ The following elements can be configured: | `selections` | The number of active selections | | `position` | The cursor position | | `position-percentage` | The cursor position as a percentage of the total number of lines | +| `separator` | The string defined in `editor.statusline.separator` (defaults to `"│"`) | | `spacer` | Inserts a space between elements (multiple/contiguous spacers may be specified) | ### `[editor.lsp]` Section diff --git a/book/src/themes.md b/book/src/themes.md index ad8864b20..e03782db3 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -224,6 +224,7 @@ These scopes are used for theming the editor interface. | `ui.statusline.normal` | Statusline mode during normal mode ([only if `editor.color-modes` is enabled][editor-section]) | | `ui.statusline.insert` | Statusline mode during insert mode ([only if `editor.color-modes` is enabled][editor-section]) | | `ui.statusline.select` | Statusline mode during select mode ([only if `editor.color-modes` is enabled][editor-section]) | +| `ui.statusline.separator` | Separator character in statusline | | `ui.popup` | Documentation popups (e.g space-k) | | `ui.popup.info` | Prompt for multiple key options | | `ui.window` | Border lines separating splits | diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index df6d48000..75e5dbd7b 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -144,6 +144,7 @@ where helix_view::editor::StatusLineElement::Selections => render_selections, helix_view::editor::StatusLineElement::Position => render_position, helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage, + helix_view::editor::StatusLineElement::Separator => render_separator, helix_view::editor::StatusLineElement::Spacer => render_spacer, } } @@ -353,6 +354,19 @@ where write(context, title, None); } +fn render_separator(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option