langoustine icon indicating copy to clipboard operation
langoustine copied to clipboard

Idea: client API

Open kubukoz opened this issue 2 years ago • 2 comments

Langoustine provides an easy way to build servers, but AFAIK there's no such thing for clients. If you were to implement a language client with Langoustine, what could that look like?

Potential usecases:

  • e2e testing of LSP servers
  • web UI/CLI/TUI LSP client
  • ???

kubukoz avatar May 13 '23 23:05 kubukoz

I'm thinking something along the lines of:

def client[F[_]](endpoints: LSPBuilder[F] => LSPBuilder[F]): Resource[F, Communicate[F]]

That's be at a similar level of abstraction to LangoustineApp. Notably you need a builder because the client still needs to handle some requests/notifications from the server, and these can also talk back to the server via the Communicate passed to each endpoint. At the very end you're left with a Communicate which you can use to call the server at the top level, e.g. with an initialize request or whatever else you wish.

At the moment you can already construct a Communicate from a Channel, so I think the only remaining part is providing the wiring for the users. Maybe even in the same module as app, or - even as LangoustineApp.client.

kubukoz avatar Mar 23 '25 00:03 kubukoz

I'd love to have a client abstraction – at the very least for E2E testing, or for the optional module that allows testing your LSP server directly by launching a mini-embedded LSP client in there with a codemirror editor – or whatever modern web editor has a non-buggy LSP implementation.

def client[F[_]](endpoints: LSPBuilder[F] => LSPBuilder[F]): Resource[F, Communicate[F]]

Something along those lines, yes, but I think we'd need to introduce a narrowed LSPBuilder type (LSPClientBuilder may be) which takes LSPRequest alongside some marker trait for requests/notifications that a LSP client is expected to respond to

keynmol avatar Mar 23 '25 11:03 keynmol