eclipse / lsp4e

Language Server Protocol support in Eclipse IDE
Eclipse Public License 2.0
65 stars 54 forks source link

Run LS in container #813

Closed ghentschke closed 11 months ago

ghentschke commented 1 year ago

I am not sure if it's already possible to run a language server in a docker or podman container? If not, I think this would be a nice feature.

bastiandoetsch commented 11 months ago

Just an idea: Isn't that already possible if you just specify a script as language server that launches a container?

mickaelistria commented 11 months ago

Whether the LS runs in a container or in a in a regular process or a thread or whatever doesn't matter as long as we can bind to an input and output stream. And after all, starting a container is more or less the same thing as starting one (bg parent) process. I can't find the current link, but in some ~5 years old article published somewhere at Eclipse.org, I demoed how LSP4E could consume a language server for OCaml that was embedded in a container, just by running the docker command with the right options. I demoed how to define and bind the language server from preferences, using the "External program" launch calling docker and later I demoed how instead of the "External Program" launch, one could use a Docker Tools launch configuration type, and also how to code the (Process)StreamProvider that was also running this command. So overall, I think all that has long been already possible. Maybe it could be made a bit simpler, but I also don't see LSP4E requiring Docker Tools out of the box to facilitate this particular use case just by providing one ContainerStreamProvider that would just launch docker. Moreover, the tricky part is not really starting the container, but starting it with the right options (eg mounted directories, port forwarding...), and connecting to the right streams (is it stdio, or some regular tcp, or some websockets; is the transport encrypted in some way that the client need to know about...?), and this very quickly becomes very specific to the container/LS.