pub struct LspClient { /* private fields */ }Expand description
LSP client with async request/response handling.
This client manages communication with an LSP server, handling:
- Concurrent requests with unique ID tracking
- Background message loop for receiving responses
- Timeout support for all requests
- Graceful shutdown
Implementations§
Source§impl LspClient
impl LspClient
Sourcepub fn new(config: LspServerConfig) -> Self
pub fn new(config: LspServerConfig) -> Self
Create a new LSP client with the given configuration.
The client starts in an uninitialized state. Call initialize() to
start the server and complete the initialization handshake.
Sourcepub fn language_id(&self) -> &str
pub fn language_id(&self) -> &str
Get the language ID for this client.
Sourcepub async fn state(&self) -> ServerState
pub async fn state(&self) -> ServerState
Get the current server state.
Sourcepub async fn request<P, R>(
&self,
method: &str,
params: P,
timeout_duration: Duration,
) -> Result<R>where
P: Serialize,
R: DeserializeOwned,
pub async fn request<P, R>(
&self,
method: &str,
params: P,
timeout_duration: Duration,
) -> Result<R>where
P: Serialize,
R: DeserializeOwned,
Send request and wait for response with timeout.
Automatically retries up to 3 times when the server returns error code
-32802 (ServerCancelled) with data.retriggerRequest == true, using
exponential backoff starting at 500 ms.
§Type Parameters
P- The type of the request parameters (must be serializable)R- The type of the response result (must be deserializable)
§Errors
Returns an error if:
- Server has shut down
- Request times out
- Response cannot be deserialized
- LSP server returns an error
Trait Implementations§
Source§impl Clone for LspClient
impl Clone for LspClient
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Creates a clone that shares the underlying connection.
The clone does not own the receiver task and cannot perform shutdown. All clones share the same command channel for sending requests.
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more