summaryrefslogtreecommitdiffstats
path: root/atuin-client
diff options
context:
space:
mode:
authorKoichi Murase <myoga.murase@gmail.com>2024-01-16 22:35:10 +0900
committerGitHub <noreply@github.com>2024-01-16 13:35:10 +0000
commit6bff8c8e1ad3a230f3cd8f5d7078ed2af3f43463 (patch)
treefa9ca6ee52cb5c100716b764b60453d157e681d8 /atuin-client
parenta2578c4521d4615d8265744ab51a1cc4f291605e (diff)
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"
Diffstat (limited to 'atuin-client')
-rw-r--r--atuin-client/config.toml9
-rw-r--r--atuin-client/src/settings.rs30
2 files changed, 35 insertions, 4 deletions
diff --git a/atuin-client/config.toml b/atuin-client/config.toml
index 29581d1fa..24366b60e 100644
--- a/atuin-client/config.toml
+++ b/atuin-client/config.toml
@@ -126,8 +126,13 @@
enter_accept = true
-## Defaults to false. If enabled you may use 'j' and 'k' to navigate the history list and 'i' to enter Insert mode.
-# vim = false
+## Defaults to "emacs". This specifies the keymap on the startup of `atuin
+## search`. If this is set to "auto", the startup keymap mode in the Atuin
+## search is automatically selected based on the shell's keymap where the
+## keybinding is defined. If this is set to "emacs", "vim-insert", or
+## "vim-normal", the startup keymap mode in the Atuin search is forced to be
+## the specified one.
+# keymap_mode = "auto"
#[stats]
# Set commands where we should consider the subcommand for statistics. Eg, kubectl get vs just kubectl
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs
index ea01961c7..36bbd826b 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("_")