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

How would you configure this if you don't have a server? #20

Open
NullVoxPopuli opened this issue Jul 10, 2022 · 7 comments
Open

How would you configure this if you don't have a server? #20

NullVoxPopuli opened this issue Jul 10, 2022 · 7 comments

Comments

@NullVoxPopuli
Copy link

I primarily work on backendless apps, and would not be able to host anything anywhere (other than static assets via CDN).

ideally, I'd like to import / bundle language servers with the codemirror bundle I'm building so I don't even need to worry about providing public asset path mapping (I totally understand this adds a lot to initial load time).

Is this possible today? Maybe via WebWorkers?

@notpushkin
Copy link

notpushkin commented Nov 13, 2022

Web Workers would be a feasible solution here I think. IIRC you'd still have to have a separate JS file for the worker itself, so no huge bundles for you :^)

For this to work, we'll want to add a Web Workers transport to @open-rpc/client-js (there's similar Window and IFrame transports there), then make sure it works if we pass it to the LanguageServerClient. I might look into that if I have time, but no promises here.

@notpushkin
Copy link

notpushkin commented Jan 2, 2023

Demo: https://codemirror-worker-lsp.ale.sh/
Source: https://gitlab.com/aedge/codemirror-web-workers-lsp-demo

The interesting bits are _transport.ts (the PostMessageWorkerTransport implementation) and _jsonWorker.ts (a JSON language server connected to Web Worker messaging). After defining those you can just call languageServerWithTransport in place of languageServer:

import { languageServerWithTransport } from 'codemirror-languageserver';
const ls = languageServerWithTransport({
	transport: new PostMessageWorkerTransport(new Worker(...)),
	rootUri: "file:///",
	workspaceFolders: null,
	documentUri: `file:///tsconfig.json`,
	languageId: "json",
});

EditorState.create({ extensions: [ ... ls ... ] })

@hjr265
Copy link
Member

hjr265 commented Jan 2, 2023

@notpushkin Thanks for sharing this. Can I borrow your comment and add it as an example to this project's README.md?

@notpushkin
Copy link

@hjr265 Sure!

Maybe it would be better to merge PostMessageWorkerTransport into @open-rpc/client-js first though, so that people don't end up copying it in every project? I was thinking about sending a PR later this week.

@hjr265
Copy link
Member

hjr265 commented Jan 3, 2023

@notpushkin That makes sense. I will wait for your signal then.

@hjr265 hjr265 pinned this issue Mar 14, 2023
@DvvCz
Copy link

DvvCz commented Aug 23, 2023

Status on the PostMessageWorkerTransport merging?

Would love to use this

@notpushkin
Copy link

Unfortunately I had to deprioritize this. Sorry!

If anybody else wants to send a PR to @open-rpc/client-js, feel free to use my code.

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

4 participants