on master help sign in
add configurable / theme-able statusline separator string (#3175)
846a6b6Seth Bromberger
book/src/configuration.md+2
@@ -63,6 +63,7 @@ Statusline elements can be defined as follows:
63left = ["mode", "spinner"]
63left = ["mode", "spinner"]
64center = ["file-name"]
64center = ["file-name"]
65right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
65right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
66+separator = "│"
66```
67```
67
68
68The following elements can be configured:
69The following elements can be configured:
@@ -79,6 +80,7 @@ The following elements can be configured:
79| `selections` | The number of active selections |
80| `selections` | The number of active selections |
80| `position` | The cursor position |
81| `position` | The cursor position |
81| `position-percentage` | The cursor position as a percentage of the total number of lines |
82| `position-percentage` | The cursor position as a percentage of the total number of lines |
83+| `separator` | The string defined in `editor.statusline.separator` (defaults to `"│"`) |
82| `spacer` | Inserts a space between elements (multiple/contiguous spacers may be specified) |
84| `spacer` | Inserts a space between elements (multiple/contiguous spacers may be specified) |
83
85
84### `[editor.lsp]` Section
86### `[editor.lsp]` Section
book/src/themes.md+1
@@ -224,6 +224,7 @@ These scopes are used for theming the editor interface.
224| `ui.statusline.normal` | Statusline mode during normal mode ([only if `editor.color-modes` is enabled][editor-section]) |
224| `ui.statusline.normal` | Statusline mode during normal mode ([only if `editor.color-modes` is enabled][editor-section]) |
225| `ui.statusline.insert` | Statusline mode during insert mode ([only if `editor.color-modes` is enabled][editor-section]) |
225| `ui.statusline.insert` | Statusline mode during insert mode ([only if `editor.color-modes` is enabled][editor-section]) |
226| `ui.statusline.select` | Statusline mode during select mode ([only if `editor.color-modes` is enabled][editor-section]) |
226| `ui.statusline.select` | Statusline mode during select mode ([only if `editor.color-modes` is enabled][editor-section]) |
227+| `ui.statusline.separator` | Separator character in statusline |
227| `ui.popup` | Documentation popups (e.g space-k) |
228| `ui.popup` | Documentation popups (e.g space-k) |
228| `ui.popup.info` | Prompt for multiple key options |
229| `ui.popup.info` | Prompt for multiple key options |
229| `ui.window` | Border lines separating splits |
230| `ui.window` | Border lines separating splits |
helix-term/src/ui/statusline.rs+14
@@ -144,6 +144,7 @@ where
144 helix_view::editor::StatusLineElement::Selections => render_selections,
144 helix_view::editor::StatusLineElement::Selections => render_selections,
145 helix_view::editor::StatusLineElement::Position => render_position,
145 helix_view::editor::StatusLineElement::Position => render_position,
146 helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage,
146 helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage,
147+ helix_view::editor::StatusLineElement::Separator => render_separator,
147 helix_view::editor::StatusLineElement::Spacer => render_spacer,
148 helix_view::editor::StatusLineElement::Spacer => render_spacer,
148 }
149 }
149}
150}
@@ -353,6 +354,19 @@ where
353 write(context, title, None);
354 write(context, title, None);
354}
355}
355
356
357+fn render_separator<F>(context: &mut RenderContext, write: F)
358+where
359+ F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
360+{
361+ let sep = &context.editor.config().statusline.separator;
362+
363+ write(
364+ context,
365+ sep.to_string(),
366+ Some(context.editor.theme.get("ui.statusline.separator")),
367+ );
368+}
369+
356fn render_spacer<F>(context: &mut RenderContext, write: F)
370fn render_spacer<F>(context: &mut RenderContext, write: F)
357where
371where
358 F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
372 F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
helix-view/src/editor.rs+6
@@ -203,6 +203,7 @@ pub struct StatusLineConfig {
203 pub left: Vec<StatusLineElement>,
203 pub left: Vec<StatusLineElement>,
204 pub center: Vec<StatusLineElement>,
204 pub center: Vec<StatusLineElement>,
205 pub right: Vec<StatusLineElement>,
205 pub right: Vec<StatusLineElement>,
206+ pub separator: String,
206}
207}
207
208
208impl Default for StatusLineConfig {
209impl Default for StatusLineConfig {
@@ -213,6 +214,7 @@ impl Default for StatusLineConfig {
213 left: vec![E::Mode, E::Spinner, E::FileName],
214 left: vec![E::Mode, E::Spinner, E::FileName],
214 center: vec![],
215 center: vec![],
215 right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding],
216 right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding],
217+ separator: String::from("│"),
216 }
218 }
217 }
219 }
218}
220}
@@ -247,8 +249,12 @@ pub enum StatusLineElement {
247 /// The cursor position
249 /// The cursor position
248 Position,
250 Position,
249
251
252+ /// The separator string
253+ Separator,
254+
250 /// The cursor position as a percent of the total file
255 /// The cursor position as a percent of the total file
251 PositionPercentage,
256 PositionPercentage,
257+
252 /// A single space
258 /// A single space
253 Spacer,
259 Spacer,
254}
260}