-
Notifications
You must be signed in to change notification settings - Fork 9
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
How can we highlight template literals as JavaScript? #140
Comments
It's not clear to me what you're asking. You might be looking for the |
It works like that. Thank you! "custom_templates": {
"default": "scope:source.js"
} |
How can I restore the default highlighting for template strings (in I know how to set |
You want e.g. templates to be highlighted as HTML by default, but as plain template strings with a lookahead? I'm having trouble envisioning the use case; can you provide an example? If that's what you mean, then I'm not sure there's a clean solution at the moment. You could do it as follows: "custom_templates": {
"default": "scope:text.html.basic",
"lookaheads": {
"foo": "string-content"
}
}, But a) you won't get the proper string scope, and b) this is kind of hacky and brittle. If this is a real use case for you, then it might not be too much of a code change to support it. |
Yes, but not as I have tried what you suggest, but it is not working. So yes it would be nice to have this. This is how I am trying: "custom_templates": {
"default": "scope:source.js"
, "lookaheads": {
"\\<": "scope:text.html.basic"
, ".": "string-content"
}
} I would like to restore the default highlighting for these type of dynamic imports for example: |
Rather than This seems to work for me, with the caveat that (as mentioned above) e.g. Alternatively, what about: "custom_templates": {
"lookaheads": {
"\\<": "scope:text.html.basic",
"import": "scope:source.js",
},
}, |
The alternative is not working. |
Seems like the solution is to not define the "custom_templates": {
"lookaheads": {
"\\<|.\\>": "scope:text.html.basic"
, "var": "scope:source.js"
}
} |
Yeah, that's what I meant. Sorry it wasn't clear. Does that work for your use case? If not I can create a feature ticket. |
Yes, it works like this for me. Thank you! |
Similarly to template strings can I set (custom) highlighting (using lookaheads) for regular strings? |
That is not currently a feature. Given that you can use template strings anywhere, I suspect that custom embedding for single/double-quoted strings would not be useful enough to justify the complexity. In addition, there might be substantial performance implications. What is your use case for this? |
Yes, it would be just nice to have. I have some single line html strings and |
I am implementing JavaScript Extensible Markup Language usage for some parts that are currently modules and will become (SolidJS) components in the Refo static site example. So for example the following line: will look like this: {template(`<!DOCTYPE HTML>`)} and unfortunately this line too for example: {template(`<head>`)} |
To highlight as
HTML
it works like this:To highlight as
JavaScript
I tried the following for example:The text was updated successfully, but these errors were encountered: