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

Investigate LSP #507

Closed
DanTup opened this issue Jan 27, 2018 · 4 comments
Closed

Investigate LSP #507

DanTup opened this issue Jan 27, 2018 · 4 comments

Comments

@DanTup
Copy link
Member

DanTup commented Jan 27, 2018

Currently Dart Code contains a lot of code that maps from the analysis server API into the VS Code API. Since VS Code's APIs are specific to Code, this code is very specific and not re-usable. If we pushed this code into an LSP implementation then it could be shared by other editors that implement LSP (for example, Visual Studio has preview support for it).

Consuming LSP

VS Code

To consume LSP in VS Code you create an extension as normal and then use the vscode-languageclient package to create an adapter for VS Code to use to communicate with your server. The client can spawn the process or be provided with a function that returns a process or a set or input/output streams (see here).

For Dart Code, we would need to be able to communicate with the server for custom requests additional to what the LSP supports which can be done with custom messages.

Visual Studio

Note: "The Visual Studio LSP extension can only be installed on the preview channel of Visual Studio. You should not use the preview for production purposes."

To consume LSP in Visual Studio you would create an extension as normal (which currently has the LSP preview extension as a dependency) and then use the Microsoft.VisualStudio.LanguageServer.Client NuGet package to create an adapter for Visual Studio to communicate with your server.

Implementation

Based on the above, there would need to be a small amount of TypeScript to get VS Code (and a small amount of C# if doing the same in Visual Studio) to connect to an LSP implementation. This code is relatively minor and is just to spawn the server and hand off to the IDE. The IDEs should themselves advertise their capabilities to the server and communicate directly.

There are a number of possible ways to do this:

  1. Ship LSP protocol inside the analysis server in the SDK
    This would mean putting SDK-detection logic into the extension(s) rather than the LSP server and being tied to SDK release schedules
  2. Write the LSP server as a proxy that spawns the analysis server and communicates over STDIO
    This means we're adding an addition process in the middle, but we're still talking to the analysis server in the same way that we do today (doing it this way, the server could be written in another technology if we so wished - Dart seems like a good candidate but we'll need to code-gen protocol APIs from the spec)
  3. Ship the analysis server inside the extension(s) and host it directly inside the LSP server
    This eliminates the extra process but bloats the distribution and ties people to a specific SDK version
  4. Don't ship the analysis server in the extension(s) but load it from the SDK directly in-process
    I don't know if this would work - can you dynamically load modules from unknown paths?
    We'd need to ensure the API we use for creating the server in-process here is stable since the version at runtime could be newer than we had when we shipped the LSP server inside the extension(s)

Related Links

VS Code

Visual Studio

@DanTup DanTup modified the milestones: v2.8.0, v3.0.0 Jan 30, 2018
@DanTup DanTup modified the milestones: v3.0.0, On Deck Feb 21, 2018
@DanTup DanTup modified the milestones: On Deck, v2.12.0 Mar 27, 2018
@DanTup DanTup changed the title Adopt LSP Investigate LSP Mar 27, 2018
@DanTup DanTup modified the milestones: v2.12.0, On Deck Apr 16, 2018
@DanTup DanTup modified the milestones: On Deck, v2.13.0 Apr 25, 2018
@DanTup DanTup modified the milestones: v2.13.0, v2.14.0 May 15, 2018
@vogella
Copy link

vogella commented May 23, 2018

Also, other IDEs as Atom or Eclipse support the LSP.

If you would offer standard LSP support my team could try to integrate Flutter into the Eclipse IDE. I believe diverse tool support would be very beneficial for the adaption of Flutter.

@rcjsuen
Copy link

rcjsuen commented May 23, 2018

By the way, there is a natebosch/dart_language_server repository on GitHub maintained by @natebosch. It seems reasonably active.

@DanTup
Copy link
Member Author

DanTup commented May 23, 2018

@rcjsuen Yeah, that's what I've been using for my experiments (I've sent some PRs this week) :-)

@DanTup DanTup modified the milestones: v2.14.0, v2.15.0 Jun 7, 2018
@DanTup DanTup modified the milestones: v2.15.0, On Deck Jun 21, 2018
@DanTup
Copy link
Member Author

DanTup commented Jan 22, 2019

Investigation has been done, and I've started on adding LSP to the Dart analysis server. Progress is tracked here:

https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md

I don't think we need this issue any more. The VS Code plugin may move to the LSP protocol in the future once it supports everything we need (either through official requests or custom requests) to avoid spinning up two copies of the server.

@DanTup DanTup closed this as completed Jan 22, 2019
@DanTup DanTup removed this from the On Deck milestone Jan 22, 2019
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