laburnum 1.17.0

An LSP framework for building language servers and compilers, powered by an incremental query tree with content-addressed storage, task-based dataflow, and parallel queries.
Documentation
// Copyright Two Neutron Stars Incorporated and contributors
// SPDX-License-Identifier: BlueOak-1.0.0

/// Error that occurs when attempting to call the language server after it has
/// already exited.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ExitedError(());

impl std::error::Error for ExitedError {}

impl std::fmt::Display for ExitedError {
  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
    f.write_str("language server has exited")
  }
}

#[derive(Debug, thiserror::Error)]
pub enum LspClientError {
  #[error("Failed to send message")]
  SendFailed(
    #[from] async_channel::SendError<crate::protocol::jsonrpc::Message>,
  ),

  #[error("Failed to receive response")]
  ReceiveFailed(#[from] async_channel::RecvError),

  #[error("Failed to serialize params: {0}")]
  SerializationFailed(#[from] serde_json::Error),

  #[error("Failed to deserialize result")]
  DeserializationFailed(serde_json::Error),

  #[error("Server not initialized (-32002)")]
  NotInitialized,

  #[error("JSON-RPC error {code}: {message}")]
  JsonRpcError { code: i64, message: String },

  #[error("Invalid response: no result or error")]
  InvalidResponse,

  #[error("Connection closed")]
  ConnectionClosed,

  #[error("Request timed out after {0:?}")]
  Timeout(std::time::Duration),
}