zed icon indicating copy to clipboard operation
zed copied to clipboard

A settings to allow mapping file types to known languages in Zed

Open daxartio opened this issue 1 year ago • 12 comments

Check for existing issues

  • [X] Completed

Is your feature request related to a problem?

I want to see Cargo.lock content with highlights syntax’s.

Describe the solution you'd like

Add a setting to settings.json

If applicable, add mockups / screenshots to help present your vision of the feature

settings.json

{
    "files": {
        "associations": {
            "*.avsc": "json",
            "Cargo.lock": "toml"
        }
    }
}

daxartio avatar Oct 15 '22 21:10 daxartio

I'm not sure if this qualifies as the same issue; however, I work on a project which for historic reasons is C++ code with .c file extensions. It would be nice if I could say "hey in this project (or even globally) treat .c as .cc/cpp"

DarkArc avatar Nov 12 '22 06:11 DarkArc

I'm wondering if the suggested structure should be flipped so that a list could be used. The structure would be saying "apply this language's syntax highlighting to the following languages":

{
    "files": {
        "associations": {
            "json": ["*.avsc"],
            "toml": ["Cargo.lock"],
        }
    }
}

I'm not sure. This would reduce duplication, but maybe it feels a bit backwards?

JosephTLyons avatar Feb 25 '23 15:02 JosephTLyons

This would be a great stop-gap for Svelte support, as Svelte users could associate their .svelte files with HTML

aewing avatar Mar 15 '23 22:03 aewing

A million times, yes.

BryanSchuetz avatar Mar 16 '23 21:03 BryanSchuetz

since there are already many many requests for language support it would make sense to allow custom languages and also to easily install language defs from others. really you would only need file extensions and lsps

maddanio avatar Jun 15 '23 11:06 maddanio

I'm wondering if the suggested structure should be flipped so that a list could be used. The structure would be saying "apply this language's syntax highlighting to the following languages":

{
    "files": {
        "associations": {
            "json": ["*.avsc"],
            "toml": ["Cargo.lock"],
        }
    }
}

I'm not sure. This would reduce duplication, but maybe it feels a bit backwards?

+1 This seems easier and more practical. Simply list all associated filetypes per language.

JarWarren avatar Jun 26 '23 17:06 JarWarren

In addition to adding this type of configuration, we should also populate some defaults, such as those suggested in:

  • https://github.com/zed-industries/zed/issues/6236

JosephTLyons avatar Jul 26 '23 16:07 JosephTLyons

This would be a huge step forward for Zed already. Currently, Zed becomes not useable for most of my projects, just because it lacks some languages (e.g. SCSS). But if I am able to map SCSS to the CSS engine (syntax highlighting, basic formatting/completion) it would be a huge step forward.

vycke avatar Jan 15 '24 13:01 vycke

Has anyone started working on this?

ljwljwljwljw avatar Jan 29 '24 13:01 ljwljwljwljw

Has anyone started working on this?

Not that I'm aware of. Feel free to open a PR if it's something you're interested in. :)

JosephTLyons avatar Jan 29 '24 13:01 JosephTLyons

Has anyone started working on this?

Not that I'm aware of. Feel free to open a PR if it's something you're interested in. :)

I'm trying to implement this, but I found that the current architecture assumes LanguageConfig is static and will not be updated by any Settings, the path_suffixes in LanguageConfig for each language is loaded by languages::init(languages.clone(), node_runtime.clone(), cx) before user's local settings and project settings are loaded. Are there any APIs or callbacks, like onLocalSettingsLoaded, that we can use to update the language configs after local settings are loaded?

ljwljwljwljw avatar Feb 02 '24 17:02 ljwljwljwljw

Has anyone started working on this?

Not that I'm aware of. Feel free to open a PR if it's something you're interested in. :)

I'm trying to implement this, but I found that the current architecture assumes LanguageConfig is static and will not be updated by any Settings, the path_suffixes in LanguageConfig for each language is loaded by languages::init(languages.clone(), node_runtime.clone(), cx) before user's local settings and project settings are loaded. Are there any APIs or callbacks, like onLocalSettingsLoaded, that we can use to update the language configs after local settings are loaded?

Another solution may be to pass AppContext as an argument to language_for_file, language_for_name_or_extension in order to load the user's custom path suffixes settings, however, it requires a lot of changes.

ljwljwljwljw avatar Feb 03 '24 07:02 ljwljwljwljw