Settings refactor (#38367)

Co-Authored-By: Ben K <ben@zed.dev>
Co-Authored-By: Anthony <anthony@zed.dev>
Co-Authored-By: Mikayla <mikayla@zed.dev>

Release Notes:

- settings: Major internal changes to settings. The primary user-facing
effect is that some settings which did not make sense in project
settings files are no-longer read from there. (For example the inline
blame settings)

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
Conrad Irwin
2025-09-18 16:47:23 +00:00
committed by GitHub
co-authored by Ben Kunkle Mikayla Maki Anthony
parent 0a9023bce0
commit fcdab160f9
219 changed files with 11697 additions and 11894 deletions
+13 -13
View File
@@ -160,9 +160,7 @@ use project::{
},
git_store::{GitStoreEvent, RepositoryEvent},
lsp_store::{CompletionDocumentation, FormatTrigger, LspFormatTarget, OpenLspBufferHandle},
project_settings::{
DiagnosticSeverity, GitGutterSetting, GoToDiagnosticSeverityFilter, ProjectSettings,
},
project_settings::{DiagnosticSeverity, GoToDiagnosticSeverityFilter, ProjectSettings},
};
use rand::seq::SliceRandom;
use rpc::{ErrorCode, ErrorExt, proto::PeerId};
@@ -171,7 +169,7 @@ use selections_collection::{
MutableSelectionsCollection, SelectionsCollection, resolve_selections,
};
use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsLocation, SettingsStore, update_settings_file};
use settings::{GitGutterSetting, Settings, SettingsLocation, SettingsStore, update_settings_file};
use smallvec::{SmallVec, smallvec};
use snippet::Snippet;
use std::{
@@ -2189,7 +2187,7 @@ impl Editor {
show_selection_menu: None,
show_git_blame_inline_delay_task: None,
git_blame_inline_enabled: full_mode
&& ProjectSettings::get_global(cx).git.inline_blame_enabled(),
&& ProjectSettings::get_global(cx).git.inline_blame.enabled,
render_diff_hunk_controls: Arc::new(render_diff_hunk_controls),
serialize_dirty_buffers: !is_minimap
&& ProjectSettings::get_global(cx)
@@ -5591,8 +5589,9 @@ impl Editor {
.language_at(buffer_position)
.map(|language| language.name());
let completion_settings =
language_settings(language.clone(), buffer_snapshot.file(), cx).completions;
let completion_settings = language_settings(language.clone(), buffer_snapshot.file(), cx)
.completions
.clone();
let show_completion_documentation = buffer_snapshot
.settings_at(buffer_position, cx)
@@ -19008,8 +19007,8 @@ impl Editor {
};
let fs = workspace.read(cx).app_state().fs.clone();
let current_show = TabBarSettings::get_global(cx).show;
update_settings_file::<TabBarSettings>(fs, cx, move |setting, _| {
setting.show = Some(!current_show);
update_settings_file(fs, cx, move |setting, _| {
setting.tab_bar.get_or_insert_default().show = Some(!current_show);
});
}
@@ -20723,7 +20722,7 @@ impl Editor {
if self.mode.is_full() {
let show_inline_diagnostics = project_settings.diagnostics.inline.enabled;
let inline_blame_enabled = project_settings.git.inline_blame_enabled();
let inline_blame_enabled = project_settings.git.inline_blame.enabled;
if self.show_inline_diagnostics != show_inline_diagnostics {
self.show_inline_diagnostics = show_inline_diagnostics;
self.refresh_inline_diagnostics(false, window, cx);
@@ -21679,11 +21678,12 @@ impl Editor {
}
}
// todo(settings_refactor) this should not be!
fn vim_enabled(cx: &App) -> bool {
cx.global::<SettingsStore>()
.raw_user_settings()
.get("vim_mode")
== Some(&serde_json::Value::Bool(true))
.and_then(|settings| settings.content.vim_mode)
== Some(true)
}
fn process_completion_for_edit(
@@ -23123,7 +23123,7 @@ impl EditorSnapshot {
let show_git_gutter = self.show_git_diff_gutter.unwrap_or_else(|| {
matches!(
ProjectSettings::get_global(cx).git.git_gutter,
Some(GitGutterSetting::TrackedFiles)
GitGutterSetting::TrackedFiles
)
});
let gutter_settings = EditorSettings::get_global(cx).gutter;