gleam-lang / vscode-gleam

📟 Gleam support for VS Code
Apache License 2.0
155 stars 30 forks source link

Better hover support for each variable type #87

Closed tarikyildizci closed 2 months ago

tarikyildizci commented 2 months ago

Coming from typescript, in case of an error my workflow is usually like this:

what happens with gleam is:

I am also including an example image. Even if I hover over response, httpc, send, or request, I get the same text. I believe it would be helpful to see the hovered item's type below as well.

image
tarikyildizci commented 2 months ago

I am pretty new to Gleam, so this might not be an issue at all, but I have also noticed that when this behavior happens it usually highlights multiple lines, and it happens in the return statement of a function

lpil commented 2 months ago

Sorry, I'm not understanding. Why can't you hover in Gleam?

tarikyildizci commented 2 months ago

I can hover, but I cannot see the details I need sometimes. Let me explain with a function:

pub fn fetch(url: String) {
  use uri <- result.try(uri.parse(url))
  use req <- result.try(request.from_uri(uri))

  let resp_result = httpc.send(req)

  use resp <- result.try(resp_result)
  Ok(Nil)
}

Compiler gives an error as the return type of this function is faulty (I I have no idea what I am doing in here :P, but that is an issue with me and the error is irrelevant for this issue).

When I try to hover over .send to see what it accepts and returns, I can only see Result(a, Nil). In typescript, when there is an error and I hover over a method that has the wiggly lines It shows me error on top, and then the type annotations of the method below.

I think it would be helpful to show types and errors at the same time. I hope I made things more clear.

tarikyildizci commented 2 months ago

Here is an example in typescript:

image

Although there is an error, it still tells me that Response.ok is a boolean at the end, which I couldn't see when using gleam.

lpil commented 2 months ago

Gleam doesn't have any control over whether your editor requests a hover or not as it uses language server protocol. Testing in Neovim, an editor that gives the user more control over whether to request a hover or not, the hover is presented by the language server when it is asked for.

VSCode does not use language server protocol for TypeScript so it'll have different behaviour in ways that are out of our control.

tarikyildizci commented 2 months ago

Okay, thanks for the clarification.