Open tommitytom opened 1 year ago
Interesting, I will do some research in the few days.
I did some research, unfortunately it was not supported.
It looks like we could have access to local files using the file system API. The web extension article claims we will, at least.
The biggest problem is of course trying to get the server (Lua) to run in the browser. It may be possible to run the server in the browser using Fengari but it would likely be a lot of work for a not-so-great user experience, I would think.
As @carsakiller mentions it is possible to access the file system from the browser, but it's only possible in chromium based browsers right now. You can test this out by going to https://vscode.dev/ and clicking "open folder" to see what the user experience is like. However it is also possible to go direct to a repository, (for example by going to https://github.dev/sumneko/lua-language-server, or you can press .
on any repo or pull request to switch to vscode).
As far as running lua in the browser, that's not too hard at all! Where there is fengari, you can also just compile lua to wasm which runs at near native speed in the browser. It's also pretty simple to do, I use it for some projects. I'm happy to help with this!
Also, I realise I should probably have added this issue to the https://github.com/sumneko/vscode-lua repo, apologies!
You can test this out by going to https://vscode.dev/ and clicking "open folder" to see what the user experience is like
My experience is "Firefox is not supported" 😛
About 80% of browsers use a Chromium browser, but that does leave 20% of people out of luck when it comes to opening folders in their browser 😕. That's assuming that the average user of VS Code is also the average browser user and that user-agent tracking is at all accurate. It is likely that the split is very different in actuality for vscode.dev
as its users are developers and more "techy" people.
That being said, it can certainly be useful for editing a repo (assuming SSH and PGP is still supported) and if it is actually possible and not unreasonably difficult to pull off, it could be a nice touch for the language server to run entirely in the browser 🙂.
It's also worth mentioning that the Monaco editor itself can be embedded on any website, which as far as I'm aware has support for communicating with language servers. Could make for some interesting live coding tools with great intellisense!
In any case, I'll take a look at this if getting the dev env setup isn't too time consuming
Here are the problems that need to be solved:
fengari
only supports Lua 5.3, however this server is using Lua 5.4
coroutine.close
bee.filesystem
: Can implement by file system APIbee.platform
: Do some special treatment for Windowsbee.subprocess
: Get process ID, not important, can be removedbee.filewatch
: Can be replaced by API of LSPbee.time
: Used for timer and logbee.thread
: Create sub-thread. Used for load protocol from stdin, sleep and wakeup main thread per second.fengari
dose not support __gc
fengari
dose not support weak table, important.maybe compile all C++ code to webassembly
I had a look yesterday, and it doesn't make sense to use fengari - the runtime from bee.lua could be compiled direct to WASM negating the need for an external JS lua wrapper. That should remove a few things from the above list.
Wanted to put https://github.com/ceifa/wasmoon on your radar. It's a real Lua 5.4 VM with JS bindings made with webassembly.
Would be very useful for embedding this in Monaco too
Was thinking, can we run this all in WASM? Have a C++/Rust binding which runs the embedded lua VM with WASI and setup filesystem to point to a virtual one?
Or a more realistic approach. We use https://webcontainers.io/ with something like https://github.com/arnoson/monaco-lua-example/tree/main to run everything in a tiny linux WASM env
Looking into this as it would greatly simplify my project as opposed to running a server. I think compiling and running the server to WASM via web workers could get it done.
Wanted to put https://github.com/ceifa/wasmoon on your radar. It's a real Lua 5.4 VM with JS bindings made with webassembly.
Creator of wasmoon here. Let me know if I can help you guys on this.
I tried doing this a while ago and the problems were mostly the native modules/cpp code in the repo. Might need a few advances or to port to WASIX maybe?
Taking a closer look at wasmoon, what would stop us from just running the language server inside of wasmoon?
Edit: I see what you mean now @JSH32. I mistakenly thought this was 100% lua but i see there are some other native modules being used.
Is there any plan to add support for the browser based version of vscode (eg https://vscode.dev)?