lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Need help with running lua lsp in a docker container

Open ankushKun opened this issue 1 year ago • 9 comments

Hi, this is what I am trying to do:

  • I have a web editor made with react and monaco editor
  • The editor is for writing lua code
  • I want lua lsp autocompletions in the web editor
  • I am trying to run the lua-language-server in a docker container which I hope to later run on a VPS and make the editor frontend connect to this remote lsp server to provide autocompletions

Setup:

  • I used the homebrew docker image to install lua-language-server https://hub.docker.com/r/homebrew/brew

Issue faced:

When I run just the lua-language-server command, it seems to be running, but when I specify a socket, it does not start and gives a connection refused error.

image

image

moreover when I install the lsp on my mac machine and run the same command, it doesnot throw and error and seems to run silently

image

If anyone needs any additional details please let me know

Dockerfile:

# Use the official Homebrew Docker image as the base
FROM homebrew/brew:latest

# Install lua-language-server
RUN brew install lua-language-server

# Verify installation
RUN lua-language-server --version

# Set working directory
WORKDIR /workspace

# ENTRYPOINT ["lua-language-server --socket=5000"]

# CMD ["lua-language-server", "--socket=5000"]

EXPOSE 5000

CMD ["bash"]

tried both ENTRYPOINT and CMD, same results, which is why I used bash and interactive mode to debug

Thanks

ankushKun avatar Jun 19 '24 05:06 ankushKun

Even if it is connected through a socket, luals must be in the same place as the runtime environment., because if the language server and the target workspace are not on the same machine, the language server cannot correctly load the workspace. LSP does not specify how to send workspace content to the LS, so general language server load the workspace by scanning the rootPath path passed in by LSP client. Currently, to truly support WebIDE, LuaLs must be compiled into wasm. There are no plans or progress in this regard at the moment.

CppCXY avatar Jun 19 '24 05:06 CppCXY

I see.

Currently, to truly support WebIDE, LuaLs must be compiled into wasm

Could you point me to any resources regarding this? if any

ankushKun avatar Jun 19 '24 06:06 ankushKun

Could you point me to any resources regarding this? if any

discuss in https://github.com/LuaLS/lua-language-server/issues/1689

CppCXY avatar Jun 19 '24 06:06 CppCXY

Did you make any progress on this? I'm also looking to integrate with monaco client <---> server kind of setup

We have a monaco editor running on the client's machine in SaaS setup and we need reasonable code completion for our custom library.

Seems like https://luals.github.io/wiki/definition-files/ would be the way to go but there is no clear way to set this up remotely on docker 🤔 Any advice would be appreciated.

d-baranowski avatar Sep 11 '24 10:09 d-baranowski

Did you make any progress on this? I'm also looking to integrate with monaco client <---> server kind of setup

We have a monaco editor running on the client's machine in SaaS setup and we need reasonable code completion for our custom library.

Seems like https://luals.github.io/wiki/definition-files/ would be the way to go but there is no clear way to set this up remotely on docker 🤔 Any advice would be appreciated. Perhaps I could talk to my boss to hire someone as a consultant on the subject.

Luals does not actually support communication via sockets. It appears to use sockets, but in reality, it uses Unix sockets.

CppCXY avatar Sep 11 '24 11:09 CppCXY

There are a couple examples online https://github.com/arnoson/monaco-lua-example/tree/main they wrap the lls with a simple typescript websockets server. I'm trying that in docker. So far so good. Will keep updating in here. Here is clone of the example code: https://github.com/d-baranowski/monaco-lua-language-server-example

d-baranowski avatar Sep 12 '24 08:09 d-baranowski

Even if it is connected through a socket, luals must be in the same place as the runtime environment., because if the language server and the target workspace are not on the same machine, the language server cannot correctly load the workspace. LSP does not specify how to send workspace content to the LS, so general language server load the workspace by scanning the rootPath path passed in by LSP client. Currently, to truly support WebIDE, LuaLs must be compiled into wasm. There are no plans or progress in this regard at the moment.

I wonder if we could bundle the correct workspaces inside the docker container to kind of dodge the issue. We only have a couple single file editors for simple scripting. No need for multi file proper editor in our use case.

d-baranowski avatar Sep 12 '24 08:09 d-baranowski

We've managed to get it to work in Docker with monaco being hosted as part of our webapp with lua-ls making it work via websockets. So it seems to be possible. We've tried multiple users talking to the same language server. As long as the node wrapper spawns a new LS process for each socket connection it works like a charm

d-baranowski avatar Sep 20 '24 07:09 d-baranowski

perhaps you can directly modify this project to achieve your goal. https://github.com/LuaLS/lua-language-server-rust

CppCXY avatar Sep 20 '24 07:09 CppCXY