From 2c7251e4f9177e047b58f53f7b3f8fed9e928fa1 Mon Sep 17 00:00:00 2001 From: zumbalogy Date: Thu, 7 Aug 2025 22:04:30 -0700 Subject: [PATCH] Add setting to hide active language button in the status bar (#33977) Release Notes: - Added settings status_bar.show_active_language_button to show/hide the language button in the status bar. The motivation for this is visual, I have had zero issues with its functionality. The language switcher can still be accessed by the command palette, menu, or a keyboard shortcut. ------ This is my first Zed and first Rust PR, so criticism is very welcome. I know there has been discussion around how the status bar settings are structured and named, and I am happy to change it to whatever is best. I was also not sure what order to put it in in the settings default.json. Feedback welcome. Here is a picture of it in action: ![image](https://github.com/user-attachments/assets/c50131e2-71aa-4fab-8db0-8b2aae586e71) --------- Co-authored-by: zumbalogy <3770982+zumbalogy@users.noreply.github.com> Co-authored-by: Kirill Bulatov --- assets/settings/default.json | 5 +++++ crates/editor/src/editor_settings.rs | 20 +++++++++++++++++++ .../src/active_buffer_language.rs | 10 +++++++++- docs/src/configuring-zed.md | 12 +++++++++++ docs/src/visual-customization.md | 11 ++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 295bebe23a..9c579b858d 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1238,6 +1238,11 @@ // 2. hour24 "hour_format": "hour12" }, + // Status bar-related settings. + "status_bar": { + // Whether to show the active language button in the status bar. + "active_language_button": true + }, // Settings specific to the terminal "terminal": { // What shell to use when opening a terminal. May take 3 values: diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index 14f46c0e60..3d132651b8 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -20,6 +20,7 @@ pub struct EditorSettings { pub lsp_highlight_debounce: u64, pub hover_popover_enabled: bool, pub hover_popover_delay: u64, + pub status_bar: StatusBar, pub toolbar: Toolbar, pub scrollbar: Scrollbar, pub minimap: Minimap, @@ -125,6 +126,14 @@ pub struct JupyterContent { pub enabled: Option, } +#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] +pub struct StatusBar { + /// Whether to display the active language button in the status bar. + /// + /// Default: true + pub active_language_button: bool, +} + #[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] pub struct Toolbar { pub breadcrumbs: bool, @@ -440,6 +449,8 @@ pub struct EditorSettingsContent { /// /// Default: 300 pub hover_popover_delay: Option, + /// Status bar related settings + pub status_bar: Option, /// Toolbar related settings pub toolbar: Option, /// Scrollbar related settings @@ -567,6 +578,15 @@ pub struct EditorSettingsContent { pub lsp_document_colors: Option, } +// Status bar related settings +#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] +pub struct StatusBarContent { + /// Whether to display the active language button in the status bar. + /// + /// Default: true + pub active_language_button: Option, +} + // Toolbar related settings #[derive(Clone, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] pub struct ToolbarContent { diff --git a/crates/language_selector/src/active_buffer_language.rs b/crates/language_selector/src/active_buffer_language.rs index 250d0c23d8..c5c5eceab5 100644 --- a/crates/language_selector/src/active_buffer_language.rs +++ b/crates/language_selector/src/active_buffer_language.rs @@ -1,8 +1,9 @@ -use editor::Editor; +use editor::{Editor, EditorSettings}; use gpui::{ Context, Entity, IntoElement, ParentElement, Render, Subscription, WeakEntity, Window, div, }; use language::LanguageName; +use settings::Settings as _; use ui::{Button, ButtonCommon, Clickable, FluentBuilder, LabelSize, Tooltip}; use workspace::{StatusItemView, Workspace, item::ItemHandle}; @@ -39,6 +40,13 @@ impl ActiveBufferLanguage { impl Render for ActiveBufferLanguage { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { + if !EditorSettings::get_global(cx) + .status_bar + .active_language_button + { + return div(); + } + div().when_some(self.active_language.as_ref(), |el, active_language| { let active_language_text = if let Some(active_language_text) = active_language { active_language_text.to_string() diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 67f1cd000b..1996e1c4ee 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -1275,6 +1275,18 @@ Each option controls displaying of a particular toolbar element. If all elements `boolean` values +## Status Bar + +- Description: Control various elements in the status bar. Note that some items in the status bar have their own settings set elsewhere. +- Setting: `status_bar` +- Default: + +```json +"status_bar": { + "active_language_button": true, +}, +``` + ## LSP - Description: Configuration for language servers. diff --git a/docs/src/visual-customization.md b/docs/src/visual-customization.md index 34ce067eba..46de078d89 100644 --- a/docs/src/visual-customization.md +++ b/docs/src/visual-customization.md @@ -306,6 +306,17 @@ TBD: Centered layout related settings } ``` +### Status Bar + +```json + "status_bar": { + // Show/hide a button that displays the active buffer's language. + // Clicking the button brings up the language selector. + // Defaults to true. + "active_language_button": true, + }, +``` + ### Multibuffer ```json