Files
Kigi-CLI/crates/codegen/kigi-tools/src/implementations/lsp/mod.rs
T
ZacharyZhang-NY a02b555e66 docs(comments): rewrite comments across all crates to the guidelines
Sweep every first-party crate source (1956 .rs files) to the project comment
guidelines: delete redundant restatements, decorative banners, change
narration, and end-of-line comments; keep and tighten the crucial ones
(invariants, bug rationale, SAFETY blocks, ported-source attribution).

No functional code changed. Every edit is proven comment-only against the
prior tree by a comment-stripping lexer (string/char/raw-string aware) plus a
separate doctest-fence check. Where removing a comment made rustfmt or clippy
want to re-lay-out adjacent code, the minimal triggering comment is restored so
code tokens stay byte-identical.

Gates green: cargo fmt --all --check (0 diffs), cargo check and cargo clippy
--workspace --all-targets (0 warnings).

Adds scripts/check_codegen_comment_guidelines.py — the enforcement gate for
these guidelines (flags banners, end-of-line comments, change narration, and
commented-out code).
2026-07-23 16:55:39 -04:00

65 lines
1.7 KiB
Rust

pub mod client;
pub mod config;
pub mod dispatch;
pub mod format;
pub mod manager;
pub mod restart;
mod types;
#[cfg(test)]
mod tests;
pub use dispatch::LspBackendAdapter;
pub use manager::{DiagnosticsSummary, LspManager, drain_lsp_diagnostics};
pub use restart::restart_monitor;
pub use types::{
DiagnosticEntry, DiagnosticSeverityLevel, FileDiagnosticEntry, LspBackend, LspConfig,
LspOperation, LspToolInput, LspToolResult,
};
use std::collections::HashMap;
use std::path::Path;
use std::sync::Arc;
use async_lsp::lsp_types::{
Diagnostic, Position, TextDocumentIdentifier, TextDocumentPositionParams, Url,
};
#[derive(Debug, thiserror::Error)]
pub enum LspError {
#[error("failed to spawn LSP server: {0}")]
SpawnFailed(String),
#[error("LSP server '{0}' timed out after {1:?}")]
Timeout(String, std::time::Duration),
#[error("LSP initialization failed: {0}")]
InitFailed(String),
#[error("LSP request failed: {0}")]
RequestFailed(String),
#[error("invalid file path")]
InvalidPath,
}
pub type DiagnosticsMap = Arc<std::sync::RwLock<HashMap<String, Vec<Diagnostic>>>>;
pub type DiagnosticsNotify = Arc<tokio::sync::Notify>;
pub type LspMainLoop = async_lsp::MainLoop<async_lsp::router::Router<()>>;
pub fn file_uri(path: &Path) -> Result<Url, LspError> {
Url::from_file_path(path).map_err(|_| LspError::InvalidPath)
}
pub fn text_document_position(
path: &Path,
line: u32,
column: u32,
) -> Result<TextDocumentPositionParams, LspError> {
Ok(TextDocumentPositionParams {
text_document: TextDocumentIdentifier {
uri: file_uri(path)?,
},
position: Position {
line,
character: column,
},
})
}