Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use file associations from the VS Code settings #2633

Closed
AlexRMU opened this issue Dec 15, 2024 · 1 comment
Closed

Use file associations from the VS Code settings #2633

AlexRMU opened this issue Dec 15, 2024 · 1 comment

Comments

@AlexRMU
Copy link

AlexRMU commented Dec 15, 2024

Description

In VS Code, you can set up associations of extensions and language identifiers.
https://code.visualstudio.com/docs/languages/identifiers

And for example, if I have such settings

{
    "files.associations": {
        "*.css": "postcss"
    }
}

it is necessary that <style> by default are highlighted and processed by plugins that process postcss files as if it were <style lang="postcss">.

Proposed solution

You can use the VS Code settings, you can add an option to the plugin settings.
See also sveltejs/svelte#9752.

Alternatives

No response

Additional Information, eg. Screenshots

Is it even necessary?

@dummdidumm
Copy link
Member

A long time ago we briefly had the option for language defaults of the script/style tags, but it turned out to be a nightmare:

  • VS Code's (and other IDE's) syntax highlighting isn't equipped to dynamically switch to a different highlighter depending on some default written into some config file which is read at runtime. You would have a subpar experience, and we would have to do horrible hacks to get it even remotely working
  • Many intellisense features are based on the file ending (for example within the TypeScript service), messing with file endings meaning different things is bad. This is no different for file contents
  • TypeScript needs synchronous code paths. Writing stuff in config files that cannot be synchronously read (like svelte.config.js) would mean that we have to jump through hoops to first load all config files, then load the TypeScript service
  • It's harder to reason about what you can write into a script/style tag by default, as it can differ between projects

For these reasons that option was quickly removed, and we don't intend to add it back - therefore closing.

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants