coderlib 0.1.0

A Rust library for AI-powered code assistance and agentic system
Documentation
//! Language Server Protocol (LSP) integration for CoderLib
//!
//! This module provides LSP client functionality to enable code intelligence
//! features like diagnostics, hover information, and completions.

pub mod client;
pub mod manager;
pub mod config;
pub mod types;

pub use client::LspClient;
pub use manager::LspManager;
pub use config::{LspConfig, LspServerConfig};
pub use types::{
    LspError, LspDiagnostic, DiagnosticSeverity, Position, Range, Location,
    CompletionItem, CompletionItemKind, Hover, CodeAction, SymbolInformation, SymbolKind
};

use std::path::Path;
use async_trait::async_trait;

/// Main trait for LSP functionality
#[async_trait]
pub trait LspService: Send + Sync {
    /// Get diagnostics for a file
    async fn get_diagnostics(&self, file_path: &Path) -> Result<Vec<LspDiagnostic>, LspError>;

    /// Notify LSP of file changes
    async fn did_change_file(&self, file_path: &Path, content: &str) -> Result<(), LspError>;

    /// Notify LSP of file open
    async fn did_open_file(&self, file_path: &Path, content: &str) -> Result<(), LspError>;

    /// Notify LSP of file close
    async fn did_close_file(&self, file_path: &Path) -> Result<(), LspError>;

    /// Check if LSP is available for a file type
    fn supports_file(&self, file_path: &Path) -> bool;

    /// Get code completions at a position
    async fn get_completions(&self, file_path: &Path, position: Position) -> Result<Vec<CompletionItem>, LspError>;

    /// Go to definition of symbol at position
    async fn goto_definition(&self, file_path: &Path, position: Position) -> Result<Vec<Location>, LspError>;

    /// Get hover information at position
    async fn get_hover(&self, file_path: &Path, position: Position) -> Result<Option<Hover>, LspError>;

    /// Find references to symbol at position
    async fn find_references(&self, file_path: &Path, position: Position, include_declaration: bool) -> Result<Vec<Location>, LspError>;

    /// Get code actions for a range
    async fn get_code_actions(&self, file_path: &Path, range: Range) -> Result<Vec<CodeAction>, LspError>;

    /// Get document symbols
    async fn get_document_symbols(&self, file_path: &Path) -> Result<Vec<SymbolInformation>, LspError>;

    /// Format document
    async fn format_document(&self, file_path: &Path) -> Result<String, LspError>;

    /// Format range in document
    async fn format_range(&self, file_path: &Path, range: Range) -> Result<String, LspError>;
}