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

Is it possible to use the same Server for 2 scripts open in 2 tabs #307

Closed
ArunGanesh88 opened this issue Dec 8, 2021 · 12 comments
Closed

Comments

@ArunGanesh88
Copy link

Based on the example given, each time we open the script in a monaco editor in a browser a new server is started, is there a way to reuse the already started server.

@CGNonofr
Copy link
Collaborator

CGNonofr commented Dec 8, 2021

The language server protocol is stateful, there is a handshake at start, so the protocol wasn't really designed for this, so there is no trivial way.

This being said, you can still implement a kind of "proxy" which play the role of the client to the server, and the role of the server to the client.
It can keep the language server up, and just send the DidOpenTextDocument notif when a client arrives and the DidCloseTextDocument when a client leaves

@CGNonofr
Copy link
Collaborator

CGNonofr commented Dec 8, 2021

Oh I didn't read the title properly!

If you want 2 clients on the same server, I guess it's still possible using the same kind of proxy, you'll just need a "main" client responsible for the file update, and a specific logic for each server notifications/requests

@ArunGanesh88
Copy link
Author

Thanks for the update @CGNonofr . is there any example code for creating the proxy?.

@CGNonofr
Copy link
Collaborator

I'm not aware of any implementation of it but I didn't search much.

Btw I'll probably have this need in the soon future so stay tuned.

@arunganesh-a
Copy link

Hi @CGNonofr is there any update on this?

@CGNonofr
Copy link
Collaborator

CGNonofr commented Feb 9, 2022

I've already implemented a prototype so I can guarantee it's possible

Btw the code is not ready yet to be shared, ask me again in some weeks :)

@CGNonofr
Copy link
Collaborator

I think you can give a try to https://github.com/CodinGame/languageserver-mutualized.

It can do a little more than what you need (it allows multiple clients to edit the same file).

Do not hesitate to provide some feedback

@arunganesh-a
Copy link

Hi @CGNonofr ,

This solves most of the problem. I have one clarification..
Things are working as expected when opening file from same workspace in 2 different editor or browser tabs.. but when we try to open another file form a different workspace language it doesn't work as expected. How to handle this scenario.

Thanks
Arun

@CGNonofr
Copy link
Collaborator

Please open an issue on the other repo and close your issue here, we'll not disturb this repo ;)

@arunganesh-a
Copy link

Actually, in the earlier approach where we open separate server for each browser tab this scenario was working. Now with new approach this is not working

@CGNonofr
Copy link
Collaborator

So you have an issue using the languageserver-mutualized lib right? Why doesn't creating an issue there seem relevant to you?

Btw I need some clarifications on

we try to open another file form a different workspace language it doesn't work as expected

What is a "workspace language"? What doesn't work?

@arunganesh-a
Copy link

arunganesh-a commented Feb 22, 2022

I am using Java Language Server, In this each maven project is a separate workspace.

I have created a new issue in the other repo. We can track this in the new issue

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

3 participants