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

Add labels when showing a hovered function type #4328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

giacomocavalieri
Copy link
Member

This PR closes #3507 by adding labels to function types that are displayed when hovering on something. This works for constructors, imported functions, functions and function heads!

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

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

To me this introduces a new syntax which is a mix of the expression syntax and the type syntax, and it implies that labels are part of the type. Maybe it'd look more like the existing syntax if it included the function name?

Another thing is that for some expressions when you hover it shows the type at the top, but for these it does not. I'm not a big fan of this inconsistency. Is there a more definition-like format we could use for the others too?

@lpil lpil added the discussion The approach has not yet been decided label Mar 11, 2025
@giacomocavalieri
Copy link
Member Author

Maybe it'd look more like the existing syntax if it included the function name?

So what would it show in this example?

fn wibble(a: Int, label b: String) {}

pub fn main() {
  let var = wibble
//     ^ Cursor here:
//         var(Int, label: String)
}

Another thing is that for some expressions when you hover it shows the type at the top, but for these it does not.

Yeah I didn't think too much about it, not really sure. If the goal is to always keep a type you can copy-paste into Gleam code then I don't see a meaningful way to show labels for functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion The approach has not yet been decided
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LSP: function hover info should include argument labels
2 participants