diff --git a/Cargo.lock b/Cargo.lock index a1a9eae4dd27..de985bca11eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1212,6 +1212,7 @@ dependencies = [ name = "helix-vcs" version = "0.6.0" dependencies = [ + "arc-swap", "gix", "helix-core", "imara-diff", diff --git a/book/src/configuration.md b/book/src/configuration.md index 4b62ca521e6b..e698646bca5d 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -111,6 +111,7 @@ The following statusline elements can be configured: | `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) | +| `version-control` | The current branch name or detached commit hash of the opened workspace | ### `[editor.lsp]` Section diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 3e7065b8282c..887863519319 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -159,6 +159,7 @@ where helix_view::editor::StatusLineElement::TotalLineNumbers => render_total_line_numbers, helix_view::editor::StatusLineElement::Separator => render_separator, helix_view::editor::StatusLineElement::Spacer => render_spacer, + helix_view::editor::StatusLineElement::VersionControl => render_version_control, } } @@ -476,3 +477,16 @@ where { write(context, String::from(" "), None); } + +fn render_version_control(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option