-
Notifications
You must be signed in to change notification settings - Fork 113
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
Semantic Highlighting of class members #105
Comments
Same problem here and same system informations System |
Thanks! This wasn't obvious to me, I implemented the protocol from the LSP spec and the TM scope mapping wasn't mentioned there. I agree with your fix. The relevant code is here: https://github.com/llvm/llvm-project/blob/c964f308141578f24932c68a03af5fae7f876011/clang-tools-extra/clangd/SemanticHighlighting.cpp#L564, I'll fix it shortly. |
I've also sent microsoft/language-server-protocol#1146 to clarify the LSP spec here. |
(This is a bug in clangd rather than the vscode extension, and so it won't be released until clangd 12 I'm afraid) |
I did not expect this mapping to happen on the clangd side — thanks a lot for the quick fix! Now that I know where to look, I might propose some other changes (now potentially with pull requests) in the future over there, so thank you for pointing me to the right place in the implementation, too! |
This isn't obvious, but vscode maps member as 'entity.name.function.member', so it's really for member functions. Fixes clangd/vscode-clangd#105
When using clangd semantic highlighting in VS Code, member variables and member functions are coloured the same way. As an example, consider the following code snippet:
Here
integer
andfunction
are formatted the same, irrespective of the colour theme used.After some digging and experimenting with a custom theme, it has emerged that both types of members have different
SymbolKind
values as theirkind
in the reply of thetextDocument/documentSymbol
operation of the LSP protocol (8 vs. 6 i.e.Field
vs.Method
), which can be seen in the log attached below. This does not appear to be the issue.However, both kinds seem to be mapped to the same semantic token type in VS Code, that is
member
(see tokenClassificationRegistry.ts).While this may sound sensible,
member
is rather clearly meant for functions, given its mapping to the TextMate scopeentity.name.function.member
, i.e. the styling of member variables in themes may be closer to functions than to variables.As a solution, I propose keeping the mapping from the
SymbolKind
Method
to the semantic token typemember
, as this seems to be intended, but to mapField
to the semantic token typeproperty
, if that is at all possible.I am not an expert on this issue at all and have found all of that out through a few hours of research; as such I have not been able to find a suitable place to fix this.
If pointed sufficiently in the right direction, I would be willing to try and fix this issue.
Logs
System information
Clangd version (from the log, or
clangd --version
):11.0.0
clangd extension version:
0.1.7
Operating system: Manjaro Linux
The text was updated successfully, but these errors were encountered: