Add support for folder-specific settings (#2537)
This PR allows you to customize Zed's settings within a particular folder by creating a `.zed/settings.json` file within that folder. Todo * [x] respect folder-specific settings for local projects * [x] respect folder-specific settings in remote projects * [x] pass a path when retrieving editor/language settings * [x] pass a path when retrieving copilot settings * [ ] update the `Setting` trait to make it clear which types of settings are locally overridable Release Notes: * Added support for folder-specific settings. You can customize Zed's settings within a particular folder by creating a `.zed` directory and a `.zed/settings.json` file within that folder.
This commit is contained in:
commit
788f97ec68
27 changed files with 797 additions and 158 deletions
|
@ -3207,12 +3207,10 @@ impl Editor {
|
|||
snapshot: &MultiBufferSnapshot,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> bool {
|
||||
let path = snapshot.file_at(location).map(|file| file.path().as_ref());
|
||||
let language_name = snapshot
|
||||
.language_at(location)
|
||||
.map(|language| language.name());
|
||||
let settings = all_language_settings(cx);
|
||||
settings.copilot_enabled(language_name.as_deref(), path)
|
||||
let file = snapshot.file_at(location);
|
||||
let language = snapshot.language_at(location);
|
||||
let settings = all_language_settings(file, cx);
|
||||
settings.copilot_enabled(language, file.map(|f| f.path().as_ref()))
|
||||
}
|
||||
|
||||
fn has_active_copilot_suggestion(&self, cx: &AppContext) -> bool {
|
||||
|
@ -7076,11 +7074,13 @@ impl Editor {
|
|||
};
|
||||
|
||||
// If None, we are in a file without an extension
|
||||
let file_extension = file_extension.or(self
|
||||
let file = self
|
||||
.buffer
|
||||
.read(cx)
|
||||
.as_singleton()
|
||||
.and_then(|b| b.read(cx).file())
|
||||
.and_then(|b| b.read(cx).file());
|
||||
let file_extension = file_extension.or(file
|
||||
.as_ref()
|
||||
.and_then(|file| Path::new(file.file_name(cx)).extension())
|
||||
.and_then(|e| e.to_str())
|
||||
.map(|a| a.to_string()));
|
||||
|
@ -7091,7 +7091,7 @@ impl Editor {
|
|||
.get("vim_mode")
|
||||
== Some(&serde_json::Value::Bool(true));
|
||||
let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
|
||||
let copilot_enabled = all_language_settings(cx).copilot_enabled(None, None);
|
||||
let copilot_enabled = all_language_settings(file, cx).copilot_enabled(None, None);
|
||||
let copilot_enabled_for_language = self
|
||||
.buffer
|
||||
.read(cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue