From 6bff8c8e1ad3a230f3cd8f5d7078ed2af3f43463 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 16 Jan 2024 22:35:10 +0900 Subject: feat(search): introduce keymap-dependent vim-mode (#1570) * feat(search): introduce keymap-dependent vim-mode * fix(zsh): provide widgets with specific keymaps * fix(settings): unify "vim" and "keymap_mode" --- atuin-client/src/settings.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'atuin-client/src') diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index ea01961c..36bbd826 100644 --- a/atuin-client/src/settings.rs +++ b/atuin-client/src/settings.rs @@ -143,6 +143,32 @@ pub enum WordJumpMode { Subl, } +#[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, ValueEnum)] +pub enum KeymapMode { + #[serde(rename = "emacs")] + Emacs, + + #[serde(rename = "vim-normal")] + VimNormal, + + #[serde(rename = "vim-insert")] + VimInsert, + + #[serde(rename = "auto")] + Auto, +} + +impl KeymapMode { + pub fn as_str(&self) -> &'static str { + match self { + KeymapMode::Emacs => "EMACS", + KeymapMode::VimNormal => "VIMNORMAL", + KeymapMode::VimInsert => "VIMINSERT", + KeymapMode::Auto => "AUTO", + } + } +} + #[derive(Clone, Debug, Deserialize)] pub struct Stats { #[serde(default = "Stats::common_prefix_default")] @@ -201,7 +227,7 @@ pub struct Settings { pub max_preview_height: u16, pub show_help: bool, pub exit_mode: ExitMode, - pub vim: bool, + pub keymap_mode: KeymapMode, pub word_jump_mode: WordJumpMode, pub word_chars: String, pub scroll_context_lines: usize, @@ -437,7 +463,7 @@ impl Settings { // New users will get the new default, that is more similar to what they are used to. .set_default("enter_accept", false)? .set_default("sync.records", false)? - .set_default("vim", false)? + .set_default("keymap_mode", "emacs")? .add_source( Environment::with_prefix("atuin") .prefix_separator("_") -- cgit v1.3.1