purescript: Upgrade zed_extension_api to v0.0.6 (#15181)

This PR upgrades the PureScript extension to use v0.0.6 of the
`zed_extension_api`.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-25 08:55:16 -04:00 committed by GitHub
parent 856a8ef5e8
commit 8ba392bba6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 14 deletions

2
Cargo.lock generated
View file

@ -13867,7 +13867,7 @@ dependencies = [
name = "zed_purescript"
version = "0.0.1"
dependencies = [
"zed_extension_api 0.0.4",
"zed_extension_api 0.0.6",
]
[[package]]

View file

@ -13,4 +13,4 @@ path = "src/purescript.rs"
crate-type = ["cdylib"]
[dependencies]
zed_extension_api = "0.0.4"
zed_extension_api = "0.0.6"

View file

@ -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/.bin/purescript-language-server";
const PACKAGE_NAME: &str = "purescript-language-server";
@ -13,14 +13,14 @@ impl PurescriptExtension {
fs::metadata(SERVER_PATH).map_or(false, |stat| stat.is_file())
}
fn server_script_path(&mut self, config: zed::LanguageServerConfig) -> Result<String> {
fn server_script_path(&mut self, language_server_id: &zed::LanguageServerId) -> Result<String> {
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 PurescriptExtension {
|| 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 PurescriptExtension {
fn language_server_command(
&mut self,
config: zed::LanguageServerConfig,
language_server_id: &zed::LanguageServerId,
_worktree: &zed::Worktree,
) -> Result<zed::Command> {
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,16 +83,14 @@ impl zed::Extension for PurescriptExtension {
fn language_server_initialization_options(
&mut self,
_config: zed::LanguageServerConfig,
_language_server_id: &zed::LanguageServerId,
_worktree: &zed::Worktree,
) -> Result<Option<String>> {
let initialization_options = r#"{
) -> Result<Option<serde_json::Value>> {
Ok(Some(serde_json::json!({
"purescript": {
"addSpagoSources": true
}
}"#;
Ok(Some(initialization_options.to_string()))
})))
}
}