Loads a specific plugin.
(&self, plugin_id: &str)
| 23 | |
| 24 | /// Loads a specific plugin. |
| 25 | pub async fn load_plugin(&self, plugin_id: &str) -> Result<LspPlugin> { |
| 26 | let plugin_dir = self.plugins_dir.join(plugin_id); |
| 27 | let manifest_path = plugin_dir.join("manifest.json"); |
| 28 | |
| 29 | if !manifest_path.exists() { |
| 30 | return Err(anyhow!( |
| 31 | "Plugin manifest not found: {}", |
| 32 | manifest_path.display() |
| 33 | )); |
| 34 | } |
| 35 | |
| 36 | let content = fs::read_to_string(&manifest_path).await?; |
| 37 | let plugin: LspPlugin = serde_json::from_str(&content) |
| 38 | .map_err(|e| anyhow!("Failed to parse manifest: {}", e))?; |
| 39 | |
| 40 | if plugin.id != plugin_id { |
| 41 | return Err(anyhow!( |
| 42 | "Plugin ID mismatch: expected '{}', found '{}'", |
| 43 | plugin_id, |
| 44 | plugin.id |
| 45 | )); |
| 46 | } |
| 47 | |
| 48 | info!("Plugin loaded: {} v{}", plugin.name, plugin.version); |
| 49 | debug!("Supported languages: {:?}", plugin.languages); |
| 50 | debug!("File extensions: {:?}", plugin.file_extensions); |
| 51 | |
| 52 | Ok(plugin) |
| 53 | } |
| 54 | |
| 55 | /// Loads all installed plugins. |
| 56 | pub async fn load_all_plugins(&self) -> Result<Vec<LspPlugin>> { |
no test coverage detected