From 6398b45084669963033fcc77babafc0c42a39290 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 23 Jul 2024 10:12:40 -0400 Subject: [PATCH] astro: Upgrade `zed_extension_api` to v0.0.6 (#15010) This PR upgrades the Astro extension to use v0.0.6 of the `zed_extension_api`. Release Notes: - N/A --- Cargo.lock | 2 +- extensions/astro/Cargo.toml | 2 +- extensions/astro/src/astro.rs | 22 ++++++++++------------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b12721af7..0f4bb6bebb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13855,7 +13855,7 @@ dependencies = [ name = "zed_astro" version = "0.0.2" dependencies = [ - "zed_extension_api 0.0.4", + "zed_extension_api 0.0.6", ] [[package]] diff --git a/extensions/astro/Cargo.toml b/extensions/astro/Cargo.toml index 0b42bde53d..02203bc63d 100644 --- a/extensions/astro/Cargo.toml +++ b/extensions/astro/Cargo.toml @@ -13,4 +13,4 @@ path = "src/astro.rs" crate-type = ["cdylib"] [dependencies] -zed_extension_api = "0.0.4" +zed_extension_api = "0.0.6" diff --git a/extensions/astro/src/astro.rs b/extensions/astro/src/astro.rs index cabe89adea..c3bb859d22 100644 --- a/extensions/astro/src/astro.rs +++ b/extensions/astro/src/astro.rs @@ -1,5 +1,5 @@ use std::{env, fs}; -use zed_extension_api::{self as zed, Result}; +use zed_extension_api::{self as zed, serde_json, Result}; const SERVER_PATH: &str = "node_modules/@astrojs/language-server/bin/nodeServer.js"; const PACKAGE_NAME: &str = "@astrojs/language-server"; @@ -13,14 +13,14 @@ impl AstroExtension { fs::metadata(SERVER_PATH).map_or(false, |stat| stat.is_file()) } - fn server_script_path(&mut self, config: zed::LanguageServerConfig) -> Result { + fn server_script_path(&mut self, language_server_id: &zed::LanguageServerId) -> Result { let server_exists = self.server_exists(); if self.did_find_server && server_exists { return Ok(SERVER_PATH.to_string()); } zed::set_language_server_installation_status( - &config.name, + language_server_id, &zed::LanguageServerInstallationStatus::CheckingForUpdate, ); let version = zed::npm_package_latest_version(PACKAGE_NAME)?; @@ -29,7 +29,7 @@ impl AstroExtension { || zed::npm_package_installed_version(PACKAGE_NAME)?.as_ref() != Some(&version) { zed::set_language_server_installation_status( - &config.name, + language_server_id, &zed::LanguageServerInstallationStatus::Downloading, ); let result = zed::npm_install_package(PACKAGE_NAME, &version); @@ -63,10 +63,10 @@ impl zed::Extension for AstroExtension { fn language_server_command( &mut self, - config: zed::LanguageServerConfig, + language_server_id: &zed::LanguageServerId, _worktree: &zed::Worktree, ) -> Result { - let server_path = self.server_script_path(config)?; + let server_path = self.server_script_path(language_server_id)?; Ok(zed::Command { command: zed::node_binary_path()?, args: vec![ @@ -83,17 +83,15 @@ impl zed::Extension for AstroExtension { fn language_server_initialization_options( &mut self, - _config: zed::LanguageServerConfig, + _language_server_id: &zed::LanguageServerId, _worktree: &zed::Worktree, - ) -> Result> { - let initialization_options = r#"{ + ) -> Result> { + Ok(Some(serde_json::json!({ "provideFormatter": true, "typescript": { "tsdk": "node_modules/typescript/lib" } - }"#; - - Ok(Some(initialization_options.to_string())) + }))) } }