laburnum 1.17.1

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

//! `hover`.

use crate::{
  connect::lsp::{
    LspClient,
    request::HoverRequest,
  },
  connect::mcp::{
    schema,
    tool::{
      Tool,
      ToolError,
      ToolRegistry,
    },
  },
  protocol::lsp::{
    Hover as LspHover,
    HoverParams,
  },
};

pub fn register(registry: &mut ToolRegistry) {
  registry.register::<Hover>();
}

pub enum Hover {}

impl Tool for Hover {
  type Input = HoverParams;
  type Output = Option<LspHover>;

  const NAME: &'static str = "hover";
  const DESCRIPTION: &'static str =
    "Get human-readable documentation for the symbol at the given position \
     (type signature, docstring, etc.). Wraps LSP `textDocument/hover`.";

  fn input_schema() -> serde_json::Value {
    schema::text_document_position()
  }

  async fn call(
    client: &LspClient,
    input: Self::Input,
  ) -> Result<Self::Output, ToolError> {
    Ok(client.send_request::<HoverRequest>(input).await?)
  }
}