aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorMichael Davis2024-01-23 14:29:07 +0000
committerBlaž Hrastnik2024-01-24 06:47:49 +0000
commit6d724a8f331f4b2a8f1a001e990cf6129dc50b00 (patch)
treecc2d8c6068ec8ad58aa29320c08c6218b2e8070d /helix-view
parent6bfe1ddc53f542d62e242fd4aaf6748dda1b0e71 (diff)
Re-export `which` from `helix-stdx::env`
We use `which::which` in many crates, so `which` was a separate dependency across all of them. We can centralize `which` into the stdx crate so it's easy for all crates to depend on it. I also moved the rest of `helix-view/src/env.rs` into helix-stdx's `env` module since it only contained a thin wrapper around `which` and `std::env`.
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/Cargo.toml1
-rw-r--r--helix-view/src/clipboard.rs4
-rw-r--r--helix-view/src/document.rs7
-rw-r--r--helix-view/src/editor.rs4
-rw-r--r--helix-view/src/env.rs8
-rw-r--r--helix-view/src/lib.rs1
6 files changed, 10 insertions, 15 deletions
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml
index 0dc18b37..2e689341 100644
--- a/helix-view/Cargo.toml
+++ b/helix-view/Cargo.toml
@@ -46,7 +46,6 @@ serde_json = "1.0"
toml = "0.7"
log = "~0.4"
-which = "5.0.0"
parking_lot = "0.12.1"
diff --git a/helix-view/src/clipboard.rs b/helix-view/src/clipboard.rs
index 812c803e..9ff2fd78 100644
--- a/helix-view/src/clipboard.rs
+++ b/helix-view/src/clipboard.rs
@@ -73,7 +73,7 @@ pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
#[cfg(target_os = "macos")]
pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
- use crate::env::{binary_exists, env_var_is_set};
+ use helix_stdx::env::{binary_exists, env_var_is_set};
if env_var_is_set("TMUX") && binary_exists("tmux") {
command_provider! {
@@ -98,7 +98,7 @@ pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
#[cfg(not(any(windows, target_os = "wasm32", target_os = "macos")))]
pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
- use crate::env::{binary_exists, env_var_is_set};
+ use helix_stdx::env::{binary_exists, env_var_is_set};
use provider::command::is_exit_success;
// TODO: support for user-defined provider, probably when we have plugin support by setting a
// variable?
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 388810b1..88653948 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -726,7 +726,12 @@ impl Document {
if let Some((fmt_cmd, fmt_args)) = self
.language_config()
.and_then(|c| c.formatter.as_ref())
- .and_then(|formatter| Some((which::which(&formatter.command).ok()?, &formatter.args)))
+ .and_then(|formatter| {
+ Some((
+ helix_stdx::env::which(&formatter.command).ok()?,
+ &formatter.args,
+ ))
+ })
{
use std::process::Stdio;
let text = self.text().clone();
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index fbfcb356..f605cbb5 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -329,7 +329,7 @@ pub struct TerminalConfig {
#[cfg(windows)]
pub fn get_terminal_provider() -> Option<TerminalConfig> {
- use crate::env::binary_exists;
+ use helix_stdx::env::binary_exists;
if binary_exists("wt") {
return Some(TerminalConfig {
@@ -352,7 +352,7 @@ pub fn get_terminal_provider() -> Option<TerminalConfig> {
#[cfg(not(any(windows, target_os = "wasm32")))]
pub fn get_terminal_provider() -> Option<TerminalConfig> {
- use crate::env::{binary_exists, env_var_is_set};
+ use helix_stdx::env::{binary_exists, env_var_is_set};
if env_var_is_set("TMUX") && binary_exists("tmux") {
return Some(TerminalConfig {
diff --git a/helix-view/src/env.rs b/helix-view/src/env.rs
deleted file mode 100644
index c68cc609..00000000
--- a/helix-view/src/env.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-pub fn binary_exists(binary_name: &str) -> bool {
- which::which(binary_name).is_ok()
-}
-
-#[cfg(not(windows))]
-pub fn env_var_is_set(env_var_name: &str) -> bool {
- std::env::var_os(env_var_name).is_some()
-}
diff --git a/helix-view/src/lib.rs b/helix-view/src/lib.rs
index 82827b5d..14b6e1ce 100644
--- a/helix-view/src/lib.rs
+++ b/helix-view/src/lib.rs
@@ -5,7 +5,6 @@ pub mod base64;
pub mod clipboard;
pub mod document;
pub mod editor;
-pub mod env;
pub mod events;
pub mod graphics;
pub mod gutter;