async lsp client
The client used to connect to the LSP server.
It starts a new process as the LSP server and uses the standard input and output as a channel, connects and controls to send requests, responses, and notifications, and receives requests or notifications from the LSP server.
Based on tower-lsp
, we have designed a series of concise APIs for accessing the LSP server. At the same time, it supports request cancellation for tower-lsp
.
Usage
Create a lsp server
let = new;
Lifecycle Message
// initialize request
let initializeResult = server.initialize.await;
// initialized notification
server.initialized;
// shutdown request
server.shutdown;
// exit notification
server.exit;
Document Synchronization
// DidOpenTextDocument
server..await;
// DidChangeTextDocument
server..await;
// DidCloseTextDocument
server..await;
// other
Language Features
// hover
server..await;
// completion
server..await;
// goto definition
server..await;
// other
Receive requests and notifications from the server
The rx
is used to receive messages from the server. Usually, the message is received in another thread.
let server_ = server.clone; // Clone the server is used to move.
spawn;
rust features
tracing
enable this feature uses thedebug!
macro of the tracing package to output messages between the server and the client.