-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add semantic highlighting #869
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
@clason I think the client needs to be configured as well so it knows about the token types and the modifiers. In VSCode, I had to do the following in the extension:
Then, I can set the colors separately using
Sure, if you edit the |
This comment was marked as resolved.
This comment was marked as resolved.
Yeah, it looks the client needs to explicitly support the token types. I think in this case, it is better to stick with the pre-defined ones. This is what VSCode sends for example: "semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary]" |
This comment was marked as resolved.
This comment was marked as resolved.
@clason Ah, it looks like Neovim does not support the range request. I can add the full one, too. |
7b2f02e
to
f414d9e
Compare
Yep, works like a charm now, including custom labels! Thanks! |
I think inline |
4c55f3c
to
0d5b0aa
Compare
Just to be clear: the |
Maybe the type of the label/citation would make more sense as a modifier? |
Not (yet) with the current implementation but I think we need a fallback for new tokens, too. Not all clients will support them right at the start.
I thought about this before, but due to how modifiers are encoded via LSP (bit sets) we cannot use more than 32 or 64 depending on the client so we have little room in the future for expansion. Maybe, the correct way would be to invert the token type in modifiers in this case. Define a |
Hmm, in this case maybe the granularity of the token types is not worth it (I have a hard time thinking how I would distinguish all of these types visually...) So my recommendation would be to drop this, actually, at least for now, and just stick to (On the other hand, Neovim allows me to just assign colors to modifiers themselves, so I wouldn't need to worry about the types for that.) |
by the way, it was brought to my attention that But as you already have the types, keeping these as token modifiers still makes sense? |
Yeah, this might be too much.
I think it makes more sense to report unused |
(there's still the undefined references, but those are then also probably better handled as diagnostics) Guess my bright ideas for semantic tokens just collapsed.... |
Well, there is still the possbility to highlight commands depending on the source of the definition:
|
Small ping; just wanted to ask whether you have any plans of adding the I can add an issue about it if it helps. |
@clason I am currently working on it (I did a small refactoring of the diagnostics module before ^^) |
This PR adds basic support for semantic highlighting (
full
andrange
).Token types:
genericLabel
sectionLabel
floatLabel
theoremLabel
equationLabel
enumItemLabel
genericCitation
articleCitation
bookCitation
collectionCitation
partCitation
thesisCitation
mathDelimiter
Token modifiers:
undefined
unused
deprecated