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
parent 77de5689a3
commit 724c19a223
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 640 additions and 415 deletions

View file

@ -1042,8 +1042,8 @@ mod tests {
use util::test::marked_text_ranges;
#[gpui::test]
fn test_render_markdown_with_mentions() {
let language_registry = Arc::new(LanguageRegistry::test());
fn test_render_markdown_with_mentions(cx: &mut AppContext) {
let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone()));
let (body, ranges) = marked_text_ranges("*hi*, «@abc», let's **call** «@fgh»", false);
let message = channel::ChannelMessage {
id: ChannelMessageId::Saved(0),
@ -1090,8 +1090,8 @@ mod tests {
}
#[gpui::test]
fn test_render_markdown_with_auto_detect_links() {
let language_registry = Arc::new(LanguageRegistry::test());
fn test_render_markdown_with_auto_detect_links(cx: &mut AppContext) {
let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone()));
let message = channel::ChannelMessage {
id: ChannelMessageId::Saved(0),
body: "Here is a link https://zed.dev to zeds website".to_string(),
@ -1130,8 +1130,8 @@ mod tests {
}
#[gpui::test]
fn test_render_markdown_with_auto_detect_links_and_additional_formatting() {
let language_registry = Arc::new(LanguageRegistry::test());
fn test_render_markdown_with_auto_detect_links_and_additional_formatting(cx: &mut AppContext) {
let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone()));
let message = channel::ChannelMessage {
id: ChannelMessageId::Saved(0),
body: "**Here is a link https://zed.dev to zeds website**".to_string(),

View file

@ -624,7 +624,7 @@ mod tests {
MessageEditorSettings::register(cx);
});
let language_registry = Arc::new(LanguageRegistry::test());
let language_registry = Arc::new(LanguageRegistry::test(cx.executor()));
language_registry.add(Arc::new(Language::new(
LanguageConfig {
name: "Markdown".into(),