clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
592 stars 97 forks source link

Highlighting broken in headers #647

Closed MarkLagodych closed 2 days ago

MarkLagodych commented 3 days ago

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

HighCommander4 commented 3 days ago

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

MarkLagodych commented 2 days ago

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

HighCommander4 commented 2 days ago

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.