Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--book/src/editor.md1
-rw-r--r--helix-term/src/ui/statusline.rs19
-rw-r--r--helix-view/src/editor.rs3
3 files changed, 23 insertions, 0 deletions
diff --git a/book/src/editor.md b/book/src/editor.md
index c2a7af76..00db71d2 100644
--- a/book/src/editor.md
+++ b/book/src/editor.md
@@ -133,6 +133,7 @@ The following statusline elements can be configured:
| `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) |
+| `file-indent-style` | The file indentation style |
| `read-only-indicator` | An indicator that shows `[readonly]` when a file cannot be written |
| `total-line-numbers` | The total line numbers of the opened file |
| `file-type` | The type of the opened file |
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs
index df23123c..ea3d27bd 100644
--- a/helix-term/src/ui/statusline.rs
+++ b/helix-term/src/ui/statusline.rs
@@ -1,5 +1,6 @@
use std::borrow::Cow;
+use helix_core::indent::IndentStyle;
use helix_core::{coords_at_pos, encoding, Position};
use helix_lsp::lsp::DiagnosticSeverity;
use helix_view::document::DEFAULT_LANGUAGE_NAME;
@@ -142,6 +143,7 @@ where
helix_view::editor::StatusLineElement::ReadOnlyIndicator => render_read_only_indicator,
helix_view::editor::StatusLineElement::FileEncoding => render_file_encoding,
helix_view::editor::StatusLineElement::FileLineEnding => render_file_line_ending,
+ helix_view::editor::StatusLineElement::FileIndentStyle => render_file_indent_style,
helix_view::editor::StatusLineElement::FileType => render_file_type,
helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics,
helix_view::editor::StatusLineElement::WorkspaceDiagnostics => render_workspace_diagnostics,
@@ -554,3 +556,20 @@ where
write(context, format!(" reg={} ", reg).into())
}
}
+
+fn render_file_indent_style<'a, F>(context: &mut RenderContext<'a>, write: F)
+where
+ F: Fn(&mut RenderContext<'a>, Span<'a>) + Copy,
+{
+ let style = context.doc.indent_style;
+
+ write(
+ context,
+ match style {
+ IndentStyle::Tabs => " tabs ".into(),
+ IndentStyle::Spaces(indent) => {
+ format!(" {} space{} ", indent, if indent == 1 { "" } else { "s" }).into()
+ }
+ },
+ );
+}
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 0ecddd87..bc811b88 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -580,6 +580,9 @@ pub enum StatusLineElement {
/// The file line endings (CRLF or LF)
FileLineEnding,
+ /// The file indentation style
+ FileIndentStyle,
+
/// The file type (language ID or "text")
FileType,