ricecoder_lsp/
lib.rs

1//! Language Server Protocol (LSP) integration for RiceCoder
2//!
3//! This crate provides LSP server capabilities for semantic code analysis,
4//! diagnostics, code actions, and hover information across multiple programming languages.
5//!
6//! # Architecture
7//!
8//! The LSP integration follows a layered architecture with external LSP proxy support:
9//!
10//! 1. **External LSP Proxy Layer**: Routes requests to external LSP servers (rust-analyzer, tsserver, pylsp, etc.)
11//! 2. **Internal Semantic Analysis Layer**: Provides fallback semantic analysis when external LSP is unavailable
12//! 3. **Diagnostics Layer**: Collects and merges diagnostics from external and internal sources
13//! 4. **Hover Layer**: Provides hover information from external and internal sources
14//! 5. **Code Actions Layer**: Provides code actions from external and internal sources
15//!
16//! # External LSP Integration
17//!
18//! The LSP module integrates with external LSP servers through the `ExternalLspClient` and `LspProxy`.
19//! When a request is made:
20//!
21//! 1. If an external LSP server is configured for the language, the request is forwarded to it
22//! 2. The external LSP response is transformed to ricecoder's internal model
23//! 3. External results are merged with internal results (external takes priority)
24//! 4. If the external LSP is unavailable, the system falls back to internal providers
25//!
26//! # Fallback Behavior
27//!
28//! When external LSP servers are unavailable:
29//!
30//! - **Completions**: Fall back to internal completion providers (keyword and pattern-based)
31//! - **Diagnostics**: Fall back to internal diagnostics engine
32//! - **Hover**: Fall back to internal hover provider
33//! - **Navigation**: Fall back to internal definition/reference providers
34//!
35//! This ensures users always get some results, even if not semantic.
36
37pub mod cache;
38pub mod code_actions;
39pub mod completion;
40pub mod config;
41pub mod diagnostics;
42pub mod hover;
43pub mod performance;
44pub mod providers;
45pub mod proxy;
46pub mod refactoring;
47pub mod semantic;
48pub mod server;
49pub mod transport;
50pub mod types;
51
52// Re-export public API
53pub use cache::{hash_input, AstCache, SemanticCache, SymbolIndexCache};
54pub use code_actions::CodeActionsEngine;
55pub use completion::CompletionHandler;
56pub use config::{
57    CodeActionTemplate, ConfigLoader, ConfigRegistry, ConfigurationManager, DiagnosticRule,
58    LanguageConfig,
59};
60pub use diagnostics::DiagnosticsEngine;
61pub use hover::HoverProvider;
62pub use performance::{PerformanceAnalyzer, PerformanceTracker, Timer};
63pub use providers::{
64    CodeActionProvider, CodeActionRegistry, DiagnosticsProvider, DiagnosticsRegistry,
65    SemanticAnalyzerProvider, SemanticAnalyzerRegistry,
66};
67pub use proxy::{ExternalLspClient, LspProxy};
68pub use refactoring::RefactoringHandler;
69pub use semantic::SemanticAnalyzer;
70pub use server::LspServer;
71pub use types::{CodeAction, Diagnostic, HoverInfo, Position, Range};