mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 18:03:51 +01:00
Add support for quick completions (#927)
This commit is contained in:
parent
1a246d141e
commit
522a53af68
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -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",
|
||||
|
@ -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" }
|
||||
|
@ -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"
|
||||
|
@ -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<String, EnvConversion>,
|
||||
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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user