stackblitz / core

Online IDE powered by Visual Studio Code ⚡️
https://stackblitz.com
MIT License
10.22k stars 885 forks source link

Feature request: support additional language servers #336

Open rictic opened 6 years ago

rictic commented 6 years ago

VSCode/Monaco supports extension through the Language Server Protocol.

It would be really awesome to be able to enhance the editing experience for a project or an embed by adding additional language servers. For example, the Polymer team maintains a language server that provides enhanced linting and autocompletion for custom elements, HTML templates, and some Polymer-specific features. It probably doesn't make sense to run this server for all users, but it would be really great to be able to run it.

The natural way to run a language server in the browser is in its own web worker. The API could be as simple as the user specifying a set of urls of their web workers' sources. The worker/host could then communicate entirely with the language server protocol over postMessage.

JosefJezek commented 6 years ago

Please @EricSimons

We have Polymer IDE extension https://marketplace.visualstudio.com/items?itemName=polymer.polymer-ide

EricSimons commented 6 years ago

@rictic @JosefJezek I love this idea. We actually just implemented the Angular language service on stackblitz; we'd love to also have support for all the other ones out there. Would either of you be able help create a proof of concept for this? Our eng timeline is completely packed for the next 2-3 months, so external help sorting out the implementation details/challenges would be 💯

JosefJezek commented 6 years ago

@rictic @EricSimons I found a module for Monaco...

And Theia IDE is nice base...

rictic commented 6 years ago

@EricSimons I'd be interested, what would you be looking for out of a proof of concept?

Here's a Monaco editor running the Polymer team's language server via an in-browser web worker.

The integration is a little sloppy there, when I set that up monaco-languageclient seemed pretty limited so I use a simple wrapper to translate the LS protocol to something that's closer to the monaco API. It seems like stackblitz might be using more of vscode than just monaco though? I poked around a bit but I couldn't find the source for the editor anywhere.

If you've got other language services working it seems like the major design considerations are taken care of (e.g. URL scheme, document model, persistence, etc).

A few questions for ya'll: Do you run the language servers on the client or the server? What were the sorts of issues you needed to resolve and modifications you needed to make for the typescript and angular language servers?

rictic commented 6 years ago

Summary from chatting on discord:

I'll poke around at that, probably this weekend!

akosyakov commented 6 years ago

@rictic Can you run arbitrary language servers in web workers? Language servers assume that they have access to the filesystem and can run local tools. APIs available to web workers are very limited, mostly they can do async requests as far as i know.