diff --git a/book/src/configuration.md b/book/src/configuration.md index 4eab4a48aa78..e8131fb4f4ba 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -46,6 +46,7 @@ hidden = false | `auto-info` | Whether to display infoboxes | `true` | | `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` | | `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` | +| `file-modification-indicator` | The string to be displayed in the statusbar when the file has been modified. | `"[+]"` | | `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` | ### `[editor.statusline]` Section diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3ee75f6a392f..0e597a0c56df 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -67,6 +67,8 @@ use grep_searcher::{sinks, BinaryDetection, SearcherBuilder}; use ignore::{DirEntry, WalkBuilder, WalkState}; use tokio_stream::wrappers::UnboundedReceiverStream; +const DEFAULT_CURRENT_BUFFER_INDICATOR: &str = "*"; + pub struct Context<'a> { pub register: Option, pub count: Option, @@ -2208,6 +2210,8 @@ fn buffer_picker(cx: &mut Context) { path: Option, is_modified: bool, is_current: bool, + modified_indicator: String, + current_indicator: String, } impl ui::menu::Item for BufferMeta { @@ -2225,10 +2229,10 @@ fn buffer_picker(cx: &mut Context) { let mut flags = Vec::new(); if self.is_modified { - flags.push("+"); + flags.push(self.modified_indicator.to_string()); } if self.is_current { - flags.push("*"); + flags.push(self.current_indicator.to_string()); } let flag = if flags.is_empty() { @@ -2245,6 +2249,8 @@ fn buffer_picker(cx: &mut Context) { path: doc.path().cloned(), is_modified: doc.is_modified(), is_current: doc.id() == current, + modified_indicator: cx.editor.config().file_modification_indicator.clone(), + current_indicator: DEFAULT_CURRENT_BUFFER_INDICATOR.to_string(), }; let picker = FilePicker::new( diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 85992c602164..df9ab4970436 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -325,10 +325,15 @@ where .as_ref() .map(|p| p.to_string_lossy()) .unwrap_or_else(|| SCRATCH_BUFFER_NAME.into()); + let file_modification_indicator = &context.editor.config().file_modification_indicator; format!( - " {}{} ", + "{}{}", path, - if context.doc.is_modified() { "[+]" } else { "" } + if context.doc.is_modified() { + file_modification_indicator + } else { + "" + } ) }; diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 7ac52f505dc9..1d8e466f333e 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -45,6 +45,8 @@ use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer} use arc_swap::access::{DynAccess, DynGuard}; +const DEFAULT_FILE_MODIFICATION_INDICATOR: &str = "[+]"; + fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -161,6 +163,8 @@ pub struct Config { pub rulers: Vec, #[serde(default)] pub whitespace: WhitespaceConfig, + /// String for file modification indicator + pub file_modification_indicator: String, /// Vertical indent width guides. pub indent_guides: IndentGuidesConfig, /// Whether to color modes with different colors. Defaults to `false`. @@ -490,6 +494,7 @@ impl Default for Config { lsp: LspConfig::default(), rulers: Vec::new(), whitespace: WhitespaceConfig::default(), + file_modification_indicator: DEFAULT_FILE_MODIFICATION_INDICATOR.to_string(), indent_guides: IndentGuidesConfig::default(), color_modes: false, }