Open Jaeiya opened 6 months ago
This is an issue with the theme, not the grammar. My Typescript files have the same problem on Dark (visual studio)
.
Some themes use the same colors for different elements or just don't have colors defined for some elements.
I understand that, but usually if a color isn't working, I can at least find the classes I need to change (ie entity.name.type
) to manually edit it. That's not the case here though. Is there a reason there are no defined classes for the other theme?
This seems to be an issue with semantic highlighting support (tree sitter). Our textmate grammar is pretty bare bones at the moment, most of the highlighting is done by tree sitter and it seems some themes don't support it, like Dark (visual studio)
.
I improved out TextMate grammar but the new version is not released yet. Should come on 0.17 which I hope is a week or two away.
Thank you! I appreciate you looking into this. I'll look forward to the upcoming release.
@Jaeiya. The new version is released. It should have better syntax highlighting even without tree-sitter.
It's definitely better, there's only a couple tokens (that I see immediately) which are still missing accurate scopes:
name = species.toUpperCase()
The toUpperCase()
is missing a specific scope, it only has the generic source.pkl
scope.
function greet(bird: Bird): String...
The greet
has the other.property.pkl
scope, but it should have the same scope as the toUpperCase()
above, when you create one, since they're both functions. I'm assuming here that other.property.pkl
is not the intended scope, since I would expect something like function.pkl
TextMate grammars will never highlight as well as the semantic highlighting from tree-sitter because they are just regexes, so themes that don't support it will never look as good. But if you find any low hanging fruit on the grammar feel free to create a PR or an issue on pkl-tmBundle.
technically no as tree-sitter doesn't have lookbehinds and lookahead doesn't work very well without the C scanner
toUpperCase()
and greet()
is very easy to mark as function
On the theme I'm currently using, which is Dainty Nord, the syntax highlighting doesn't work completely. If I switch to Dark+ I do see the expected highlighting. I assumed maybe it was a problem with my theme, but then I tried the other default theme Dark (visual studio) and it also does not work properly.
This is Dark+![image](https://github.com/apple/pkl-vscode/assets/2054218/e09a7794-437d-44b9-bf89-207a159664bd)
This is Dark (visual studio)
'
I then inspected the tokens for each theme and it looks like they're only defined for certain themes, which is odd since I've never seen theme-dependent tokenization before.
Dark (visual studio)![image](https://github.com/apple/pkl-vscode/assets/2054218/d10a637c-0292-424a-92eb-860c34e80aee)
Dark+![image](https://github.com/apple/pkl-vscode/assets/2054218/6fc04b74-ef0d-4f37-b561-485d0e9ad96a)