Open jiribenes opened 3 months ago
Server
trait, add some getInlayHints: Range => Option[Vector[InlayHint]]
methodServices
class, register inlay hints as server capabilities (docs)Services
catch the textDocument/inlayHint
event (similarly to https://github.com/effekt-lang/kiama/blob/ab6aef78fc4ce99a9ad2db8555718d00b03f7b8a/jvm/src/main/scala/kiama/util/Server.scala#L518-L519)server.getInlayHints
on the serverRange
and create a new InlayHint, setting the position, label, etc. (docs)LanguageService
trait, define some basic case class for InlayHint
s, let's say for types and parameters for now?getInlayHints
in LSPServer
here in this repo
We could use inlay hints from LSP v3.17 for:
[{io}] def ...
)def bar(x: Int) [: Int / Log] = ...
)val foo [: Int] = ...
)"answer is: " ++ <{ 42 [: Int] }> [: String]
)val boxed = [box ] function
)bank.transfer([from =] person1, [to =] person2)
[?1] <{ ... }>
)(where
[...]
means an inlay hint)Note that these would probably need to be highly configurable so that the code is still somewhat navigable. :)
As far as I can tell, we're already doing 1. in a somewhat ad-hoc way: https://github.com/effekt-lang/effekt/blob/7b7629c942e2809cab08b0122e244ba3bcbb9410/effekt/js/src/main/scala/effekt/LanguageServer.scala#L138-L143 but it would be nice to use the LSP protocol instead.
There are also a lot of other quality of life related features like "if we already have an inlay, we can just double-click it to apply" like in rust-analyzer (see first video there for a demo).