Proposal: show function head on hover #5463
Replies: 4 comments 11 replies
-
|
Just to contribute to "What other languages are doing", dart also show the function head when hover
|
Beta Was this translation helpful? Give feedback.
-
|
Where the function head includes generics would hovering over the call show the function head with the generics or with the inferred types? If it "fills in" the types is there a potential for this to be confusing? |
Beta Was this translation helpful? Give feedback.
-
|
Would format the head? What would be the max width? Would attributes and comments be included? |
Beta Was this translation helpful? Give feedback.
-
|
With this change it seems like it may be more challenging to understand the type due to it being more obscured and it not being specialised any more. I think this may be OK as you can hover specific arguments to see the specialisation, and signature help is still specialised. What do you think? |
Beta Was this translation helpful? Give feedback.









Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Right, when hovering over a function call, the language server displays its type and documentation.
For example:
This is the hover:

What I think it should be
I think the language server could show the function head instead of the type, that is show this:
Instead of this:
Why I think this is useful
When writing Gleam it feels great how everything feels right "on hand":
..in a pattern, a tooltip tells me all the fields I'm ignoring. It could be just as simple to jump to the pattern definition, but it feels better when the information is right there and I don't have to jump to some other file (possibly inside a dependency) to see for myselfI think the same goes for function heads: it is easy to jump to a function definition and read for myself the labels and arguments of the function. But it's not as immediate as seeing that in a nice hover tooltip: I have to jump to another file, see what the arguments are, and go back to what I was doing.
What other languages are doing
It's hard to do an apples to apples comparison with other languages as I'm not aware of any other mainstream language that has a distinction between public label and internal argument name.
But I think it's worth it to also see what other big languages do:
Every single mainstream language I can think of shows the function head, even languages like Rust, TypeScript, and Java where there's no labelled arguments and the argument name would be an internal detail (like in Gleam) they choose to show those on hover.
What we could do instead
fn(Int, some_label: String) -> a. I'm not a fan of this (or any variation on this theme) since that's no longer valid Gleam syntax. A function head, on the other hand, is always syntactically valid Gleam code.Beta Was this translation helpful? Give feedback.
All reactions