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

Support for Multiple LSP Languages Servers per File #4609

Closed
tsmaeder opened this issue Mar 29, 2017 · 4 comments
Closed

Support for Multiple LSP Languages Servers per File #4609

tsmaeder opened this issue Mar 29, 2017 · 4 comments
Assignees
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Milestone

Comments

@tsmaeder
Copy link
Contributor

Currently, LSP support assumes that only a single language server can be active for any given file. However, this is makes it impossible to do add-on language servers. For an example, think of a linting plugin for typescript for example. Even if the main language server plugin has no support for a particular linting tool, we could make the linting tool contribute diagnostics and code actions to show/fix warnings from the linter.
Visual Studio Code, for example, supports this (so it IS possible) and describes a set of rules on how to handle the cases where multiple language servers are claiming responsibility for a file, see https://code.visualstudio.com/docs/extensionAPI/vscode-api#_languages.

@ghost ghost added the kind/enhancement A feature request - must adhere to the feature request template. label Mar 29, 2017
@tsmaeder
Copy link
Contributor Author

I have made a timeboxed proof of concept implementation and which is based on the following main concepts:

  1. Languages and LanguageServers are separated. Languages are configured per file extension and determine the language id for a
  2. A language server registers a description that can match a combination of file paths (via a regular expression) or language ids (determined by matching a language description). When multiple language servers are selected for a given file, they are asked for results (and the results merged) via a set of rules based on a match score (see https://code.visualstudio.com/docs/extensionAPI/vscode-api#_)
  3. The selection of language servers to ask for a particular request and the merging of the result is done in the workspace agent. No IDE plugins are required to add a new language server.
  4. Language servers are started lazily and asynchronously. Each service call uses the currently available language servers for processing. Since we may start multiple language servers when opening a file, waiting for the startup becomes less attractive. Server capabilities for a file are determined using the servers currently online. (see also Initialization Language Server loader should be non-blocking and allow user to edit the file while it is processing #2525). Servers are always initialized with the projects directory as the root. Currently, servers are started per project, but I don't think that makes sense, for example for Java workspaces. If a language server cannot handle multiple projects, that failure must be handled inside the server-specific workspace agent plugin.

I have dumped the code here: https://github.com/tsmaeder/che/tree/multiple_language_servers. I would call the state of the code "barely working". I think it can show that the concept will work, but due to bugs and incompleteness, you can only just do a demo with it.
I think with another 2 weeks of work, I could make this into a working PR.

@tsmaeder
Copy link
Contributor Author

For reference, the investigation was originally done here: https://issues.jboss.org/browse/CHE-173

@tsmaeder
Copy link
Contributor Author

Pictures, or it didn't happen: https://www.youtube.com/watch?v=tNQ3-M2_KVA&feature=youtu.be

@tsmaeder
Copy link
Contributor Author

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

No branches or pull requests

2 participants