Skip to content

LS: hover info for custom types and their constructors #4451

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

Open
unknown opened this issue Apr 6, 2025 · 5 comments · May be fixed by #4458
Open

LS: hover info for custom types and their constructors #4451

unknown opened this issue Apr 6, 2025 · 5 comments · May be fixed by #4458
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium

Comments

@unknown
Copy link

unknown commented Apr 6, 2025

The language server currently doesn't return hover info for custom types and their constructors. It would be useful for the language server to support this.

//// wibble.gleam

type Wibble {
  // ^ wibble.Wibble

  Wibble(Int)
  // ^ fn(Int) -> Wibble

  Wobble(String)
  // ^ fn(String) -> Wibble
}

The proposed behavior above would be consistent with the hover info of type annotations and constructor expressions.

@GearsDatapacks
Copy link
Member

Ah, I think that may be a bug. I'm sure I've used that feature before. I'll investigate

@lpil lpil added help wanted Contributions encouraged good first issue Good for newcomers priority:medium labels Apr 6, 2025
@unknown
Copy link
Author

unknown commented Apr 6, 2025

Ah, I think that may be a bug. I'm sure I've used that feature before. I'll investigate

I've tested every tagged release dating back to v1.0.0, and none of the versions provided hover info on my machine. Feel free to investigate further, but I'd like to work on this in the meantime!

@GearsDatapacks
Copy link
Member

Go ahead! I haven't had a chance to look at it yet

@unknown
Copy link
Author

unknown commented Apr 7, 2025

Ran into a small issue with implementing the proposed behavior because RecordConstructor doesn't store any data related to which custom type it's a member of. Not sure if there are other approaches to get the custom type, but alternatively, we can display something similar to rust-analyzer's behavior when hovering enums like the following:

//// wibble.gleam

type Wibble {
  // ^ Wibble

  Wibble(Int)
  // ^ Wibble(Int)

  Wobble(String)
  // ^ Wobble(String)
}

I think this is also more readable and useful.

@unknown unknown linked a pull request Apr 7, 2025 that will close this issue
@unknown
Copy link
Author

unknown commented Apr 14, 2025

While working on this, I've also realized that type aliases do not have any hover info. Is this something that we want to support? If so, should I open a separate issue or merge that into this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants