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

Improper syntax highlighting #6323

Open
Enyium opened this issue Sep 26, 2024 · 5 comments
Open

Improper syntax highlighting #6323

Enyium opened this issue Sep 26, 2024 · 5 comments
Labels
a:editor integration VSCode extension, treesitter, and other editor integration (mT,bO) bug Something isn't working

Comments

@Enyium
Copy link
Contributor

Enyium commented Sep 26, 2024

The following syntax highlighting in VS Code looks off:

1

2
(% should probably be colored like the digits, because this is also the case with units like px.)

3

@ogoffart ogoffart added the need triaging Issue that the owner of the area still need to triage label Sep 26, 2024
@ogoffart
Copy link
Member

ogoffart commented Sep 26, 2024

component F {
   font-size: 1.5rem;
   width: 100%;
   property <color> my-color-1: true ? white : black;
   property <color> my-color-1: true ? black : white;
}

Can be reproduced with github on this snippet, so this is a bug in the textmate grammar. (https://github.com/slint-ui/slint/blob/master/editors/vscode/slint.tmLanguage.json)

@ogoffart ogoffart added bug Something isn't working a:editor integration VSCode extension, treesitter, and other editor integration (mT,bO) and removed need triaging Issue that the owner of the area still need to triage labels Sep 26, 2024
@hunger
Copy link
Member

hunger commented Sep 26, 2024

VSCode seems to be working towards supporting tree-sitter (microsoft/vscode#207416)... that is a way better way to support syntax highlighting than the textmate, Slint supports it and it works fine there:

image

Maybe we can just switch to tree-sitter soon?

@tronical
Copy link
Member

Relevant in VS Code might be microsoft/vscode#210475 . It looks like right now they're using the grammars compiled to WASM and it's not extensible yet. Very promising though :)

@ogoffart
Copy link
Member

Regardless, we'll still want to maintain the textmate grammar for other things that uses it like the GitHub.

hunger added a commit to hunger/slint that referenced this issue Sep 27, 2024
1. Add in all the color names
2. Move more constants into the general section
3. Apply the general section when parsing properties

Fixes: slint-ui#6323
@hunger
Copy link
Member

hunger commented Sep 27, 2024

With #6355 applied this is what the example from above looks like in VSCode:

image

using the default dark theme...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:editor integration VSCode extension, treesitter, and other editor integration (mT,bO) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants