I use Helix Editor and by default it uses clangd as LSP server.

But when I use “newer” C++20 features I get warning messages in the editor that they are only available in “later” C++ versions or I get straight up error messages.

So how do I tell clangd that I am writing C++20 code? I am guessing passing an argument (-std=c++20) or creating a “project properties” file…

This is the Helix Editor configuration file, languages.toml:

[[language]]
name = "cpp"
language-server = { command = "clangd", args = [] }
auto-format = true

Please let me know the right way to do it.

You are viewing a single thread.
View all comments
4 points

If you use meson or cmake, you can generate a compile_commands.json which you can link from the build dir into your source dir. If not you cam create a local config file for clangd https://stackoverflow.com/questions/73758291/is-there-a-way-to-specify-the-c-standard-of-clangd-without-recompiling-it

permalink
report
reply
3 points

This, .clangd, file in the root of the project directory worked:

CompileFlags:
  Add: [-std=c++20]

Thank you!

permalink
report
parent
reply

C++

!cpp@programming.dev

Create post

The center for all discussion and news regarding C++.

Rules

  • Respect instance rules.
  • Don’t be a jerk.
  • Please keep all posts related to C++.

Community stats

  • 28

    Monthly active users

  • 264

    Posts

  • 537

    Comments