question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trigger signature help after accepting a function completion.

See original GitHub issue

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",
]

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
sam-mccallcommented, Oct 12, 2022

This is a bit hard to follow, but IIUC there are two complaints:

  1. you want a mode where function completion inserts foo rather than foo() or foo(int x).
  2. In VSCode, after accepting a function code completion, signature help doesn’t immediately trigger.

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.

0reactions
MK-Aliascommented, Oct 22, 2022

@wtdcode that is a different issue and I don’t think one we can do anything about it, please file a bug against vscode.

Yes, but the reason for that is that you’re not using the reguar signature-help. Instead - for what ever reason - you desided to go with the snippet engine for functions/methods which is not the way the editor is intended to work. No other language does this. This is your design choice, not that of VScode.

Maybe you can make an option to either use the [currently used] snippet-engine or the [requested] signature-help. But honestly I think the snippet-engine is inferieur in every way. Just look at @wtdcode issue and the fact it is generating illegal syntax and just a lot of spam on long argument lists, and lastly also not showing the function/method documentation (comment above the function/method).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trigger signature help after completion · Issue #13072 - GitHub
For signature help I have the triggerCharacter '(' but unfortunately inserting it by applying a suggestion doesn't trigger signature help. Is ...
Read more >
Azure Functions HTTP trigger | Microsoft Learn
Learn how to call an Azure Function via HTTP.
Read more >
Lsp - Neovim docs
This allows to trigger completion using i_CTRL-X_CTRL-O ... lsp-handlers are functions with special signatures that are designed to handle responses and ...
Read more >
AWS Lambda function handler in Node.js
When the handler exits or returns a response, it becomes available to handle another event. The following example function logs the contents of...
Read more >
How to trigger autocomplete suggestion box in vim or neovim ...
For instance, to use Ctrl + Space to trigger completion, you need to put the following in your vimrc: inoremap <silent><expr> <c-space> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found