From ebc4694e05c3cf9ec60eb584ceb7e6ea007950f5 Mon Sep 17 00:00:00 2001 From: Anders Rasmussen Date: Thu, 14 Jan 2021 04:31:47 +1100 Subject: [PATCH] move keybinding_path to nu-data (#2927) --- crates/nu-cli/Cargo.toml | 2 +- crates/nu-cli/src/keybinding.rs | 6 +----- crates/nu-data/src/keybinding.rs | 3 +++ crates/nu-data/src/lib.rs | 1 + crates/nu-engine/Cargo.toml | 3 +++ crates/nu-engine/src/evaluate/variables.rs | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 crates/nu-data/src/keybinding.rs diff --git a/crates/nu-cli/Cargo.toml b/crates/nu-cli/Cargo.toml index 058832319..1c3b81ba7 100644 --- a/crates/nu-cli/Cargo.toml +++ b/crates/nu-cli/Cargo.toml @@ -130,6 +130,6 @@ quickcheck_macros = "0.9.1" [features] clipboard-cli = ["arboard"] rich-benchmark = ["heim"] -rustyline-support = ["rustyline"] +rustyline-support = ["rustyline", "nu-engine/rustyline-support"] stable = [] trash-support = ["trash"] diff --git a/crates/nu-cli/src/keybinding.rs b/crates/nu-cli/src/keybinding.rs index f6b9f3f6f..201fcd802 100644 --- a/crates/nu-cli/src/keybinding.rs +++ b/crates/nu-cli/src/keybinding.rs @@ -405,14 +405,10 @@ pub struct Keybinding { type Keybindings = Vec; -pub(crate) fn keybinding_path() -> Result { - nu_data::config::default_path_for(&Some(std::path::PathBuf::from("keybindings.yml"))) -} - pub(crate) fn load_keybindings( rl: &mut rustyline::Editor, ) -> Result<(), nu_errors::ShellError> { - let filename = keybinding_path()?; + let filename = nu_data::keybinding::keybinding_path()?; let contents = std::fs::read_to_string(filename); // Silently fail if there is no file there diff --git a/crates/nu-data/src/keybinding.rs b/crates/nu-data/src/keybinding.rs new file mode 100644 index 000000000..9c36d463c --- /dev/null +++ b/crates/nu-data/src/keybinding.rs @@ -0,0 +1,3 @@ +pub fn keybinding_path() -> Result { + crate::config::default_path_for(&Some(std::path::PathBuf::from("keybindings.yml"))) +} diff --git a/crates/nu-data/src/lib.rs b/crates/nu-data/src/lib.rs index 809d499a6..1705e2537 100644 --- a/crates/nu-data/src/lib.rs +++ b/crates/nu-data/src/lib.rs @@ -2,6 +2,7 @@ pub mod base; pub mod command; pub mod config; pub mod dict; +pub mod keybinding; pub mod primitive; pub mod types; pub mod utils; diff --git a/crates/nu-engine/Cargo.toml b/crates/nu-engine/Cargo.toml index 172f4ba70..579c0ad1c 100644 --- a/crates/nu-engine/Cargo.toml +++ b/crates/nu-engine/Cargo.toml @@ -48,3 +48,6 @@ users = "0.10.0" [dev-dependencies] nu-test-support = {version = "0.25.2", path = "../nu-test-support"} + +[features] +rustyline-support = [] diff --git a/crates/nu-engine/src/evaluate/variables.rs b/crates/nu-engine/src/evaluate/variables.rs index 34f79e788..e9f0a1170 100644 --- a/crates/nu-engine/src/evaluate/variables.rs +++ b/crates/nu-engine/src/evaluate/variables.rs @@ -47,7 +47,7 @@ pub fn nu(env: &IndexMap, tag: impl Into) -> Result