Skip to content

Commit dfbd980

Browse files
authored
Add send: vichangemode to reedline config (#16327)
# Description Allows custom bindings (non-chord) to send a `edit_mode: vi` mode change via the new `ReedlineEvent::ViChangeMode` Takes nushell/reedline#932 # User-Facing Changes You can now set bindings which change the Vi mode. (This still has the same rules for defining the key-combination: Only modifiers and single keys are supported) To do so send a `vichangemode` event with the `mode` field to set `normal`, `insert`, or `visual` ```nushell $env.config.keybindings ++= [{ name: modechangetest modifier: control keycode: "char_[" mode: [vi_normal, vi_insert] event: {send: vichangemode, mode: normal} }] ```
1 parent 2c9f6ac commit dfbd980

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Cargo.lock

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ bench = false
342342
# To use a development version of a dependency please use a global override here
343343
# changing versions in each sub-crate of the workspace is tedious
344344
[patch.crates-io]
345-
# reedline = { git = "https://github.com/nushell/reedline", branch = "main" }
345+
reedline = { git = "https://github.com/nushell/reedline", branch = "main" }
346346
# nu-ansi-term = {git = "https://github.com/nushell/nu-ansi-term.git", branch = "main"}
347347

348348
# Run all benchmarks with `cargo bench`

crates/nu-cli/src/reedline_config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,10 @@ fn event_from_record(
10471047
ReedlineEvent::ExecuteHostCommand(cmd.to_expanded_string("", config))
10481048
}
10491049
"openeditor" => ReedlineEvent::OpenEditor,
1050+
"vichangemode" => {
1051+
let mode = extract_value("mode", record, span)?;
1052+
ReedlineEvent::ViChangeMode(mode.as_str()?.to_owned())
1053+
}
10501054
str => {
10511055
return Err(ShellError::InvalidValue {
10521056
valid: "a reedline event".into(),

0 commit comments

Comments
 (0)