From d8a69233f9d7f4708eea279cbedd4eaac601f89d Mon Sep 17 00:00:00 2001 From: mfirhas Date: Fri, 14 Jun 2024 14:51:16 +0700 Subject: [PATCH] Add current working directory status --- book/src/editor.md | 1 + helix-term/src/ui/statusline.rs | 15 +++++++++++++++ helix-view/src/editor.rs | 2 ++ 3 files changed, 18 insertions(+) diff --git a/book/src/editor.md b/book/src/editor.md index ba03e90e5..b63ee2041 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -92,6 +92,7 @@ The following statusline elements can be configured: | `file-name` | The path/name of the opened file | | `file-absolute-path` | The absolute path/name of the opened file | | `file-base-name` | The basename of the opened file | +| `current-working-directory` | The current working directory | | `file-modification-indicator` | The indicator to show whether the file is modified (a `[+]` appears when there are unsaved changes) | | `file-encoding` | The encoding of the opened file if it differs from UTF-8 | | `file-line-ending` | The file line endings (CRLF or LF) | diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 7437cbd07..080b1933a 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -163,6 +163,7 @@ where helix_view::editor::StatusLineElement::Spacer => render_spacer, helix_view::editor::StatusLineElement::VersionControl => render_version_control, helix_view::editor::StatusLineElement::Register => render_register, + helix_view::editor::StatusLineElement::CurrentWorkingDirectory => render_cwd, } } @@ -531,3 +532,17 @@ where write(context, format!(" reg={} ", reg), None) } } + +fn render_cwd(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option