effekt-lang / effekt-lang/effekt

LSP inlay hints

Open
#524 2 comments 2 reactions 0 assignees View on GitHub
area:lsp quality-of-life requires-design
Dominant language
Scala
Stars
469
Forks
41
Avg merge
1d 16h
Merged PRs (30d)
23

Description

We could use _inlay hints_ from [LSP v3.17](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint) for:
1. ~~showing the inferred capabilities in a principled way (`[{io}] def ...`)~~ _EDIT: done in #828_
2. ~~showing the inferred return types and effects of functions (`def bar(x: Int) [: Int / Log] = ...`)~~ ~> #869
3. showing the inferred types of bindings (`val foo [: Int] = ...`)
4. showing the expected & actual type of a typed hole (`"answer is: " ++ <{ 42 [: Int] }> [: String]`)
5. showing the inferred boxes/unboxes? (`val boxed = [box ] function`)
6. showing the chosen overloads?
7. showing the argument names for functions with many arguments of the same type `bank.transfer([from =] person1, [to =] person2)`
8. showing the unique identifier for a typed hole? (`[?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](https://rust-analyzer.github.io/thisweek/2023/04/17/changelog-177.html) (see first video there for a demo).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.