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 Language Server Protocol #1287

Closed
26 tasks done
Tracked by #3
svenefftinge opened this issue May 18, 2016 · 57 comments
Closed
26 tasks done
Tracked by #3

Support for Language Server Protocol #1287

svenefftinge opened this issue May 18, 2016 · 57 comments
Labels
kind/epic A long-lived, PM-driven feature request. Must include a checklist of items that must be completed.

Comments

@svenefftinge
Copy link
Contributor

svenefftinge commented May 18, 2016

##The VSCode team has recently published the version 2.0 of their language-server protocol. The goal is to define common API for editors such as VSCode or Che to interact with language services like

We have started using this protocol for communication between Che and Xtext and would like to move the Che part here and collaborate on the development. @evidolob: could you create a branch, against which we can make a PR with the basic projects we have created so far?

Tasks in this Epic includes part 1 of implementation:

Language Server Agents.

LS agents are injected into workspace configuration:
“agents” : [“org.eclipse.che.ls.json”, “org.eclipse.che.ls.csharp”]
LS agents and LS binaries are located at remote storage. For the time being it is Codenvy Update Server. Agents are available by the following urls:
https://codenvy.com/update/repository/public/download/org.eclipse.che.ls.json
https://codenvy.com/update/repository/public/download/org.eclipse.che.ls.csharp
When workspace is created agents are being applied. Basically it means agents script execution over running instance. After that LS can be started on demand when user opens files associated with installed LS.

Bug:

Code Assistant and Code Validation don't work for C# #2509

Initialize process:

  • User opens file with LS support.
  • LS Editor provider calls vs-agent to initialize LS.
  • LanguageRegistryService on vs-agent calls LanguageServerRegistry to find and start LS.
  • LanguageServerRegistry launch LS.
  • When new LS is launched and initialized, LS capabilities passed to IDE.
  • IDE use LS capabilities to create editor and open file.
  • Language Server Protocol: Respect Language Server capabilities on IDE client Language Server Protocol: Respect Language Server capabilities on IDE client #1789

Diagnostics

RI: C#, JSON

  • Shows errors and warnings inside editor.

diagnostics

Completion (IntelliSense)

RI: C#, JSON

  • Intellisense - auto-completion in a context aware setting

Is a context-aware code completion feature in some programming environments that speeds up the process of coding applications by reducing typos and other common mistakes. Attempts to do this are usually done through auto completion popups when typing, querying parameters of functions, query hints related to syntax errors, etc.

completion

Goto Definition

RI: C#

Perform search for symbol definition and allows to navigate.

goto definition

Find References

RI: C#

Search project-wide references for the symbol denoted by the given text

find references

Document Symbols

RI: JSON

Allow to view and navigate document symbols. In most cases it’s can be described as flat outline

document symbols

Workspace Symbols

RI: C#

  • Workspace symbox to list project-wide symbols matching a query string.
    Workspace symbols is the list project-wide symbols matching the query string. It’s allow to navigate not only for file or class name but for method or field.

workspace symbols

Document Formatting

RI: JSON

Format all document.

Document Range Formatting

RI: C#, JSON

Format selected range in document.

document range formatting

Document on Type Formatting

RI: C#

Automatically invoke formatting after special character typed.

document on type formatting

Hover

RI: C#, JSON

The hover shows useful information, such as types of symbols, or, in the case of CSS below, the shape of the HTML that would match a certain CSS rule:

hover

Or for java hover may show javadoc:

hover2

Signature Help

RI: C#

Shows signature information at a given cursor position. For strongly typed programming languages it’s may shows method parameters types:

signature help1

signature help2

@svenefftinge
Copy link
Contributor Author

Also we have defined the interfaces of the protocol in Java. And made it available here : https://github.com/TypeFox/ls-api

@evidolob
Copy link
Contributor

I create branch named "language-server" https://github.com/eclipse/che/tree/language-server

@nadako
Copy link

nadako commented May 19, 2016

Nice, this is exactly what I had in mind when I started developing haxe-languageserver - that not only VSCode can implement and make use of that protocol, but any editor/IDE! Looking forward for it to be implemented in Eclipse, so I could try adding Haxe support for it, using the language server.

@TylerJewell
Copy link

@tolusha @evidolob @gazarenkov @vkuznyetsov - please, can we link in any dependency issues related to agent deployment and end user UX that are related to how a user will add / remove language servers within a workspace? without seeing the full end user workflow issues that we need to handle, it will be hard to understand what the real definition of done is here.

@tolusha
Copy link
Contributor

tolusha commented Aug 10, 2016

#1823

@kaloyan-raev
Copy link
Contributor

I want to prototype a PHP IntelliSense support in Che. I want to take advantage of the Crane language server, which provides the PHP IntelliSense in VSCode: https://github.com/HvyIndustries/crane

As far as I understand, the support for the language server protocol in Che is currently a work in progress and it is not available in the master branch yet.

Could you tell me how to setup my dev environment, so I can start experimenting?

@TylerJewell
Copy link

@evidolob @tolusha @vparfonov - FYI - can we document some setup tasks for the community to test our work as we go along?

@kaloyan-raev
Copy link
Contributor

I was able to build the branch from the root pom.xml after deleting a couple of test files that were causing compilation errors.

Now I am exploring how the C# support is implemented. I have a Java workspace in my local Che. I created a new C# file. If I open it in the editor, I get an "Initializing Language Server for cs" progress message and the IDE freezes.

It looks like the C# language server cannot be started. Any hints how to troubleshoot?

@kaloyan-raev
Copy link
Contributor

Same story with the JSON language server. There the code for launching the server is simpler and I found that the /home/user/che-agents/ls-json/launch.sh script is missing. I guess this is related to #2032 and these launch.sh are not available yet...

@tolusha
Copy link
Contributor

tolusha commented Aug 11, 2016

@TylerJewell
What setup tasks do you mean? Everything is in branch, except @evidolob code part.

@kaloyan-raev
I am checking...

@tolusha
Copy link
Contributor

tolusha commented Aug 11, 2016

@kaloyan-raev
I've just fixed agents. No need to pull changes.
json ls requires only a few seconds to be initialized, but c# requires several minutes.
c# ls works properly if you have project.json file in your project.

I tested everything on codenvy/debian_jdk8 container

@kaloyan-raev
Copy link
Contributor

@tolusha Thanks for the magic you have done! I created new project and the Json language server now starts (I would say immediately).

How do I check if the language server works correctly? I don't see any meaningful code assist, and it's hard for me to imagine any for a generic json file.

Does the validation come from the language server too?

@tolusha
Copy link
Contributor

tolusha commented Aug 11, 2016

@kaloyan-raev
To use code assist just add any json scheme into your file and press Ctrl+Space
For instance:
{
"$schema": "http://json-schema.org/draft-04/schema#"
}

@kaloyan-raev
Copy link
Contributor

@tolusha Thanks! This works.

I noticed a few issue with the code assist. Perhaps, you already know them:

  • The list of proposals is not sorted.
  • The list of proposal is not filtered. Regardless the input I type, the proposals list always contains all available proposals and always the first one is selected.
  • There is some {{}}} garbage inserted when applying the code assist.

There is also a concept issue with the json editor. I've never seen $schema to be declared for popular json files like bower.json and composer.json. Yet users would expect code assist and validation to work for such files. Is there a way for Che to tell the json language server what schema to use, if there is no $schema declared in the file?

@tolusha
Copy link
Contributor

tolusha commented Aug 12, 2016

@kaloyan-raev
Thx.
We aware of them.

@gazarenkov
Copy link
Contributor

Splitted epic moving its second part to #2109 including:

Language Server Protocol: ShowMessage Notification feature #1793
Language Server Protocol: ShowMessage Request feature #1794
Language Server Protocol: Telemetry Notification #1796
Language Server Protocol: DidChangeConfiguration Notification feature #1798
Language Server Protocol: DidChangeWatchedFiles Notification #1799
Language Server Protocol: Document Highlights #1802
Language Server Protocol: Rename feature #1806
Language Server Protocol: Push notification to client on new language server #1427
Language Server Protocol: Ensure order of Events #1426

@TylerJewell
Copy link

@slemeur - on the "Document Symbols" - can you please take a look at the UX for the highlight of the typed characters. It is currently a weird yellow box and ends up appearing unnecessarily heavy to the end users. Please identify an improvement here that we can apply.

kaloyan-raev added a commit to kaloyan-raev/che that referenced this issue Aug 31, 2016
Registers a language server for the PHP editor.

Signed-off-by: Kaloyan Raev <[email protected]>
@kaloyan-raev
Copy link
Contributor

After I've done some refactoring on the Crane language server (HvyIndustries/crane#143), I am now able to run it in Che and get code completion inside the PHP editor.

I prepared PR #2282 with the changes. Please, review and merge it to the language-server branch.

The PR also contains attachments with the agent that must be uploaded to the Codenvy Update Server.

@kaloyan-raev
Copy link
Contributor

BTW, there is a new PHP language server started a few days ago: https://github.com/felixfbecker/php-language-server.

It is implemented in pure PHP. My next goal is to try it out with Che.

Is it be possible to have more than one language servers for the same editor at the same time?

For the moment, the two language server available for PHP does overlap in features, but complement each other. So, it would make sense to have them both available.

@TylerJewell
Copy link

Very interesting work! I do not believe it will be possible - for now - to have more than one language server activated for a source file of a particular type / extension. I do not see us working to try and provide support for multiple LS at the same time for a single file. I think we would require users to register / unregister one before activating another. This would be the common scenario, I would expect.

Also - we will be publishing docs later this week or next week around how to author agents, which are ways to package up language servers into hot-deployable services within a workspace. This will be a nice packaging. We haven't done our own language servers this way but need to.

@StevenDoesStuffs
Copy link

StevenDoesStuffs commented Sep 11, 2016

@vparfonov
Copy link
Contributor

vparfonov commented Sep 12, 2016

Move:

to the Support for Language Server Protocol - part 2

@TylerJewell
Copy link

@vazexqi - you asked about delivery timeframes - this looks like it will be completed for M2 or M3 of the 5.0.0 release train, which is very near term, likely this month.

@felixfbecker
Copy link

Could you add https://github.com/felixfbecker/php-language-server to the list?

@StevenDoesStuffs
Copy link

StevenDoesStuffs commented Sep 17, 2016

@TylerJewell Any updates on the typescript lang server? Or are we out of luck?

https://github.com/Microsoft/TypeScript/blob/master/src/server/server.ts
https://github.com/Microsoft/TypeScript/tree/master/src/server
Is that of any significance?

@TylerJewell
Copy link

@StevenTheEVILZ - we will have to wait and see what Microsoft chooses to do with it. We'll package language servers as they become available.

@StevenDoesStuffs
Copy link

StevenDoesStuffs commented Sep 17, 2016

@TylerJewell I;m probably missing something, but isn't that licensed under Apache 2.0 like the rest of the typescript package? And also, I'm not even sure if that is a language server; I don't see it using anything from languageserver-node.

@TylerJewell
Copy link

Our understanding is that Microsoft has a language server for typescript, but has not chosen to release it yet. It's only for vscode right now. This is the list of language servers that have been published. Not all are open source. https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations

@StevenDoesStuffs
Copy link

I see. TY

@StevenDoesStuffs
Copy link

@TylerJewell Sorry to bother you again, but then what is the thing I sent you?

@TylerJewell
Copy link

I don't know - we are not following what is happening in the typescript libraries. Microsoft will let us know if they add more language servers in the open source realm. We'll also publish the ones that we include soon, too. Unless, of course, you wanted to adapt Typescript into a language server for others to use?

@StevenDoesStuffs
Copy link

@TylerJewell Yeah, I was thinking about writing a typescript lang server. I just wanted to make sure that there isn't already one ready to be implemented.

@TylerJewell
Copy link

I'd get in touch with Microsoft on their forums and ask about their progress. If they are planning something, you would want to know about it before doing the work.

@StevenDoesStuffs
Copy link

K. TY

@tolusha
Copy link
Contributor

tolusha commented Sep 20, 2016

@felixfbecker
When we have API and UI to inject ls agents into a machine, the php ls will be among them.
Or are you talking about a bit different list?

@felixfbecker
Copy link

Just referring to the list in the issue

@StevenDoesStuffs
Copy link

@felixfbecker @TylerJewell I think che is already using crane as its php ls:
#2282

@kaloyan-raev
Copy link
Contributor

@StevenTheEVILZ This is true. I submitted #2282 with the Crane server. That day it was more or less the only available PHP language server.

Since then we have also https://github.com/felixfbecker/php-language-server on the scene. It shows faster progress than Crane so far. Also it is written in pure PHP, which has a greater potential to attract the PHP community for contributions and to reuse existing PHP tools.

I believe very soon we should replace Crane with https://github.com/felixfbecker/php-language-server.

@felixfbecker
Copy link

I also use the existing https://github.com/nikic/PHP-Parser for parsing instead of rolling my own, imo this is a much more solid foundation. I also care about as-high-as-possible test coverage.

@TylerJewell
Copy link

This is a first cut of the documentation that we need to write around language servers. These are my notes from a 90 minute demo / review with the language server team this morning.

A language server has two phases of management within Che: installation and initialization. The installation is about how the language server gets installed into the stack, so that it is present for Che to turn on or off. The initialization process is the launching of the language server so that it is a running process within the workspace, and that the editor can connect to it.

The installation of a language server must happen within the definition of a workspace, or as part of a stack. Language servers are packaged within "agents" which are scripts that install the langauge server and its dependencies into a workspace. The agent installation can happen either as part of a stack (when the workspace is first started), or dynamically when a file of an associated type is first opened in the editor. It's recommended, for performance, to always include the associated agent within a workspace / stack definition.

Shortly, we will be providing a GUI within the dashboard that lets users add / remove agents to a workspace or a stack. This will also be part of the stack editing process. Stacks can choose from various agents that they want included.

There can be different types of agents added into the system other than language servers. For example, we have an SSH and terminal agent, which provide the services you expect the workspace to have.

Currently, all agents must be pre-defined within Che and saved in this location as part of the Che repository. We are thinking about a public registry for agents where they can be added and removed, but this is a future activity.

Each agent is saved as a JSON file. The name of the file without the extension is the ID for the agent within the agents list used by the dashboard or other products. So the CSharp agent is identified as "org.eclipse.che.csharp". Inside of workspaces and stacks, there is a new data object called agents : [] which is an array of agents that are to be included. The array would list the identifiers of each agent to include.

Agents have a name, a set of other agents that they depend upon, properties and a "script", which defines how the agent's package is to be installed into the workspace. This is not the startup of the agent, but just the installation. The script section of the agent is difficult to read, but we also include the same scripts in this scripts directory and our CI systems convert those scripts to embed them inline within your agent during the packaging phase.

The scripts that you must provide with an agent have a large if block where you provide installation logic for each Linux distribution that we support. You can follow our templates for how to build agents of your own.

Once a language server is included in the workspace as an agent, then there needs to be a launcher that controls when the language server is started and stopped. Technically, agents can be start / stopped for any number of reasons. For language servers, those agents will be typically start / stopped when the editor opens a file of a certain extension or when a plugin of a certain type is created. Right now, launchers need to be authored as Che extensions that are packaged with Che itself. We will also look to make these dynamic in the future.

Write a launcher extension
Add the launcher as a module

Once you have added this extension, you can test your Che by just rebuilding the plugin-language server module and also rebuilding the core assembly.

@kaloyan-raev
Copy link
Contributor

@TylerJewell This was very helpful. Thanks for taking the time to write it down!

@kaloyan-raev
Copy link
Contributor

@TylerJewell It would be helpful to have a wiki page that lists all supported Linux distros and versions, and a minimal Che stack for each of them. This will help testing the LS agent installation and initialization.

@mickaelistria
Copy link

I reported microsoft/language-server-protocol#76 about setting up a public registry/marketplace of language servers that all clients could use.

@vazexqi about Che and eclipse-language-server, there isn't going to be much room for collaboration on the UI parts as the UI stacks are quite different. However, there is already collaboration on the common parts such as the protocol itself and the LSP4J api. The good way to move forward if you're interested in LSP is to contribute to both ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/epic A long-lived, PM-driven feature request. Must include a checklist of items that must be completed.
Projects
None yet
Development

No branches or pull requests