Implements a full Language Server Protocol server accessible via `streamd lsp`. The server communicates over stdin/stdout and auto- detects the workspace root from the LSP initialize request. Features implemented: - Passive mode when no .streamd.toml exists in workspace root - Workspace-root-based config loading (bypasses R22/R23 global config) - .streamd.toml file watcher (config reloads without restart) - textDocument/completion with @ trigger, conditional suggestions (if_with relationships), and temporal date/time snippets (R16) - textDocument/publishDiagnostics: R15 file-name format + R18 timesheet violations (overlapping timecards, unclosed days) - textDocument/documentSymbol: shard tree exposed as nested symbols - textDocument/codeAction: "Mark task as done" quickfix for @Task - workspace/symbol: cross-file shard search - textDocument/references: find all @Marker occurrences - textDocument/rename: rename @Marker across all files Dependencies added: tower-lsp 0.20, tokio, dashmap, serde_json
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
use std::fs;
|
|
use std::path::Path;
|
|
|
|
use chrono_tz::Tz;
|
|
use walkdir::WalkDir;
|
|
|
|
use crate::error::StreamdError;
|
|
use crate::extract::parse_markdown_file;
|
|
use crate::localize::localize_stream_file;
|
|
use crate::models::{LocalizedShard, RepositoryConfiguration};
|
|
|
|
pub mod completions;
|
|
pub mod daily;
|
|
pub mod edit;
|
|
pub mod lsp;
|
|
pub mod new;
|
|
pub mod timesheet;
|
|
pub mod todo;
|
|
|
|
pub fn load_markdown_shards(
|
|
base_folder: &Path,
|
|
config: &RepositoryConfiguration,
|
|
tz: Tz,
|
|
) -> Result<Vec<LocalizedShard>, StreamdError> {
|
|
let mut shards = Vec::new();
|
|
for entry in WalkDir::new(base_folder)
|
|
.max_depth(1)
|
|
.into_iter()
|
|
.filter_map(|e| e.ok())
|
|
{
|
|
let path = entry.path();
|
|
if path.extension().map(|e| e == "md").unwrap_or(false) {
|
|
let file_name = path.to_string_lossy().to_string();
|
|
let content = fs::read_to_string(path)?;
|
|
let stream_file = parse_markdown_file(&file_name, &content);
|
|
if let Ok(shard) = localize_stream_file(&stream_file, config, tz) {
|
|
shards.push(shard);
|
|
}
|
|
}
|
|
}
|
|
Ok(shards)
|
|
}
|