Code Monkey home page Code Monkey logo

Comments (10)

hjr265 avatar hjr265 commented on June 4, 2024 2

@haeck98 Sure, thank you.

from codemirror-languageserver.

hjr265 avatar hjr265 commented on June 4, 2024 1

@haeck98 In the meantime I have added preliminary support for reusing the LSP client across multiple plugin instances.

from codemirror-languageserver.

haeck98 avatar haeck98 commented on June 4, 2024

As I understand this is not yet supported. I had a quick look into the source code and had the following idea:

Maybe the languageServer() function could accept an optional client instance, which it uses to send further requests. This way it would be possible to create a client instance beforehand and share it between multiple Editors. By creating the client instance it sends the 'initialize'-Request and the LanguageServerPlugin then just sends the 'textDocument/didOpen'-Request via the client it receives. If you do not set a client instance for languageServer() call, it just creates a new one, like it is already doing right now.

Would You be open to integrate this feature into the library? Since I need this functionality, I'm willing to contribute to this project and implement the feature I described above.

@hjr265

from codemirror-languageserver.

hjr265 avatar hjr265 commented on June 4, 2024

@haeck98 Is this something the Language Server Protocol even supports?

Sorry if I am missing something obvious.

If we are going to allow a client to be passed to the plugin's constructor, we will also have to do the same for transport. Since it is used here:

this.transport.connection.addEventListener('message', (message) => {

from codemirror-languageserver.

haeck98 avatar haeck98 commented on June 4, 2024

Hi thanks for your response @hjr265 !

"The protocol currently assumes that one server serves one tool."

As far as I understand, this only refers to the number of connections between a client and a server. One Server can only serve one client. BUT one client can get notifications and send requests for multiple open files. For example consider the following order of notifications and requests a single LSP Client can send to the server:

  1. request "initialize"
  2. notify "textDocument/didOpen" for ./src/file1.ts
  3. notify "textDocument/didOpen" for ./src/file2.ts
  4. notify "textDocument/didOpen" for ./src/file3.ts

Now the client can retrieve information for these three files, e.g. diagnostics, completions, hover, etc..

Knowing this, I propose to strictly separate the LSP client from the LanguageServerPlugin.

I actually started implementing my own library for LSP support in CodeMirror 6, since I actually needed some other features, which are also not implemented here. However, if you are interested I can explain how I managed to share one LSP Client with multiple CodeMirror Editors. But since I already implemented it in my own library, feel free to close the issue.

from codemirror-languageserver.

haeck98 avatar haeck98 commented on June 4, 2024

microsoft/language-server-protocol#23

As far as I undestand, this is issue is about connecting multiple clients to a single language server instance, e.g. opening multiple web socket connections to a server which all communicate with one single language server process. This is not possible. However, what I requested was the possiblity to open a single websocket connection and share this single connections between multiple open CodeMirror Editors in a website. The current implementation will open a web socket connection for every open editor in a website and therefor, since one language server can only server one client, requires a separate language server process for every editor in a website.

from codemirror-languageserver.

hjr265 avatar hjr265 commented on June 4, 2024

@haeck98 I see what you mean.

Yeah, this is a current limitation of this implementation.

I will eventually have to add support for this as well once I start dealing with multiple co-existing CodeMirror instances at the same time in my project.

from codemirror-languageserver.

haeck98 avatar haeck98 commented on June 4, 2024

@hjr265 When my implementation is in a stable state, I will make it publicly available and also publish to npm. If you want, I can share the repository in here, when it is public.

from codemirror-languageserver.

panchaoco avatar panchaoco commented on June 4, 2024

Hello, may I ask this package has been released?

from codemirror-languageserver.

hjr265 avatar hjr265 commented on June 4, 2024

@panchaoco Do you mean with the support for reusing LSP clients? Yes.

https://www.npmjs.com/package/codemirror-languageserver

from codemirror-languageserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.