haskell / haskell-language-server

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

Code lenses that show type signatures should be inlay hints instead #3254

Open michaelpj opened 1 year ago

michaelpj commented 1 year ago

Prompted by an issue with lsp-mode where they started showing code lenses at the end of the line instead of above the line by default (https://github.com/emacs-lsp/lsp-mode/issues/3749). I made an issue in the spec repo (https://github.com/microsoft/language-server-protocol/issues/1558) to ask whether clients can make any assumptions about where code lenses are displayed.

The answer seems to be no, we should not make assumptions about where code lenses are displayed. That means that the way we're using them to display type signatures is fundamentally unreliable. Fortunately, there is a feature that does allow specific placement of something in the buffer: inlay hints.

So I think the "right thing" here is to convert the code lenses that display type signatures into inlay hints.

July541 commented 1 year ago

I almost never insert the signature for instance methods really, agree to replace it with inlay hints.

michaelpj commented 4 months ago

cc @jinser

If the argument in this ticket is correct, then maybe we should be looking at the code that currently does the type signature code lenses and figuring out how to extend it to local bindings. Then we can switch that uniformly over to use inlay hints! Note that there was some progress on that here: https://github.com/haskell/haskell-language-server/pull/2966