diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 6be565747..3d3de08e4 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -633,9 +633,8 @@ impl EditorView { let current_doc = view!(editor).doc; for doc in editor.documents() { - let fname = doc - .path() - .unwrap_or(&scratch) + let path = doc.path().unwrap_or(&scratch); + let fname = path .file_name() .unwrap_or_default() .to_str() @@ -647,7 +646,20 @@ impl EditorView { bufferline_inactive }; - let text = format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" }); + let text = if editor.config().bufferline_show_parent { + let parent_dir = path + .parent() + .and_then(|p| p.file_name().unwrap_or_default().to_str()) + .unwrap_or_default(); + format!( + " {}/{}{} ", + parent_dir, + fname, + if doc.is_modified() { "[+]" } else { "" } + ) + } else { + format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" }) + }; let used_width = viewport.x.saturating_sub(x); let rem_width = surface.area.width.saturating_sub(used_width); diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index eab291e44..9e6de7b85 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -332,6 +332,8 @@ pub struct Config { pub whitespace: WhitespaceConfig, /// Persistently display open buffers along the top pub bufferline: BufferLine, + /// Show the parent directory of files in the bufferline. + pub bufferline_show_parent: bool, /// Vertical indent width guides. pub indent_guides: IndentGuidesConfig, /// Whether to color modes with different colors. Defaults to `false`. @@ -999,6 +1001,7 @@ impl Default for Config { rulers: Vec::new(), whitespace: WhitespaceConfig::default(), bufferline: BufferLine::default(), + bufferline_show_parent: false, indent_guides: IndentGuidesConfig::default(), color_modes: false, soft_wrap: SoftWrap {