mirror of
https://github.com/nushell/nushell.git
synced 2024-12-27 01:19:25 +01:00
Merge pull request #407 from iamcodemaker/vi
WIP: add support for vi mode
This commit is contained in:
commit
729051fdd2
13
src/cli.rs
13
src/cli.rs
@ -17,7 +17,7 @@ use crate::prelude::*;
|
|||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rustyline::error::ReadlineError;
|
use rustyline::error::ReadlineError;
|
||||||
use rustyline::{self, ColorMode, Config, Editor};
|
use rustyline::{self, ColorMode, Config, Editor, config::Configurer, config::EditMode};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::{BufRead, BufReader, Write};
|
use std::io::{BufRead, BufReader, Write};
|
||||||
@ -256,6 +256,17 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
|||||||
context.shell_manager.clone(),
|
context.shell_manager.clone(),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
let edit_mode = crate::object::config::config(Span::unknown())?
|
||||||
|
.get("edit_mode")
|
||||||
|
.map(|s| match s.as_string().unwrap().as_ref() {
|
||||||
|
"vi" => EditMode::Vi,
|
||||||
|
"emacs" => EditMode::Emacs,
|
||||||
|
_ => EditMode::Emacs,
|
||||||
|
})
|
||||||
|
.unwrap_or(EditMode::Emacs);
|
||||||
|
|
||||||
|
rl.set_edit_mode(edit_mode);
|
||||||
|
|
||||||
let readline = rl.readline(&format!(
|
let readline = rl.readline(&format!(
|
||||||
"{}{}> ",
|
"{}{}> ",
|
||||||
cwd,
|
cwd,
|
||||||
|
@ -111,6 +111,7 @@ pub fn config(
|
|||||||
|
|
||||||
if result.contains_key(&key) {
|
if result.contains_key(&key) {
|
||||||
result.remove(&key);
|
result.remove(&key);
|
||||||
|
config::write_config(&result)?;
|
||||||
} else {
|
} else {
|
||||||
return Err(ShellError::string(&format!(
|
return Err(ShellError::string(&format!(
|
||||||
"{} does not exist in config",
|
"{} does not exist in config",
|
||||||
|
Loading…
Reference in New Issue
Block a user