How to setup clangd for C++ 20?

As title. I have error message on consteval. I have already added a .clangd file with option -std=c++20.

Unknown type name 'consteval'; did you mean 'constexpr'? (fix available)

If you want to see the image I clipped goto this issue: How to setup clangd so that it can recognize C++20 keyword, like consteval? · Issue #1602 · neovim/nvim-lspconfig (github.com)

For compile_flags.txt only -std=c++20 seems to work.

For .clangd it seems it should be:

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

@zeertzjq: Is it possible to setup this in the init.lua? I don’t like creating additional files.