pub struct LspServer { /* private fields */ }Expand description
Managed LSP server instance with capabilities and encoding.
Implementations§
Source§impl LspServer
impl LspServer
Sourcepub async fn spawn(config: ServerInitConfig) -> Result<Self>
pub async fn spawn(config: ServerInitConfig) -> Result<Self>
Spawn and initialize LSP server.
This performs the complete initialization sequence:
- Spawns the LSP server as a child process
- Sends initialize request with client capabilities
- Receives server capabilities from initialize response
- Sends initialized notification
§Errors
Returns an error if:
- Server process fails to spawn
- Initialize request fails or times out
- Server returns error during initialization
Sourcepub const fn capabilities(&self) -> &ServerCapabilities
pub const fn capabilities(&self) -> &ServerCapabilities
Get server capabilities.
Sourcepub fn position_encoding(&self) -> PositionEncodingKind
pub fn position_encoding(&self) -> PositionEncodingKind
Get negotiated position encoding.
Sourcepub async fn shutdown(self) -> Result<()>
pub async fn shutdown(self) -> Result<()>
Shutdown server gracefully.
Sends shutdown request, waits for response, then sends exit notification.
§Errors
Returns an error if shutdown sequence fails.
Sourcepub async fn spawn_batch(configs: &[ServerInitConfig]) -> ServerInitResult
pub async fn spawn_batch(configs: &[ServerInitConfig]) -> ServerInitResult
Spawn multiple LSP servers in batch mode with graceful degradation.
Attempts to spawn and initialize all configured servers. If some servers fail to spawn, the successful servers are still returned. This enables graceful degradation where the system can continue to operate with partial functionality.
§Behavior
- Attempts to spawn each server sequentially
- Logs success (info) and failure (error) for each server
- Accumulates successful servers and failures
- Never panics or returns early - attempts all servers
§Examples
use mcpls_core::lsp::{LspServer, ServerInitConfig};
use mcpls_core::config::LspServerConfig;
use std::path::PathBuf;
let configs = vec![
ServerInitConfig {
server_config: LspServerConfig::rust_analyzer(),
workspace_roots: vec![PathBuf::from("/workspace")],
initialization_options: None,
},
ServerInitConfig {
server_config: LspServerConfig::pyright(),
workspace_roots: vec![PathBuf::from("/workspace")],
initialization_options: None,
},
];
let result = LspServer::spawn_batch(&configs).await;
if result.has_servers() {
println!("Successfully spawned {} servers", result.server_count());
}
if result.partial_success() {
eprintln!("Warning: {} servers failed", result.failure_count());
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for LspServer
impl !RefUnwindSafe for LspServer
impl Send for LspServer
impl Sync for LspServer
impl Unpin for LspServer
impl !UnwindSafe for LspServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more