scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.06k stars 320 forks source link

Refactor lsp4s requestAsync signature to return Task[T] #206

Closed olafurpg closed 6 years ago

olafurpg commented 6 years ago

Currently, the response for async lsp4s requests is Task[Either[Response.Error, T]]. However, editors like vscode don't even present Response.Error like "invalid request" in the UI so it's better to use window/showMessage to report problems. We should refactor the signature to return Task[T] instead and make Response.Error extend Throwable so we can still handle them.

olafurpg commented 6 years ago

I have a WIP commit from January that started this refactoring https://github.com/scalameta/metals/commit/3a8c1a7a797a8fdea80cd913aa8f068de3624621 Opening this ticket to remind myself to complete that work

olafurpg commented 6 years ago

After more thinking, it's fine to keep the signature unchanged. lsp4s should be an idiomatic scala LSP implementation so it would be weird to rely on exceptions for control flow.

However, the vscode client doesn't seem to report several error codes, but it's possible to accommodate that while keeping the signature unchanged.