Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: build a wasm gopls to allow auto completion in browser #25

Open
Zxilly opened this issue Sep 24, 2024 · 4 comments
Open

Comments

@Zxilly
Copy link

Zxilly commented Sep 24, 2024

Right now playground uses codemirror, I think it would be simpler to switch to monaco implementation.

@aykevl
Copy link
Member

aykevl commented Sep 24, 2024

gopls in the browser would indeed be really nice to have!

There are a few things that make this difficult:

  • Right now it can't be compiled with TinyGo. This might be fixable, but will take a while. Compiling with "big Go" is possible, but results in a large binary of 45MB (10MB compressed).
  • For gopls to work, it needs access to the packages it imports. That means these packages also need to be shipped to the client (or at least their type information). This could probably be done on-demand but would still result in a decent amount of data over the wire.
  • gopls assumes it's running on an OS, I think (but I'm not sure) it runs go list internally. So that's something that needs to be worked around.

Right now playground uses codemirror, I think it would be simpler to switch to monaco implementation.

Actually, no. I specifically choose CodeMirror 6 over Monaco. CodeMirror 6 is very flexible, small, and because it uses native browser APIs it works everywhere. And it supports autocomplete. Monaco doesn't support mobile browsers, is big and from what I've read difficult to configure/modify. Switching to Monaco would mean dropping mobile support, which I'm not willing to do.

@Zxilly
Copy link
Author

Zxilly commented Sep 24, 2024

"Monaco doesn't support mobile browsers"

I think it works on mobile, but due to the WebWorkers, the bundler may need additional setup.

@aykevl
Copy link
Member

aykevl commented Sep 24, 2024

I tried it. Inserting text and backspace work, but selecting text does not. Also, when you focus the editor in Chrome it zooms in much further than useful/practical. These things all work correctly in CodeMirror 6.

This is where I tried it:
https://microsoft.github.io/monaco-editor/

Also, that page literally says:

The Monaco editor is not supported in mobile browsers or mobile web frameworks.

In any case, this is besides the point. The feature request is about gopls autocompletion, not about the editor. If there are any features in the editor missing feel free to file a bug report, but autocomplete is supported in CodeMirror 6 (just not wired up yet in the playground).

@Zxilly
Copy link
Author

Zxilly commented Sep 24, 2024

I think I need to start with some exec proposals for wasm port of Golang, there are these APIs we need in wasi 0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants