From 5c1bbc9383ba1d705c14305f2d769222b04c7195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sun, 17 Sep 2023 17:21:24 +0200 Subject: [PATCH] Add zsh-vi-mode --- nvim/spell/ltex.dictionary.en-GB.txt | 3 + zsh/.zshrc | 107 ++++++++++++++------------- zsh/zsh-vi-mode | 1 + 3 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 nvim/spell/ltex.dictionary.en-GB.txt create mode 160000 zsh/zsh-vi-mode diff --git a/nvim/spell/ltex.dictionary.en-GB.txt b/nvim/spell/ltex.dictionary.en-GB.txt new file mode 100644 index 0000000..f2613f1 --- /dev/null +++ b/nvim/spell/ltex.dictionary.en-GB.txt @@ -0,0 +1,3 @@ +logits +logits +OpenSwarm diff --git a/zsh/.zshrc b/zsh/.zshrc index 8c05d80..5f62286 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -22,35 +22,8 @@ setopt autocd typeset -g -A key # Use vi-mode -bindkey -v -bindkey jj vi-cmd-mode - -key[Home]="${terminfo[khome]}" -key[End]="${terminfo[kend]}" -key[Insert]="${terminfo[kich1]}" -key[Backspace]="${terminfo[kbs]}" -key[Delete]="${terminfo[kdch1]}" -key[Up]="${terminfo[kcuu1]}" -key[Down]="${terminfo[kcud1]}" -key[Left]="${terminfo[kcub1]}" -key[Right]="${terminfo[kcuf1]}" -key[PageUp]="${terminfo[kpp]}" -key[PageDown]="${terminfo[knp]}" -key[Shift-Tab]="${terminfo[kcbt]}" - -# setup key accordingly -[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line -[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line -[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode -[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char -[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char -[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history -[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history -[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char -[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char -[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history -[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history -[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete +source ${XDG_CONFIG_HOME}/zsh/zsh-vi-mode/zsh-vi-mode.plugin.zsh +ZVM_VI_INSERT_ESCAPE_BINDKEY=jj # Finally, make sure the terminal is in application mode, when zle is # active. Only then are the values from $terminfo valid. @@ -62,12 +35,59 @@ if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop fi -autoload -Uz up-line-or-beginning-search down-line-or-beginning-search -zle -N up-line-or-beginning-search -zle -N down-line-or-beginning-search +function zvm_after_init() { + key[Home]="${terminfo[khome]}" + key[End]="${terminfo[kend]}" + key[Insert]="${terminfo[kich1]}" + key[Backspace]="${terminfo[kbs]}" + key[Delete]="${terminfo[kdch1]}" + key[Up]="${terminfo[kcuu1]}" + key[Down]="${terminfo[kcud1]}" + key[Left]="${terminfo[kcub1]}" + key[Right]="${terminfo[kcuf1]}" + key[PageUp]="${terminfo[kpp]}" + key[PageDown]="${terminfo[knp]}" + key[Shift-Tab]="${terminfo[kcbt]}" + + # setup key accordingly + [[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line + [[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line + [[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode + [[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char + [[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char + [[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history + [[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history + [[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char + [[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char + [[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history + [[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history + [[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete + + autoload -Uz up-line-or-beginning-search down-line-or-beginning-search + zle -N up-line-or-beginning-search + zle -N down-line-or-beginning-search + [[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search + [[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search + + + if [ -f "/usr/share/doc/pkgfile/command-not-found.zsh" ]; then + source /usr/share/doc/pkgfile/command-not-found.zsh + fi + + #FZF + if [ -f "/usr/share/doc/fzf/examples/key-bindings.zsh" ]; then + source /usr/share/doc/fzf/examples/key-bindings.zsh + source /usr/share/doc/fzf/examples/completion.zsh + elif [ -f "/usr/share/fzf/key-bindings.zsh" ]; then + source /usr/share/fzf/key-bindings.zsh + source /usr/share/fzf/completion.zsh + fi + + if [ -f "/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" ]; then + source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh + fi +} -[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search -[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' @@ -78,25 +98,6 @@ autoload -Uz compinit compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION" -if [ -f "/usr/share/doc/pkgfile/command-not-found.zsh" ]; then - source /usr/share/doc/pkgfile/command-not-found.zsh -fi - -#FZF -if [ -f "/usr/share/doc/fzf/examples/key-bindings.zsh" ]; then - source /usr/share/doc/fzf/examples/key-bindings.zsh - source /usr/share/doc/fzf/examples/completion.zsh -elif [ -f "/usr/share/fzf/key-bindings.zsh" ]; then - source /usr/share/fzf/key-bindings.zsh - source /usr/share/fzf/completion.zsh -fi - -# Autosuggestions -if [ -f "/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" ]; then - source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh -fi - - export HISTFILE="$XDG_STATE_HOME"/zsh/history export HISTSIZE=10000000 export SAVEHIST=10000000 diff --git a/zsh/zsh-vi-mode b/zsh/zsh-vi-mode new file mode 160000 index 0000000..1f28e18 --- /dev/null +++ b/zsh/zsh-vi-mode @@ -0,0 +1 @@ +Subproject commit 1f28e1886dc8e49f41b817634d5c7695b6abb145