-
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
Rascal LSP uses textmate token scopes where it should use SemanticTokenTypes for the syntax highlighting. #366
Comments
Ouch! Good analysis. How about this:
This way we fix the bug and also keep in line with the rest of the LanguageServer design, and we stay backward compatible for a while. |
That is cool, but it does mean you have to import the I was currently working on this:
Pros:
Cons:
|
Watch out... next to the standard types and modifiers, there is more:
|
Yes, but that is not LSP. That's VS Code that is helping out map semantic token types to textmate scopes for the themes that do not have extensive semantic token support. |
Also Custom TextMate scope mappings can be added. We could use these to support the old Rascal-eclipse tokenType names, such as "ambiguity", etc. They can be added to the json configuration file and do not have to be directly associated with any language. |
Indeed, but again, this is a VS Code specific extension. LSP does not want us to do this. VS Code API of semantic tokens is not the same as LSP api of semantic tokens. By design they've limited the categories. But I was also thinking, that yes, for the ambiguity nodes, we could try and sneak one in, that just won't work for other LSP clients. |
The original implementation was half working, due to an incorrect interpretation of the standard. This commit fixes that, but also adds modifiers Fixes #366
The original implementation was half working, due to an incorrect interpretation of the standard. This commit fixes that, but also adds modifiers Fixes #366
I see your points, but I want to work towards a more ideal situation. Syntax highlighting is a core feature of the Rascal game, in Eclipse, in VScode but also elsewhere in other LSP instances or even on the commandline. I don't like the strings since they lead to the kind of bugs that we are now fixing here. Things happily seem to work, but then they don't. Our users have to find this out. So I guess I am proposing an extension to
|
Note that tags are not checked by the type checker (yet). Right @PaulKlint ? |
If you mean typechecker (instead of prettyprinter): I actually fixed that yesterday! |
type checker! duh.. where did that come from? Oh that's cool. That will help us find a few bugs! |
@DavyLandman but that means that |
Ok, so I like your idea @jurgenvinju. But since we're running into this issue at our customers and rascal is in the middle of a lot of shakeup, how about we split the fix in 2 phase.
So apart from this scheduling proposal, I have a small comment on the design proposed: that the LSP categories are quite limited, they designed it to force people into a small set of options that can reliably be mapped to a theme, but things we would consider normal is missing. Like for example there are only classes, interface & structures. And a lot of things will have to map to Also, I'm not sure if |
Or alternative point 1: do fix the name mapping part, but drop the I think that would be my preference. I've updated #367 with these changes. |
After some offline discussion with Jurgen, we came to the conclusion that #367 fixes the current bug, while usethesource/rascal#1928 will give the proper support for this. Therefore we'll keep #367 "small" |
Describe the bug
Rascal LSP is reporting the wrong kind of semantic token types in the legend. This makes it a hit and miss which ones are properly highlighted.
To Reproduce
Annotate a production with
@Category{constant.numeric}
and it doesn't get the colors of numeric contants of the theme, whilestring
as category does work.Analysis
I think the documentation on this feature has been improved, it used to be less clear what LSP expected, I've read some old GH issues discussing the closed aspect of these TokenTypes. The set of valid token type is limited to the enum mentioned in the LSP spec, which is a subset of the API in VS Code
Now why did it even work? We were passing sublime scopes like
entity.name
andvariable.function
. But VS Code is ignoring after the.
(as the syntax is actually<tokentype>.<modifier>
in VS Code, no LSP). So if the first name happened to be in the list (or we used something likestring
) it accidentally worked. Butconstant.numeric
(orconstant
) doesn't exist as a TokenType, so it gets no highlighting applied. A user cannot just do@Category{number}
instead, as rascal-lsp has a hardcoded list of token types, andnumber
is not in there.Solution
The text was updated successfully, but these errors were encountered: