Skip to content

Conversation

@chrisgrieser
Copy link
Contributor

@chrisgrieser chrisgrieser commented Apr 24, 2025

A first draft for fixing #1670, with an (admittedly slightly hacky) workaround to check if the signature is the same on the previous and the following line to detect multiline callbacks.

Some issues:

  1. The solution requires making three requests to for LSP signature, and awaiting all three results. However, I don't have any previous experience with dealing with async in lua, and I couldn't figure out how async works in blink.cmp. Thus, there is currently only a naive solution right now running all three requests at the same time, which will probably sometimes fail due to race conditions.
  2. Nonetheless, the solution appears to work for me in almost all the cases I tested. It does not work when entering insert mode at the end of a line (or via cc and o). Though I suspect that is since the signature help is triggered by something else, which might be a bug unrelated to this PR, since I also had a few cases where signatures showed up when they shouldn't when using show_on_insert = false.
  3. I checked, and calling vim.lsp.buf.signature_help in a multiline-callback just results in "No signature help available", so apparently, vim.lsp.buf.signature_help already have some method of determining those? Maybe the workaround of this PR is not needed after all.

(Just to note, I based the PR on tag v1.1.1 and not main, since the current HEAD of main appears to not work for me.)

@saghen
Copy link
Owner

saghen commented May 3, 2025

Sorry for the late review! We should use context.trigger.kind instead of context.show_on_insert, to match the other trigger/context code: https://github.com/Saghen/blink.cmp/blob/main/lua/blink/cmp/completion/trigger/context.lua#L33-L34

You can await multiple tasks with require('blink.cmp.lib.async').task.all(your_tasks):map(function(task_outputs) end)

I checked, and calling vim.lsp.buf.signature_help in a multiline-callback just results in "No signature help available", so apparently, vim.lsp.buf.signature_help already have some method of determining those? Maybe the workaround of this PR is not needed after all.

That's very interesting! I don't have time to investigate it atm, but here's the code for it: https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp/buf.lua#L350`

@chrisgrieser
Copy link
Contributor Author

Yeah, I investigated this further and the signature in multi-line callbacks is definitely not due to the LSP, but a bug in blink's implementation.

Closing this PR, since it's obviously preferable to fix the bug instead of adding the workaround of this PR.

Will be adding some details at #1670 since that issue is the original bug report.

@chrisgrieser chrisgrieser deleted the dev branch May 3, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants