Search code examples
visual-studio-codecode-completionclangd

How can I disable parameter auto-completion when selecting a suggested function in VS Code with the clangd extension?


When typing the prefix of a function name in VS Code, the IDE will provide suggestions to choose from. When using the clangd extension, if the suggestion is a function and the user selects it using the Tab key, VS Code will automatically complete the parameter list and enter a strange editing mode. However, sometimes when the user wants to use the function as a function pointer, this feature can be annoying.

This is the suggestions. After selecting, the content within the red box will be automatically completed.

I have tried to disable this feature in both VS Code settings (such as disabling Inlay hints, etc.) and clangd settings(not been able to find any relevant options in the official documentation for clangd).

If I set editor.suggest.showFunctions to false in VS Code, there will be no more suggested functions, which is not what I want.


Solution

  • Try putting the following in your settings.json file:

    {
        "clangd.arguments": [
            "--function-arg-placeholders=0"
        ],
    }
    

    This information provided courtesy of Disable function/method arugment insertion.!? #92.

    For your reference / learning purposes, I found that issue ticket by searching "is:issue function argument " in the GitHub issues page for the VS Code clangd extension.


    Old answer before more clarification was added:

    Is this not just a case of having to put "editor.parameterHints.enabled": false in settings.json?

    If you want this setting to only apply to C++ files, then you can wrap the setting in [cpp]: { ... }.

    Also related if you're using the vscode-cpptools extension: C_Cpp.autocompleteAddParentheses (default value is false).

    The clangd extension configuration contributions can be found here, but I think all you need is editor.parameterHints.enabled.