clangd / vscode-clangd

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

Syntax tree entry (char) is not resolved #551

Closed Darkness2k19 closed 7 months ago

Darkness2k19 commented 7 months ago

char is not highlighted as if it was not parsed as a valid token const std::string sc(1, 'a'); static_assert(!std::is_assignable_v<decltype(*sc.data()), char>); Screenshot from 2023-11-20 02-09-25

Logs Initialization clangd.log

On hower over char I[01:56:57.013] <-- textDocument/hover(19) V[01:56:57.014] ASTWorker running Hover on version 1 of /home/darknessx/Projects/CPP/Programming/review/string/main.cpp I[01:56:57.016] --> reply:textDocument/hover(19) 2 ms V[01:56:57.016] >>> {"id":19,"jsonrpc":"2.0","result":null}

System information Clangd version: 16.0.2 clangd extension version: 0.1.24 Operating system: Ubuntu 22.04.3 LTS

HighCommander4 commented 7 months ago

Clangd does not apply semantic highlighting to keyword tokens in general, leaving that to client-side highlighting.

Is the apperance of char any different in this static_assert than on the line:

char c;

?

Darkness2k19 commented 7 months ago

Yes, it differs image

I supposed there was something with c++ version that is used to parse tokens and to highlight them because, if I change is_assignable_v to is_assignable or even just add a trailing ::, the char becomes properly highlighted image image but in that case clangd would not find the is_assignable_v itself so I thought it might be either a clangd extension bug or a problem of vscode itself

HighCommander4 commented 7 months ago

It's an issue of vscode's client-side highlighting, please file it at https://github.com/jeff-hykin/better-cpp-syntax.

You can also consider using Minimal C++ Syntax as an alternative client-side highlighting engine to VSCode's default, it does not have this problem.

Darkness2k19 commented 7 months ago

Thank you very much for your help, this issue is then resolved!