You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add more specific scopes to bool, num, double, int, Object, String, dynamic in textmate grammar #4974
in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
changed the title [-]Syntax Highlight bool, num, double, int as Keywords[/-][+]Syntax Highlight `bool`, `num`, `double`, `int` as Keywords[/+]on Feb 3, 2024
Can you provide some motivation for this? Those things are types so it seems like they should be coloured as such.
Unfortunately we can't change colours conditionally in a textmate grammar, so this isn't something we could control as an option there (we could perhaps have a Semantic Tokens modifier for built-in types like these that would allow you to customise them, but based on your other issues I think you're not using Semantic Tokens and that might not help you).
To change the textmate grammar, I think it would need to be clear that the majority of users would prefer this change.
Can you provide some motivation for this? Those things are types so it seems like they should be coloured as such.
Clarification
I don't need there to be an option to toggle this, I can manually do it in the settings if TextMate grammars are provided.
Motivation
Dart is my second language after C#, and I got used to seeing keywords such as int, bool, etc. highlighted as keywords.
(In fact, the images above are actually from Dart and C#).
In my opinion, since int, bool, etc. in Dart are built-in types (i.e. shipped with the SDK and don't require an import statement), they could technically be interpreted as keywords.
In C#, built-in keyworded types are given the scope keyword.type.<type>.cs (e.g. int would be given keyword.type.int.cs).
Therefore, in Dart, these built-in types could be given scopes such as:
This should keep the same colouring by default, but I think would allow you to customise the colours yourself in the VS Code settings.
I think we should only do it for the items in that existing list though. Types like Set/List/Map/etc. are not really special - they are just classes that live inside the SDK (like hundreds of other classes). The textmate grammar cannot tell the difference between List from the SDK and class List {} that is user-defined.
changed the title [-]Syntax Highlight `bool`, `num`, `double`, `int` as Keywords[/-][+]Add more specific scopes to `bool`, `num`, `double`, `int`, `Object`, `String`, `dynamic` in textmate grammar[/+]on Feb 5, 2024
Ah sorry, I misunderstood from comments in #4963 and thought you had semantic tokens disabled.
Semantic Tokens will completely replace the textmate grammar (this is VS Code behaviour), although the grammar will be used immediately when you open a file and then replaced when the tokens arrive.
In that case, supporting this would require server changes to add additional modifiers to those types.
in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
Activity
[-]Syntax Highlight bool, num, double, int as Keywords[/-][+]Syntax Highlight `bool`, `num`, `double`, `int` as Keywords[/+]DanTup commentedon Feb 5, 2024
Can you provide some motivation for this? Those things are types so it seems like they should be coloured as such.
Unfortunately we can't change colours conditionally in a textmate grammar, so this isn't something we could control as an option there (we could perhaps have a Semantic Tokens modifier for built-in types like these that would allow you to customise them, but based on your other issues I think you're not using Semantic Tokens and that might not help you).
To change the textmate grammar, I think it would need to be clear that the majority of users would prefer this change.
crkit-chan commentedon Feb 5, 2024
Clarification
I don't need there to be an option to toggle this, I can manually do it in the settings if TextMate grammars are provided.
Motivation
Dart is my second language after C#, and I got used to seeing keywords such as
int,bool, etc. highlighted as keywords.(In fact, the images above are actually from Dart and C#).
In my opinion, since
int,bool, etc. in Dart are built-in types (i.e. shipped with the SDK and don't require animportstatement), they could technically be interpreted as keywords.In C#, built-in keyworded types are given the scope
keyword.type.<type>.cs(e.g.intwould be givenkeyword.type.int.cs).Therefore, in Dart, these built-in types could be given scopes such as:
keyword.type.int.dartkeyword.type.double.dartkeyword.type.string.dartkeyword.type.num.dartkeyword.type.object.dartkeyword.type.dynamic.dartkeyword.type.set.dartkeyword.type.list.dartkeyword.type.map.dartkeyword.type.symbol.dartkeyword.type.bool.dartDanTup commentedon Feb 5, 2024
One option is that we change
support.class.darttosupport.class.primitive.darthere (and addStringto the list):Dart-Code/syntaxes/dart.json
Lines 231 to 234 in 622472f
This should keep the same colouring by default, but I think would allow you to customise the colours yourself in the VS Code settings.
I think we should only do it for the items in that existing list though. Types like Set/List/Map/etc. are not really special - they are just classes that live inside the SDK (like hundreds of other classes). The textmate grammar cannot tell the difference between
Listfrom the SDK andclass List {}that is user-defined.crkit-chan commentedon Feb 5, 2024
That sounds perfect!
What about
Objectthough? Would that also be included?DanTup commentedon Feb 5, 2024
Yeah, I think it would be reasonable to include that too.
[-]Syntax Highlight `bool`, `num`, `double`, `int` as Keywords[/-][+]Add more specific scopes to `bool`, `num`, `double`, `int`, `Object`, `String`, `dynamic` in textmate grammar[/+]crkit-chan commentedon Feb 5, 2024
Sorry, I didn't fully read your comment before.
To clarify, I use semantic tokens.
I like them as they provide much richer information, but it is sometimes annoying that they override textmate tokens.
Sorry, I tried the fix and I actually do need semantic tokens for this, as they are overriding the TextMate tokens.
With semantic highlighting:
Without semantic highlighting:
DanTup commentedon Feb 5, 2024
Ah sorry, I misunderstood from comments in #4963 and thought you had semantic tokens disabled.
Semantic Tokens will completely replace the textmate grammar (this is VS Code behaviour), although the grammar will be used immediately when you open a file and then replaced when the tokens arrive.
In that case, supporting this would require server changes to add additional modifiers to those types.
crkit-chan commentedon Feb 5, 2024
Sorry, in that issue I meant something like "this syntax highlighting does not need semantic tokens".
Would it be wise to implement both? (I.e. in this v3.84.0, release TextMate grammars, and later release semantic highlighting)?
DanTupBot commentedon Nov 8, 2026
Closely related issues requesting finer-grained Semantic Tokens / modifiers for theming:
const,late,final,async, andabstract.semantic token typefor a function as a parameter/getter #4585 ("Differentsemantic token typefor a function as a parameter/getter"): Requests a semantic token modifier for function-typed parameters/variables.