vscode-clangd: Trigger signature help after accepting a function completion.
Goodday,
I really enjoy using clangd. Its a must-have tool for every C++ programmer. However, there is one things that really irritates me. Because just as the title implies, it does not give a hover on auto-completing functions/metods. The default is to insert placeholders. Which honestly is weird for an extreme pedant language like C++ to insert illegal syntax (and also spamming the output on functions with a long agrument list). Fortunally it can be turned of with adding this argument.
--function-arg-placeholders=0
This will however break VScode’s hover – which is a way better way to use completing arguments all to getter. So now when auto-completing a function/method it will just type out the function with paranthesis. Regardless of howmany arguments it has. If you want to use the hover you then must press backspace to remove the parenthesis and then retype to parenthesis. Which is irritating me on a daily basis.
Also clangd is not honoring my parenthesis preference with this!
A nice solution whoud be to just not insert the parenthesis. This will force me (which is also conform my preference) to type the parenthesis myself and with that triggering the hover. But there are probably other things you can do inside the VScode plugin API to make the hover show if not using function-arg-placeholders
Thanks for your time for reading this, and please make people like me a bit happier in this world by given us the hover!
Thank You!
– using: clangd version 14.0.6 editor: VScode arguments:
"clangd.arguments": [
"--function-arg-placeholders=0",
"--header-insertion=never",
]
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 32 (14 by maintainers)
Commits related to this issue
- Trigger signature help when accepting code completions, where appropriate. As recommended in https://github.com/microsoft/vscode/issues/78806 This is an incomplete fix but better than nothing. Also f... — committed to sam-mccall/vscode-clangd by sam-mccall 2 years ago
- Trigger signature help when accepting code completions, where appropriate. (#398) As recommended in https://github.com/microsoft/vscode/issues/78806 This is an incomplete fix but better than nothing... — committed to clangd/vscode-clangd by sam-mccall 4 months ago
- Trigger signature help when accepting code completions, where appropriate. (#398) As recommended in https://github.com/microsoft/vscode/issues/78806 This is an incomplete fix but better than nothing... — committed to sr-tream/vscode-clangd by sam-mccall 4 months ago
This is a bit hard to follow, but IIUC there are two complaints:
foo
rather thanfoo()
orfoo(int x)
.The first is actually something clangd does, but we only enable it if the editor doesn’t support rich “snippet completions” (e.g. "insert foo() but place the cursor between the parens). I think this isn’t exposed as an option just because of our perception people don’t want it. Even here it’s not clear to me if it’s important per se or just a workaround for the second problem.
The secord problem is a VSCode-specific limitation/bug, this works OK in other editors. VSCode says the extension should provide an explicit hint to do this (https://github.com/microsoft/vscode/issues/31290) and the owners of the VSCode LSP library + LSP itself seem to think this hint should come via LSP, but haven’t added it to LSP yet. (https://github.com/microsoft/language-server-protocol/issues/274). I think we can work around this bug on the client-side by injecting the hint ourselves in the middleware.
I’m going to transfer this to the vscode-clangd repo since the second issue seems more important and is vscode-specific.
Okay to put it clear: Please add an option to disable auto-completion like any other plugins. vscode-clangd is good, and thank you, you will be appreciated, but the auto-completion is causing a lot of confusion to me.