c++visual-studio-codeclangd

add (constructor) arguments auto completion


I am using clangd in my C++ project.

When clangd suggests a function, it also inserts placeholders for the functions:
enter image description here

However, when I type a constructor, I only receive the overload window I can cycle through. RETURN will just create empty parenthesis:
enter image description here

Can I make clangd insert placeholders for constructor parameters?

Edit:

My clangd arguments:

"clangd.arguments": [
    "--pretty",
    "--compile-commands-dir=${workspaceFolder}/build",
    "--background-index",
    "--completion-style=detailed",
    "--header-insertion=iwyu",
    "--function-arg-placeholders"
],
$ clangd --version
clangd version 19.1.7

Edit2:

The placeholders are already there, it's just that I need to scroll down for a particular constructor. Its a bit inconvenient.

enter image description here


Solution

  • Add --completion-style=detailed to clangd's command line arguments ("clangd.arguments" setting in VSCode), and restart clangd for it to take effect.

    Now, when you are typing Texture, the individual constructors should be offered as proposals, and if you select a particular one, you will get placeholders for the selected one.