5hirish / quinine

A Flutter IDE by developers for developers (In Development)
https://discord.gg/Yh5Nkrznaw
Apache License 2.0
107 stars 8 forks source link

Core: Dart LSP #9

Open 5hirish opened 1 year ago

5hirish commented 1 year ago

Language Server Protocol (LSP) support is available in the Dart analysis server from version 2.2.0 of the SDK (which was included in version 1.2.1 of Flutter).

This issue outlines the scope of LSP methods to be implemented in the tagged milestone. Full list of LSP methods integrated in the quinine Dart LSP client. dart-lang/sdk (Following implementations subjected to methods implemented at the Dart LSP server)

Method Progress Milestone
initialize M1
initialized M1
shutdown M1
exit M1
$/cancelRequest
$/progress
client/registerCapability ☑️ M2
client/unregisterCapability ☑️ M2
textDocument/definition M3
textDocument/hover M3
textDocument/completion M3
textDocument/publishDiagnostics M3
textDocument/prepareCallHierarchy M3
textDocument/didChange M2
textDocument/didClose M2
textDocument/didOpen M2
window/logMessage M2
window/showMessage M2
workspace/configuration M2
window/workDoneProgress/create ☑️ M2
window/workDoneProgress/cancel ☑️ M2

Milestones

Running the Server

Start the language server using the dart language-server command. Pass the --client-id and --client-version flags to identify your editor/plugin and version:

dart language-server --client-id my-editor.my-plugin --client-version 1.2

Note: In LSP the client makes the first request so there is no obvious confirmation that the server is working correctly until the client sends an initialize request. Unlike standard JSON RPC, LSP requires that headers are sent.

References:

5hirish commented 1 year ago

Confirming compatibility with the existing code-editor : https://github.com/akvelon/flutter-code-editor/issues/240

5hirish commented 1 year ago

On first attempt of workspace selection LSP server initiation doesn't happen. Only after subsequent ones it initiates. https://github.com/5hirish/quinine/blob/c0c1b9d54881823dc00f3dbb5d04afd2851c150e/lib/provider/project.dart#L28-L32

5hirish commented 1 year ago

Came across an issue where the provider was starting two LSP server process. Need a test case to ensure only one process is started.

5hirish commented 1 year ago

Pending M2:

  1. Client should maintain the server's capabilities after it responds to client's initlialize request. The server can signal the following capabilities.. For example, client requires to know the extent of support provided by the server for workspace/executeCommand.
  2. Client should maintain the server's client/registerCapability request in order to enable the various features / capabilities on the client (IDE) side as required. Options necessary for the registration. For example when implementing textDocument/didChange, client needs to register how documents are synced to the server (incremental or full). Hence, it must maintain this request received from the server in order to comply with the server capabilities.
5hirish commented 1 year ago

Dart LPS document syncKind with the server is 2. Meaning documents are synced by sending the full content on open. After that only incremental updates to the document are sent.