[nvim.completion] Signature help for overloads
Contributing guidelines
- [x] I have read CONTRIBUTING.md
- [x] I have read CODE_OF_CONDUCT.md
Module(s)
mini.completion
Description
Since https://github.com/neovim/neovim/pull/33646, neovim(stable) supports multiple signatures in signature help. This is beneficial for overloads in C/C++. This can be triggered with <C-S> as explained in :h news. Since mini.completion supports signatures out of the box, would it be possible to integrate multiple signatures? Right now, if I type a function, and then <C-S>, there are two signature_help windows, one by nvim and one by mini.completion.
Thanks for the plugin!
Thanks for the suggestion!
The initial idea of a signature window is to have a one-line (possibly wrapped) signature. I'll take a look if automatically showing all signatures is possible with concise adjustments. Having a mapping that cycles through possible signatures is probably off the table.
To make it easier in the future, would you mind posting as small as possible code example (presumably in C/C++ with clangd) and position at which there should be more than one signature. That'll greatly help in testing.
This feature will be beneficial to all languages which allow function overloading. See the attached example.
#include <string>
int func(int a) { // func 1
return a;
}
int func(int a, int b) { // func 2
return a + b;
}
std::string func(std::string abs) { // func 3
return abs;
}
int main() {
func(1, 2); // Cursor after (
}
Pressing <C-s> at (_1 should show the behaviour I mentioned. mini.completion already changes the signature help if the number of parameters increases. For example, try
func(1
func("s
func(1, 2
and see that the signature for when , is input changes to func 3. Ideally, the signature when "s is input should also change to func 2, but I understand that may be a substantial change. In this case though, just showing the possible overloads is enough.
Also, I think either cycling or showing all signatures, both are acceptable, so feel free to look into whichever is easier.
Edit: Just to clarify, the three signatures by clangd are
func(int a) -> int
func(std::string abs) -> std::string
func(int a, int b) -> int
Thank you so much! I do see now how this might work. This helps a lot.