diff --git a/book/src/configuration.md b/book/src/configuration.md index c209dc3d..4eab4a48 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -62,7 +62,7 @@ Statusline elements can be defined as follows: [editor.statusline] left = ["mode", "spinner"] center = ["file-name"] -right = ["diagnostics", "selections", "position", "file-encoding", "file-type"] +right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"] ``` The following elements can be configured: @@ -73,6 +73,7 @@ The following elements can be configured: | `spinner` | A progress spinner indicating LSP activity | | `file-name` | The path/name of the opened file | | `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-type` | The type of the opened file | | `diagnostics` | The number of warnings and/or errors | | `selections` | The number of active selections | diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index fb03af44..d6db117e 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -413,12 +413,11 @@ fn set_line_ending( // Attempt to parse argument as a line ending. let line_ending = match arg { - // We check for CR first because it shares a common prefix with CRLF. - #[cfg(feature = "unicode-lines")] - arg if arg.starts_with("cr") => CR, arg if arg.starts_with("crlf") => Crlf, arg if arg.starts_with("lf") => LF, #[cfg(feature = "unicode-lines")] + arg if arg.starts_with("cr") => CR, + #[cfg(feature = "unicode-lines")] arg if arg.starts_with("ff") => FF, #[cfg(feature = "unicode-lines")] arg if arg.starts_with("nel") => Nel, diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 895043cd..85992c60 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -138,6 +138,7 @@ where helix_view::editor::StatusLineElement::Spinner => render_lsp_spinner, helix_view::editor::StatusLineElement::FileName => render_file_name, helix_view::editor::StatusLineElement::FileEncoding => render_file_encoding, + helix_view::editor::StatusLineElement::FileLineEnding => render_file_line_ending, helix_view::editor::StatusLineElement::FileType => render_file_type, helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics, helix_view::editor::StatusLineElement::Selections => render_selections, @@ -280,6 +281,31 @@ where } } +fn render_file_line_ending(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option