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

Native syntax highlighting in javascript template literals #229297

Closed
Qsppl opened this issue Sep 22, 2024 · 5 comments
Closed

Native syntax highlighting in javascript template literals #229297

Qsppl opened this issue Sep 22, 2024 · 5 comments
Assignees
Labels
*extension-candidate Issue identified as good extension implementation

Comments

@Qsppl
Copy link

Qsppl commented Sep 22, 2024

Feature Description

See MDN template literals.

Template literals are currently displayed like this:

image

Let's make template literals appear like this:

image

In recent years, many web developers have needed this feature. Here are examples of projects known to me that require this feature:

Many of these projects come up with their own ways of highlighting the syntax of template literals, but in all known implementations this does not work well.
Even if you can turn on syntax highlighting inside a template literal, formatting, tabulation, auto-substitutions, and transitions to definitions still do not work.
In some cases, these solutions break the syntax highlighting of javascript code.

Here are examples of these solutions:

Usually, in conjunction with these extensions, you also need to use prettier for correct tabulation.

Feature implementation details

Unlike Markdown, PHP, and HTML, Javascript syntax does not explicitly define the language of a template literal.
image

Therefore, I assume that a meta attribute will have to be added to jsdoc and tsdoc to explicitly determine the language of the template literal:

image

Details of the technical implementation of the feature

Perhaps to fully implement this feature you will need to use tree-sitter (#50140)

@RedCMD
Copy link
Contributor

RedCMD commented Sep 22, 2024

does https://marketplace.visualstudio.com/items?itemName=ruschaaf.extended-embedded-languages work for you?

@Qsppl
Copy link
Author

Qsppl commented Sep 22, 2024

This extension has no less problems than the others.
There is no code formatting, syntax highlighting is broken both in the template literal itself and in the code after the template literal (see lines 12-14). Emmet, snippets and other features do not work in a template literal.
image

But the main problem is that syntax highlighting generally has to be enabled by extensions.

@mjbvz mjbvz added the *extension-candidate Issue identified as good extension implementation label Sep 23, 2024
Copy link

We try to keep VS Code lean and we think the functionality you're asking for is great for a VS Code extension. Maybe you can already find one that suits you in the VS Code Marketplace. Just in case, in a few simple steps you can get started writing your own extension. See also our issue reporting guidelines.

Happy Coding!

@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2024
@mlntr

This comment has been minimized.

@RedCMD
Copy link
Contributor

RedCMD commented Nov 7, 2024

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Nov 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*extension-candidate Issue identified as good extension implementation
Projects
None yet
Development

No branches or pull requests

4 participants