mirror of https://github.com/helix-editor/helix
Add file indentation style for statusline (#13632)
parent
2bd7452fe0
commit
733ebcdaeb
|
@ -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 |
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
Loading…
Reference in New Issue