From 540a08d322c8b9d40b35f69125e1fdb7faa3acae Mon Sep 17 00:00:00 2001 From: Alexis Kalabura Date: Tue, 19 Jul 2022 18:56:56 -0400 Subject: [PATCH 1/4] add statusline element to display file line endings --- book/src/configuration.md | 3 ++- helix-term/src/ui/statusline.rs | 14 ++++++++++++++ helix-view/src/editor.rs | 5 ++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index c209dc3de249..fc7288af2d60 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-endings", "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-endings` | 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/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 895043cd1154..caea2f37df35 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::FileLineEndings => render_file_line_endings, 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,19 @@ where } } +fn render_file_line_endings(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option