haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.66k stars 355 forks source link

Feature request: Fixity information in hover #2019

Closed viluon closed 2 years ago

viluon commented 3 years ago

Pardon me if there's a better place to open this issue, or if it has been discussed already. I tried to look for similar suggestions but could not find any.

When dealing with infix operators -heavy expressions, it is sometimes difficult to tell what precedence various operators have. In some cases, different parenthesising can lead to semantically different but equally type-correct expressions.

It would be helpful if HLS could show the fixity of an operator along with its type in the hover. (Not very relevant screenshot follows)

image

isovector commented 3 years ago

@ErnestKz and I did some work on this front. He might be in a good position to get it pushed through

https://github.com/ErnestKz/haskell-language-server/commit/c23b213d1a76486cb571b5317dadad72b6eca76e

ErnestKz commented 3 years ago

Recently wrapped up some other stuff, I can pick this up now and try get it pushed through. 👍

ErnestKz commented 3 years ago

Hey, unfortunately did not get around to spending time on it, and I'm not sure I can see myself spending time on it in the near future.

The fork https://github.com/ErnestKz/haskell-language-server/tree/explicit-prescedence is the most up to date I have it, so feel free if anyone would like to pick it up.

Also, here's a pair programming session with Isovector that built up to that point VIDEO

jneira commented 3 years ago

Many thanks for share your work

Vlix commented 3 years ago

I just thought of this feature request too. Maybe this is self-evident, but I hope if this gets implemented, it also works for non-operator functions that have explicit infix notations :heart:

July541 commented 2 years ago

I'll pick this.

I'm thinking of adding an extra inlay hint for the operator, is it reasonable?

/cc @michaelpj

July541 commented 2 years ago

More a little off-topic, how about adding inlay hints to show signature for inner expressions?

f = g
  where
     -- inlay hint here
     g = undefined
michaelpj commented 2 years ago

The lsp library doesn't support inlay hints yet, I think.

Indeed, I would love to have type signature code lenses for local bindings, I'm not really sure why we don't!

michaelpj commented 2 years ago

I think just putting the fixity in the hover doc would be good enough for starters.

July541 commented 2 years ago

OK, we can put inlay hints later.