mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
move keybinding_path to nu-data (#2927)
This commit is contained in:
parent
a9441d670e
commit
ebc4694e05
6 changed files with 10 additions and 7 deletions
|
@ -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"]
|
||||
|
|
|
@ -405,14 +405,10 @@ pub struct Keybinding {
|
|||
|
||||
type Keybindings = Vec<Keybinding>;
|
||||
|
||||
pub(crate) fn keybinding_path() -> Result<std::path::PathBuf, nu_errors::ShellError> {
|
||||
nu_data::config::default_path_for(&Some(std::path::PathBuf::from("keybindings.yml")))
|
||||
}
|
||||
|
||||
pub(crate) fn load_keybindings(
|
||||
rl: &mut rustyline::Editor<crate::shell::Helper>,
|
||||
) -> 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
|
||||
|
|
3
crates/nu-data/src/keybinding.rs
Normal file
3
crates/nu-data/src/keybinding.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub fn keybinding_path() -> Result<std::path::PathBuf, nu_errors::ShellError> {
|
||||
crate::config::default_path_for(&Some(std::path::PathBuf::from("keybindings.yml")))
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -48,3 +48,6 @@ users = "0.10.0"
|
|||
|
||||
[dev-dependencies]
|
||||
nu-test-support = {version = "0.25.2", path = "../nu-test-support"}
|
||||
|
||||
[features]
|
||||
rustyline-support = []
|
||||
|
|
|
@ -47,7 +47,7 @@ pub fn nu(env: &IndexMap<String, String>, tag: impl Into<Tag>) -> Result<Value,
|
|||
|
||||
#[cfg(feature = "rustyline-support")]
|
||||
{
|
||||
let keybinding_path = crate::keybinding::keybinding_path()?;
|
||||
let keybinding_path = nu_data::keybinding::keybinding_path()?;
|
||||
nu_dict.insert_value(
|
||||
"keybinding-path",
|
||||
UntaggedValue::filepath(keybinding_path).into_value(&tag),
|
||||
|
|
Loading…
Reference in a new issue