Crate ricecoder_lsp

Crate ricecoder_lsp 

Source
Expand description

Language Server Protocol (LSP) integration for RiceCoder

This crate provides LSP server capabilities for semantic code analysis, diagnostics, code actions, and hover information across multiple programming languages.

§Architecture

The LSP integration follows a layered architecture with external LSP proxy support:

  1. External LSP Proxy Layer: Routes requests to external LSP servers (rust-analyzer, tsserver, pylsp, etc.)
  2. Internal Semantic Analysis Layer: Provides fallback semantic analysis when external LSP is unavailable
  3. Diagnostics Layer: Collects and merges diagnostics from external and internal sources
  4. Hover Layer: Provides hover information from external and internal sources
  5. Code Actions Layer: Provides code actions from external and internal sources

§External LSP Integration

The LSP module integrates with external LSP servers through the ExternalLspClient and LspProxy. When a request is made:

  1. If an external LSP server is configured for the language, the request is forwarded to it
  2. The external LSP response is transformed to ricecoder’s internal model
  3. External results are merged with internal results (external takes priority)
  4. If the external LSP is unavailable, the system falls back to internal providers

§Fallback Behavior

When external LSP servers are unavailable:

  • Completions: Fall back to internal completion providers (keyword and pattern-based)
  • Diagnostics: Fall back to internal diagnostics engine
  • Hover: Fall back to internal hover provider
  • Navigation: Fall back to internal definition/reference providers

This ensures users always get some results, even if not semantic.

Re-exports§

pub use cache::hash_input;
pub use cache::AstCache;
pub use cache::SemanticCache;
pub use cache::SymbolIndexCache;
pub use code_actions::CodeActionsEngine;
pub use completion::CompletionHandler;
pub use config::CodeActionTemplate;
pub use config::ConfigLoader;
pub use config::ConfigRegistry;
pub use config::ConfigurationManager;
pub use config::DiagnosticRule;
pub use config::LanguageConfig;
pub use diagnostics::DiagnosticsEngine;
pub use hover::HoverProvider;
pub use performance::PerformanceAnalyzer;
pub use performance::PerformanceTracker;
pub use performance::Timer;
pub use providers::CodeActionProvider;
pub use providers::CodeActionRegistry;
pub use providers::DiagnosticsProvider;
pub use providers::DiagnosticsRegistry;
pub use providers::SemanticAnalyzerProvider;
pub use providers::SemanticAnalyzerRegistry;
pub use proxy::ExternalLspClient;
pub use proxy::LspProxy;
pub use refactoring::RefactoringHandler;
pub use semantic::SemanticAnalyzer;
pub use server::LspServer;
pub use types::CodeAction;
pub use types::Diagnostic;
pub use types::HoverInfo;
pub use types::Position;
pub use types::Range;

Modules§

cache
Caching layer for semantic analysis and AST parsing
code_actions
Code Actions Module
completion
config
Configuration module for language-agnostic, configuration-driven architecture
diagnostics
Diagnostics Engine Module
hover
Hover Information Provider
performance
Performance monitoring and optimization utilities
providers
Provider traits for pluggable language-specific implementations
proxy
LSP Proxy for external LSP server integration
refactoring
Refactoring integration for LSP
semantic
Semantic Analysis Engine
server
LSP Server implementation
transport
JSON-RPC message transport over stdio
types
Core LSP types and data structures