From 486112dbfa7cb53668cb9bbd777fb7eb486b23a0 Mon Sep 17 00:00:00 2001 From: Steven Kalt Date: Wed, 28 Jan 2026 12:54:06 -0500 Subject: [PATCH 1/3] refactor: use worktree env for spawning the language server. This also prefers any executable on PATH named bash-language-server. --- src/bash.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/bash.rs b/src/bash.rs index 890cf99..9c5c722 100644 --- a/src/bash.rs +++ b/src/bash.rs @@ -1,4 +1,4 @@ -use std::{env, fs}; +use std::{fs, path::PathBuf}; use zed_extension_api::{self as zed, Result}; const SERVER_PATH: &str = "node_modules/bash-language-server/out/cli.js"; @@ -64,20 +64,27 @@ impl zed::Extension for BashExtension { fn language_server_command( &mut self, id: &zed::LanguageServerId, - _worktree: &zed::Worktree, + worktree: &zed::Worktree, ) -> Result { + let env = worktree.shell_env(); + if let Some(cmd) = worktree.which(PACKAGE_NAME) { + return Ok(zed::Command { + command: cmd.clone(), + args: vec!["start".to_string()], + env, + }); + } let server_path = self.server_script_path(&id)?; Ok(zed::Command { command: zed::node_binary_path()?, args: vec![ - env::current_dir() - .unwrap() - .join(&server_path) + PathBuf::from(worktree.root_path()) + .join(server_path) .to_string_lossy() .to_string(), "start".to_string(), ], - env: Default::default(), + env, }) } From 9ff8e44171e73be8978df49439c77151c9a40e7d Mon Sep 17 00:00:00 2001 From: Steven Kalt Date: Mon, 2 Feb 2026 17:17:04 -0500 Subject: [PATCH 2/3] chore: fix clippy lints --- src/bash.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bash.rs b/src/bash.rs index 9c5c722..22c9dac 100644 --- a/src/bash.rs +++ b/src/bash.rs @@ -10,7 +10,7 @@ struct BashExtension { impl BashExtension { fn server_exists(&self) -> bool { - fs::metadata(SERVER_PATH).map_or(false, |stat| stat.is_file()) + fs::metadata(SERVER_PATH).is_ok_and(|stat| stat.is_file()) } fn server_script_path(&mut self, id: &zed::LanguageServerId) -> Result { @@ -74,7 +74,7 @@ impl zed::Extension for BashExtension { env, }); } - let server_path = self.server_script_path(&id)?; + let server_path = self.server_script_path(id)?; Ok(zed::Command { command: zed::node_binary_path()?, args: vec![ From f4fe133fd7b2b6df43a74a8c73d0e08a88b41d4d Mon Sep 17 00:00:00 2001 From: Steven Kalt Date: Tue, 3 Feb 2026 09:26:39 -0500 Subject: [PATCH 3/3] fix: path to extension-specific installation of bash-language-server --- src/bash.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bash.rs b/src/bash.rs index 22c9dac..1c10e05 100644 --- a/src/bash.rs +++ b/src/bash.rs @@ -1,4 +1,4 @@ -use std::{fs, path::PathBuf}; +use std::{env, fs}; use zed_extension_api::{self as zed, Result}; const SERVER_PATH: &str = "node_modules/bash-language-server/out/cli.js"; @@ -66,25 +66,27 @@ impl zed::Extension for BashExtension { id: &zed::LanguageServerId, worktree: &zed::Worktree, ) -> Result { - let env = worktree.shell_env(); + let shell_env = worktree.shell_env(); if let Some(cmd) = worktree.which(PACKAGE_NAME) { return Ok(zed::Command { command: cmd.clone(), args: vec!["start".to_string()], - env, + env: shell_env, }); } + // TODO: consider drawing `bash_language_server` from the worktree's own `./node_modules/` + let extension_work_dir = env::current_dir().unwrap(); let server_path = self.server_script_path(id)?; Ok(zed::Command { command: zed::node_binary_path()?, args: vec![ - PathBuf::from(worktree.root_path()) - .join(server_path) + extension_work_dir + .join(&server_path) .to_string_lossy() .to_string(), "start".to_string(), ], - env, + env: shell_env, }) }