From 522a53af68882b344d03ae2bedf769df58b51b03 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Fri, 4 Feb 2022 10:30:21 -0500 Subject: [PATCH] Add support for quick completions (#927) --- Cargo.lock | 2 +- Cargo.toml | 1 + crates/nu-cli/Cargo.toml | 1 + crates/nu-protocol/src/config.rs | 9 +++++++++ src/repl.rs | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 68491382d5..7e23f9b623 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3277,7 +3277,7 @@ dependencies = [ [[package]] name = "reedline" version = "0.2.0" -source = "git+https://github.com/nushell/reedline?branch=main#375c779e360cd368bb75e583986eec856853bbf2" +source = "git+https://github.com/nushell/reedline?branch=main#e4cec995262fc85fab3e08cad267e28a3da60460" dependencies = [ "chrono", "crossterm", diff --git a/Cargo.toml b/Cargo.toml index 2c907d1e08..21b3be0b39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ members = [ [dependencies] reedline = { git = "https://github.com/nushell/reedline", branch = "main" } + crossterm = "0.22.*" nu-cli = { path="./crates/nu-cli" } nu-command = { path="./crates/nu-command" } diff --git a/crates/nu-cli/Cargo.toml b/crates/nu-cli/Cargo.toml index 99e55ee6ee..ede438bc9d 100644 --- a/crates/nu-cli/Cargo.toml +++ b/crates/nu-cli/Cargo.toml @@ -15,5 +15,6 @@ nu-color-config = { path = "../nu-color-config" } miette = { version = "3.0.0", features = ["fancy"] } thiserror = "1.0.29" reedline = { git = "https://github.com/nushell/reedline", branch = "main" } + log = "0.4" is_executable = "1.0.1" diff --git a/crates/nu-protocol/src/config.rs b/crates/nu-protocol/src/config.rs index 994cdd4fa3..471ca0b77c 100644 --- a/crates/nu-protocol/src/config.rs +++ b/crates/nu-protocol/src/config.rs @@ -59,6 +59,7 @@ pub struct Config { pub float_precision: i64, pub filesize_format: String, pub use_ansi_coloring: bool, + pub quick_completions: bool, pub env_conversions: HashMap, pub edit_mode: String, pub max_history_size: i64, @@ -81,6 +82,7 @@ impl Default for Config { float_precision: 4, filesize_format: "auto".into(), use_ansi_coloring: true, + quick_completions: false, env_conversions: HashMap::new(), // TODO: Add default conversoins edit_mode: "emacs".into(), max_history_size: 1000, @@ -185,6 +187,13 @@ impl Value { eprintln!("$config.use_ansi_coloring is not a bool") } } + "quick_completions" => { + if let Ok(b) = value.as_bool() { + config.quick_completions = b; + } else { + eprintln!("$config.quick_completions is not a bool") + } + } "filesize_format" => { if let Ok(v) = value.as_string() { config.filesize_format = v.to_lowercase(); diff --git a/src/repl.rs b/src/repl.rs index 5080c55d9f..ccd4069266 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -107,6 +107,7 @@ pub(crate) fn evaluate(engine_state: &mut EngineState) -> Result<()> { engine_state: engine_state.clone(), })) .with_completer(Box::new(NuCompleter::new(engine_state.clone()))) + .with_quick_completions(config.quick_completions) .with_ansi_colors(config.use_ansi_coloring); line_editor = add_completion_menu(line_editor, &config);