Skip to content

Signature help on function applications #252

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

Closed
amiralies opened this issue May 24, 2021 · 13 comments · Fixed by #547
Closed

Signature help on function applications #252

amiralies opened this issue May 24, 2021 · 13 comments · Fixed by #547
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@amiralies
Copy link
Contributor

https://microsoft.github.io/language-server-protocol/specification#textDocument_signatureHelp

@cristianoc
Copy link
Collaborator

What's the idea -- different than hover?

@amiralies
Copy link
Contributor Author

It automatically opens when typing function applications (via ( for example) and also users can config a hotkey to open the signature help while writing.
Another feature i see in ts extension is it highlights current parameter you're applying in signature help box.

@amiralies
Copy link
Contributor Author

recording.mp4

This is an exmaple from ts extension

@cristianoc cristianoc added the enhancement New feature or request label May 25, 2021
@cristianoc
Copy link
Collaborator

cristianoc commented May 25, 2021

How's that triggered in the example? By ( ?
And any ideas of how the mechanism is different from normal auto-completion? Because it has a notion of n-th argument?

@cristianoc
Copy link
Collaborator

This feature is quite compelling.

@amiralies
Copy link
Contributor Author

I'm not sure currently.
they are two plugins i'm aware which are implementing this feature.
tsserver (bundled with vscode)
metals (scala language server https://github.com/scalameta/metals-vscode)

@cristianoc
Copy link
Collaborator

cristianoc commented May 26, 2021

This looks roughly like:

  • ( triggers signature help
  • , re-triggers (for the n+1-th argument)

Needs a list of labels (the function parameters), and an index (of the current argument).

So:

let add = (x,y) => x+y

Then given:
add(3,

would need to return:

  • [int, int] (the list of parameters, perhaps named with conventional names, perhaps one can retrieve "x" and "y" from the ast)
  • 1 (index of the second parameter)

@cristianoc
Copy link
Collaborator

As usual some care is required about context:
foo(3, (2, should not trigger anything as it's about an inner tuple, not an argument to foo.

@cristianoc
Copy link
Collaborator

For perf reasons, context scanning should happen before doing any other work that scans project structure etc. As context scanning is pure string parsing.

@cristianoc
Copy link
Collaborator

In fact, the same perf comment apply to completion: #255

@oblitum
Copy link

oblitum commented Aug 16, 2021

The server publishes the characters that trigger this in Server Capability SignatureHelpOptions.triggerCharacters.

@oblitum
Copy link

oblitum commented Aug 16, 2021

This is must have, most servers provide this. Just having bare function names completed is a bit lacking. Also, a good chunk of servers also provide snippet expansion on top, meaning, not only is signatureHelp available, you can also expand the function call with all arguments filled with placeholders you can jump to.

gif-2021-08-16-181416

@zth
Copy link
Collaborator

zth commented Jun 2, 2022

Unless @cristianoc disagrees, this sounds like a good first issue for a contributor with some OCaml skills. Essentially, we should have all we need in the analysis bin now that we've integrated the full parser.

@zth zth added the help wanted Extra attention is needed label Jun 2, 2022
@zth zth mentioned this issue Aug 6, 2022
@zth zth closed this as completed in #547 Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants