Crates.io | lsp-client-rs |
lib.rs | lsp-client-rs |
version | 0.1.0 |
source | src |
created_at | 2024-03-30 12:31:20.180906 |
updated_at | 2024-03-30 12:31:20.180906 |
description | A Rust client to talk to LSP servers. |
homepage | https://github.com/sudarshan-reddy/lsp-rs |
repository | https://github.com/sudarshan-reddy/lsp-rs |
max_upload_size | |
id | 1191036 |
size | 24,398 |
lsp-rs
is a Rust library designed to facilitate communication with Language Server Protocol (LSP) servers. It provides an asynchronous client for sending and receiving messages in accordance with the LSP specification, making it easier to integrate LSP features into Rust applications.
Initialize
, Notification
, and Response
.Add lsp-rs
to your Cargo.toml
:
[dependencies]
lsp-rs = "0.1.0"
Here's a basic example of how to use lsp-rs to initialize a connection with an LSP server and send an initialization request:
use lsp_rs::{LspClient, RequestMessage};
use tokio::runtime::Runtime;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rt = Runtime::new()?;
rt.block_on(async {
let mut client = LspClient::new("tcp:127.0.0.1:8080").await?;
let initialize_request = RequestMessage::new_initialize(
1, // Request ID
std::process::id(),
"file:///path/to/workspace".into(),
"MyLSPClient".into(),
"1.0".into(),
vec![], // Workspace folders
);
client.send_request(initialize_request).await?;
let response = client.handle_response().await?;
println!("Received response: {:?}", response);
Ok(())
})
}