clangd/vscode-clangd

Highlighting broken in headers

Closed this issue · 3 comments

The highlighting is wrong in headers, however it is correct in normal source files.

Test code snippet:

struct A { struct A const */**/ a; };
extern struct A const */**/ a;
void f(struct A const */**/ a);
struct A const */**/ g(struct A const */**/ a);

Actual result (header):

image

Expected result (source file):

image

Logs
clangd-log.txt

System information
clangd version: 18.1.3
clangd extension version: 0.1.28
vscode version: 1.90.2/flatpak
operating system: Fedora Linux 40 x86_64

The tokens that are colored differently between the two screenshots are struct, const, and /**/.

These tokens are not colored by clangd (clangd only colors semantic tokens, mostly identifiers), they are colored on the client-side by vscode.

Therefore, please report the issue to the client-side coloring engine at https://github.com/jeff-hykin/better-cpp-syntax (this is what vscode uses).

Alternatively, I would recommend using this alternative client-side coloring engine which works better in my experience: https://marketplace.visualstudio.com/items?itemName=daiyousei-qz.minimal-cpp-syntax

minimal-cpp-syntax worked well enough for me, though struct is still highlighted differently between headers and source files.
Thank you!

though struct is still highlighted differently between headers and source files

If you're interested in finding out more about this remaining discrepancy, a helpful VSCode command to know about is "Developer: Inspect Editor Tokens and Scopes". This will tell you information about where the color of the token at the editor caret location is coming from.