Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signatures: show all overloads #774

Merged
merged 4 commits into from
Dec 29, 2024
Merged

signatures: show all overloads #774

merged 4 commits into from
Dec 29, 2024

Conversation

hfn92
Copy link
Contributor

@hfn92 hfn92 commented Dec 25, 2024

with this change the signature help should show all signatures that are possible given the current parameters.
This is useful for languages that support function overloading.

Given

void fn_ov();
void fn_ov(int i, float f, float f2);
void fn_ov(int i, float f);
void fn_ov(int i);

it should show:
signatures

Copy link
Owner

@Saghen Saghen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Maybe there should be a limit on how many signatures we show? And maybe we should be smart about which signatures we prune (i.e. prefer fewer args, but filter out any signatures with less args than currently typed)

lua/blink/cmp/signature/window.lua Outdated Show resolved Hide resolved
if opts.detail and opts.detail ~= '' then detail_lines = docs.split_lines(opts.detail) end

if opts.detail then
if type(opts.detail) == 'table' then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local details = type(opts.detail) == 'string' and { opts.detail } or opts.detail
details = require('blink.cmp.lib.utils').deduplicate(details)

@hfn92
Copy link
Contributor Author

hfn92 commented Dec 29, 2024

@Saghen From what I can tell the list we get already contains only the possible signatures. E.g in my example fn_ov() and fn_ov(int i) are ignored because we are already at arg 2.

If you want I can add an option for the max amount of signatures. But I think this is already implicitly handled by blink.cmp.SignatureWindowConfig.max_height. I tested with 20 signatures but it will only show 10 lines, which is the default. Increasing max_height to >20 will then show everything. (I think this is how https://github.com/ray-x/lsp_signature.nvim works as well)

@Saghen Saghen merged commit 8ffddd9 into Saghen:main Dec 29, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 29, 2024

Thanks!

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