codive-lsp 0.1.0

LSP client infrastructure for Codive
Documentation

LSP client infrastructure for the AI coding agent

This crate provides Language Server Protocol (LSP) integration, enabling the agent to leverage code intelligence from language servers like rust-analyzer, typescript-language-server, pyright, and gopls.

Architecture

The crate is organized into several modules:

  • [server]: LSP server definitions and spawning
  • [client]: LSP client with JSON-RPC communication
  • [facade]: High-level API with lazy initialization and caching
  • [types]: LSP types and utilities
  • [language]: File extension to language ID mappings

Usage

use codive_lsp::facade::{init, lsp};
use std::path::PathBuf;

// Initialize the LSP subsystem
let working_dir = PathBuf::from("/path/to/project");
init(working_dir);

// Get the LSP instance
let lsp = lsp().unwrap();

// Touch a file to notify LSP servers
lsp.touch_file(Path::new("src/main.rs"), true).await?;

// Go to definition
let locations = lsp.definition(Path::new("src/main.rs"), 10, 5).await?;

Supported Language Servers

Language Server Extensions
Rust rust-analyzer .rs
TypeScript/JavaScript typescript-language-server .ts, .tsx, .js, .jsx
Python pyright .py, .pyi
Go gopls .go

LSP Operations

The following LSP operations are supported:

  • goToDefinition - Find where a symbol is defined
  • findReferences - Find all references to a symbol
  • hover - Get hover information (documentation, types)
  • documentSymbol - Get all symbols in a document
  • workspaceSymbol - Search for symbols across the workspace
  • goToImplementation - Find implementations of a trait/interface
  • prepareCallHierarchy - Get call hierarchy item at a position
  • incomingCalls - Find all callers of a function
  • outgoingCalls - Find all functions called by a function