Add a setting for custom associations between languages and files (#9290)

Closes #5178

Release Notes:

- Added a `file_types` setting that can be used to associate languages
with file names and file extensions. For example, to interpret all `.c`
files as C++, and files called `MyLockFile` as TOML, add the following
to `settings.json`:

    ```json
    {
      "file_types": {
        "C++": ["c"],
        "TOML": ["MyLockFile"]
      }
    }
    ```

As with most zed settings, this can be configured on a per-directory
basis by including a local `.zed/settings.json` file in that directory.

---------

Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
Max Brunsfeld
2024-03-13 10:23:30 -07:00
committed by GitHub
co-authored by Marshall
parent 77de5689a3
commit 724c19a223
30 changed files with 640 additions and 415 deletions
+5 -12
View File
@@ -9302,8 +9302,7 @@ impl Editor {
.redacted_ranges(search_range, |file| {
if let Some(file) = file {
file.is_private()
&& EditorSettings::get(Some((file.worktree_id(), file.path())), cx)
.redact_private_values
&& EditorSettings::get(Some(file.as_ref().into()), cx).redact_private_values
} else {
false
}
@@ -9645,22 +9644,16 @@ impl Editor {
telemetry.report_copilot_event(suggestion_id, suggestion_accepted, file_extension)
}
#[cfg(any(test, feature = "test-support"))]
fn report_editor_event(
&self,
_operation: &'static str,
_file_extension: Option<String>,
_cx: &AppContext,
) {
}
#[cfg(not(any(test, feature = "test-support")))]
fn report_editor_event(
&self,
operation: &'static str,
file_extension: Option<String>,
cx: &AppContext,
) {
if cfg!(any(test, feature = "test-support")) {
return;
}
let Some(project) = &self.project else { return };
// If None, we are in a file without an extension