Crate ricecoder_external_lsp

Crate ricecoder_external_lsp 

Source
Expand description

External Language Server Protocol (LSP) integration for RiceCoder

This crate provides integration with external LSP servers to provide real semantic intelligence for code completion, diagnostics, hover, and navigation across multiple programming languages.

§Features

  • Configuration-Driven: Support unlimited LSP servers through YAML configuration
  • Process Management: Automatic spawning, monitoring, and restart of LSP servers
  • Output Mapping: Transform LSP server responses to ricecoder models via configuration
  • Graceful Degradation: Fall back to internal providers when external LSP unavailable
  • Multi-Language Support: Pre-configured for Rust, TypeScript, Python, Go, Java, and more

§Architecture

The external LSP integration follows a layered architecture:

┌─────────────────────────────────────────────────────────────────────────┐
│                         Ricecoder LSP Proxy                              │
├─────────────────────────────────────────────────────────────────────────┤
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────────────────┐ │
│  │  LSP Server     │  │  Request        │  │  Response               │ │
│  │  Registry       │  │  Router         │  │  Merger                 │ │
│  │  (Config)       │  │  (Language)     │  │  (External + Internal)  │ │
│  └────────┬────────┘  └────────┬────────┘  └────────────┬────────────┘ │
│           │                    │                        │              │
│  ┌────────▼────────────────────▼────────────────────────▼────────────┐ │
│  │                    External LSP Client Pool                        │ │
│  │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐             │ │
│  │  │ rust-analyzer│  │  tsserver    │  │   pylsp      │  ...        │ │
│  │  │   Client     │  │   Client     │  │   Client     │             │ │
│  │  └──────────────┘  └──────────────┘  └──────────────┘             │ │
│  └───────────────────────────────────────────────────────────────────┘ │
│                                                                         │
│  ┌─────────────────────────────────────────────────────────────────┐   │
│  │                    Process Manager                               │   │
│  │  - Spawn/terminate LSP server processes                         │   │
│  │  - Health monitoring and auto-restart                           │   │
│  │  - Resource management (memory, CPU limits)                     │   │
│  └─────────────────────────────────────────────────────────────────┘   │
│                                                                         │
│  ┌─────────────────────────────────────────────────────────────────┐   │
│  │                    Fallback Provider                             │   │
│  │  - Internal completion (existing ricecoder-completion)          │   │
│  │  - Internal diagnostics (existing ricecoder-lsp)                │   │
│  │  - Used when external LSP unavailable                           │   │
│  └─────────────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────────────┘

§Module Organization

  • registry: LSP server registry and configuration management
  • client: LSP client communication and protocol handling
  • process: LSP server process management
  • mapping: Output mapping and transformation
  • merger: Response merging from multiple sources
  • error: Error types and result types
  • types: Core data structures

Re-exports§

pub use client::CapabilityNegotiator;
pub use client::ClientCapabilities;
pub use client::JsonRpcError;
pub use client::JsonRpcHandler;
pub use client::JsonRpcMessage;
pub use client::JsonRpcNotification;
pub use client::JsonRpcRequest;
pub use client::JsonRpcResponse;
pub use client::LspConnection;
pub use client::PendingRequest;
pub use client::RequestId;
pub use client::ServerCapabilities;
pub use error::ExternalLspError;
pub use error::Result;
pub use mapping::CompletionMapper;
pub use mapping::DiagnosticsMapper;
pub use mapping::HoverMapper;
pub use mapping::JsonPathParser;
pub use mapping::OutputTransformer;
pub use merger::CompletionMerger;
pub use merger::DiagnosticsMerger;
pub use merger::HoverMerger;
pub use process::ClientPool;
pub use process::HealthChecker;
pub use process::ProcessManager;
pub use registry::ConfigLoader;
pub use registry::DefaultServerConfigs;
pub use registry::ServerDiscovery;
pub use semantic::SemanticFeatures;
pub use storage_integration::StorageConfigLoader;
pub use types::ClientState;
pub use types::CompletionMappingRules;
pub use types::DiagnosticsMappingRules;
pub use types::ExternalLspResult;
pub use types::GlobalLspSettings;
pub use types::HealthStatus;
pub use types::HoverMappingRules;
pub use types::LspServerConfig;
pub use types::LspServerRegistry;
pub use types::MergeConfig;
pub use types::OutputMappingConfig;
pub use types::ResultSource;

Modules§

client
LSP client communication and protocol handling
error
Error types for external LSP integration
mapping
Output mapping and transformation
merger
Response merging from multiple sources
process
LSP server process management
registry
LSP server registry and configuration management
semantic
Semantic feature integration (completion, diagnostics, hover, navigation)
storage_integration
Storage integration for external LSP configuration
types
Core data structures for external LSP integration