diff --git a/Cargo.toml b/Cargo.toml index 9ace523026ce3d1c117db2c20beef83d5814466a..ff5193e292c1f4053ccece4b5633157abd5b63c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ edition = "2024" [dependencies] anyhow = "1.0.100" +async-gen = "0.2.3" async-lsp = "0.2.2" async-process = "2.3" clap = { version = "4.5.48", features = ["derive"] } diff --git a/src/config.rs b/src/config.rs index 55685a22eeddecc4d815dc39daa81f731884f80d..db983c37ab4216eea1c82aa752e312cfc662a0b6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,8 @@ +use async_gen::{AsyncIter, r#gen}; +use anyhow::Context; use clap::Parser; use rmcp::serde_json; -use std::path::PathBuf; +use std::{fs::FileType, path::{Path, PathBuf}}; #[derive(Parser, Debug)] #[command(version, about)] @@ -18,6 +20,8 @@ pub struct Command { #[derive(serde::Deserialize, Debug)] pub struct Config { pub lsp_server_command: Command, + + /// An absolute path pointing to the root of the project on disk. pub project_root: PathBuf, } @@ -27,4 +31,18 @@ impl Config { let config: Config = serde_json::from_str(&config_content)?; Ok(config) } + + /// Returns a `Some` containing an absolute `` to the file if it is in the + /// project, otherwise returns `None` + pub async fn path_in_project
(&self, path: P) -> anyhow::Result