Unnamed repository; edit this file 'description' to name the repository.
Avoid cloning configured env vars when starting a language server
The clone of the hashmap can be avoided by passing a ref instead. This commit also changes the `server_environment` type to match the bounds expected by `Command::envs` - this will avoid future refactoring if the underlying type changes (for example switching to `hashbrown::HashMap`).
Michael Davis 2025-02-19
parent e0da129 · commit d031260
-rw-r--r--helix-lsp/src/client.rs13
-rw-r--r--helix-lsp/src/lib.rs2
2 files changed, 9 insertions, 6 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 3a50f20a..d6308997 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -16,11 +16,14 @@ use helix_stdx::path;
use parking_lot::Mutex;
use serde::Deserialize;
use serde_json::Value;
-use std::sync::{
- atomic::{AtomicU64, Ordering},
- Arc,
-};
use std::{collections::HashMap, path::PathBuf};
+use std::{
+ ffi::OsStr,
+ sync::{
+ atomic::{AtomicU64, Ordering},
+ Arc,
+ },
+};
use std::{future::Future, sync::OnceLock};
use std::{path::Path, process::Stdio};
use tokio::{
@@ -178,7 +181,7 @@ impl Client {
cmd: &str,
args: &[String],
config: Option<Value>,
- server_environment: HashMap<String, String>,
+ server_environment: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>,
root_path: PathBuf,
root_uri: Option<lsp::Url>,
id: LanguageServerId,
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index 5eeea81c..df57bbe8 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -871,7 +871,7 @@ fn start_client(
&ls_config.command,
&ls_config.args,
ls_config.config.clone(),
- ls_config.environment.clone(),
+ &ls_config.environment,
root_path,
root_uri,
id,