-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Support specifying language for semantic token types and modifiers #103097
Comments
I was hoping that custom token type or modifier are not the norm, but instead that the standard types and modifiers will be used as much as possible. That will allow themes and users to write theming rules that work across languages and result in consistent theming experience. If a custom token type or modifier is very language specific, it makes sense to prefix it that way: We have #97063 to discuss new standard tokens. |
I agree with this, and my feature request is actually aimed at minimizing the need for theme authors to use language-specific token types, although it might not have been clear in my previous comment. Let me explain: We seem to agree that providing only language-specific token types will be a hindrance for theme authors, and just a bad idea in general. But the problem that I see with generalizing all the token types is that it takes away capabilities from theme authors who do know about the more specific token types, and who want to use them. For example, let's say that But as you say, with the more specific token types, now there is no way for theme authors to style After thinking some more about it, I do see another way of achieving the same goal. What the Do you think this is a better solution than my previous suggestion about being able to specify the language? Or do you think there is a better way to achieve the same goal? I am open to suggestions, but I really want to make a solution that works for both "experts" and those who want to rely on the standard token types. Should I make a comment to suggest |
Something I just realised about the second solution I had, is that I would really need to be able to declare multiple supertypes for the custom token types, in order for it to work like I wanted. Let me make a hypothetical list of "java" token types (some of which have not been implemented yet, but might come in the future):
Read the arrow as "extends". Do you feel like multiple supertypes with these custom tokens would be better than language-specific supertypes? A third solution that might work is for the |
You can add Java specific types if that solves a user request for you, but note that users/theme can already define language specific theming rules:
The point of the inheritance is that you can inherit styling rules of other types. I don't know what it would mean if multiple inheritance would be allowed. So I'd rather not go there and avoid more complexity. |
Yes, I knew about the language specifier in the theming rules. The examples above were just a naming scheme to indicate that those tokens had a different meaning/hierarchy than the standard token types.
Oh, that clears many things up for me! I was really confused about the meaning of the I understand if you don't want to add more complexity to the system, and now that you cleared things up I no longer feel like we need this specific feature. But if you are not planning to change the name of |
Thanks for your efforts. I realize now that |
Issue Type: Feature Request
Currently, only the
semanticTokenScopes
contribution point supports language-specific contributions for semantic tokens, via the"language": "..."
property. But thesemanticTokenTypes
andsemanticTokenModifiers
contribution points do not support specifying the language, which means that semantic token types and modifiers are declared globally, for all languages. This causes a problem where the token contribution of one extension might override the token contribution of the same ID, from another extension (or even from the default tokens).Implementing this feature would yield the following benefit:
Extensions providing semantic tokens could declare supertypes for new and existing token types, without breaking semantic highlighting for other languages that want to declare a different supertype for the same token type. For example, Java methods, which get the token type
function
in theredhat.java
extension, should have the token supertype ofmember
since that holds true for all methods in Java. But in other languages, such as TypeScript, functions are not always members. If theredhat.java
extension were to declaremember
the supertype offunction
, this would cause the same behavior in TypeScript, which is undesirable. Instead, theredhat.java
extension should be able to declare that functions are members, but only for tokens provided to Java files. Another "collision" that could happen in the future is that annotations are types in Java, but they are functions in TypeScript.VS Code version: Code 1.47.2 (17299e4, 2020-07-15T18:22:15.161Z)
OS version: Linux x64 4.19.0-9-amd64
The text was updated successfully, but these errors were encountered: