Unnamed repository; edit this file 'description' to name the repository.
Current working directory status (#10998)
Co-authored-by: mfirhas <[email protected]>
| -rw-r--r-- | book/src/editor.md | 1 | ||||
| -rw-r--r-- | helix-term/src/ui/statusline.rs | 14 | ||||
| -rw-r--r-- | helix-view/src/editor.rs | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/book/src/editor.md b/book/src/editor.md index 7f1de68b..42d97fe6 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -132,6 +132,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 ea3d27bd..aad3d532 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -158,6 +158,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, } } @@ -573,3 +574,16 @@ where }, ); } + +fn render_cwd<'a, F>(context: &mut RenderContext<'a>, write: F) +where + F: Fn(&mut RenderContext<'a>, Span<'a>) + Copy, +{ + let cwd = helix_stdx::env::current_working_dir(); + let cwd = cwd + .file_name() + .unwrap_or_default() + .to_string_lossy() + .to_string(); + write(context, cwd.into()) +} diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 57e13088..66315652 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -628,6 +628,9 @@ pub enum StatusLineElement { /// Indicator for selected register Register, + + /// The base of current working directory + CurrentWorkingDirectory, } // Cursor shape is read and used on every rendered frame and so needs |