Skip to main content

LspServer

Struct LspServer 

Source
pub struct LspServer { /* private fields */ }
Expand description

Managed LSP server instance with capabilities and encoding.

Implementations§

Source§

impl LspServer

Source

pub async fn spawn(config: ServerInitConfig) -> Result<Self>

Spawn and initialize LSP server.

This performs the complete initialization sequence:

  1. Spawns the LSP server as a child process
  2. Sends initialize request with client capabilities
  3. Receives server capabilities from initialize response
  4. Sends initialized notification
§Errors

Returns an error if:

  • Server process fails to spawn
  • Initialize request fails or times out
  • Server returns error during initialization
Source

pub const fn capabilities(&self) -> &ServerCapabilities

Get server capabilities.

Source

pub fn position_encoding(&self) -> PositionEncodingKind

Get negotiated position encoding.

Source

pub const fn client(&self) -> &LspClient

Get client for making requests.

Source

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.

Source

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§

Source§

impl Debug for LspServer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more