瀏覽代碼

feat(zsh): use improved vi mode

Joe 7 月之前
父節點
當前提交
e124b6249f
共有 2 個文件被更改,包括 30 次插入24 次删除
  1. 4 2
      .config/brew/Brewfile
  2. 26 22
      .config/zsh/.zshrc

+ 4 - 2
.config/brew/Brewfile

@@ -32,8 +32,6 @@ brew "docker"
 brew "dtc"
 # Simple, fast and user-friendly alternative to find
 brew "fd"
-# Interpreted, interactive, object-oriented programming language
-brew "python@3.13"
 # C library SSHv1/SSHv2 client and server protocols
 brew "libssh"
 # Low-level access to audio, keyboard, mouse, joystick, and graphics
@@ -58,6 +56,8 @@ brew "go"
 brew "gopls"
 # Perfect hash function generator
 brew "gperf"
+# Interpreted, interactive, object-oriented programming language
+brew "python@3.13"
 # GitHub Markdown previewer
 brew "grip"
 # CLI for Heroku
@@ -146,6 +146,8 @@ brew "yaml-language-server"
 brew "zsh-autosuggestions"
 # Fish shell like syntax highlighting for zsh
 brew "zsh-syntax-highlighting"
+# Better and friendly vi(vim) mode plugin for ZSH
+brew "zsh-vi-mode"
 # The easiest way to access your cloud.
 brew "common-fate/granted/granted"
 # Simple hotkey-daemon for macOS.

+ 26 - 22
.config/zsh/.zshrc

@@ -14,6 +14,12 @@ if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
     setopt COMBINING_CHARS
 fi
 
+# Use `nvim` as editor, preferring current instance if nested
+export EDITOR="${DOTFILES_DIR}/.scripts/nvim_editor.zsh"
+
+# Fixes plugin keymap conflicts
+export ZVM_INIT_MODE=sourcing
+
 ################################################################################
 # History
 ################################################################################
@@ -135,11 +141,28 @@ if command -v lazydocker &>/dev/null; then;
 fi;
 
 ################################################################################
-# Keybinds
+# From github.com/zsh-users:
+# * zsh-autosuggestions
+# * zsh-syntax-highlighting
+# Both can be installed through Homebrew.
 ################################################################################
+if command -v brew >> /dev/null; then
+    source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
+    source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
+    source $(brew --prefix)/opt/zsh-vi-mode/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
+fi
 
-# vi mode
-bindkey -v
+################################################################################
+# fzf
+################################################################################
+
+if command -v fzf >> /dev/null; then
+    eval "$(fzf --zsh)"
+fi
+
+################################################################################
+# Keybinds
+################################################################################
 
 # Ctrl+Y copies buffer to clipboard
 cmd_to_clip () { pbcopy <<< $BUFFER }
@@ -166,22 +189,3 @@ copy_dir_llm_style () {
 }
 zle -N copy_dir_llm_style
 bindkey '^G' copy_dir_llm_style
-
-################################################################################
-# fzf
-################################################################################
-
-if command -v fzf >> /dev/null; then
-    eval "$(fzf --zsh)"
-fi
-
-################################################################################
-# From github.com/zsh-users:
-# * zsh-autosuggestions
-# * zsh-syntax-highlighting
-# Both can be installed through Homebrew.
-################################################################################
-if command -v brew >> /dev/null; then
-    source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
-    source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
-fi