dotfiles/emacs-lisp/vterm.org
Magic_RB 9bf5aa7a27
Even more koy stuff
Signed-off-by: Magic_RB <magic_rb@redalder.org>
2021-11-25 21:47:24 +01:00

1.8 KiB

Vterm

Emacs-libvterm (vterm) is fully-fledged terminal emulator inside GNU Emacs based on libvterm, a C library. As a result of using compiled code (instead of elisp), emacs-libvterm is fully capable, fast, and it can seamlessly handle large outputs.

Vterm is "evilified" by Evil Collection.

  (use-package vterm
    :straight t
    :init

We first have to define a new minor mode, magic_rb-koy-vterm-mode, then hook it onto the existing vterm-mode

  (define-minor-mode magic_rb-koy-vterm-mode
    "Enable koy compatibility for vterm."
    :lighter " koy"
    :keymap (make-sparse-keymap)
    (evil-normalize-keymaps))
  (add-hook 'vterm-mode-hook 'magic_rb-koy-vterm-mode)

Then we actually populate the keymap using general.el.

  :after (general)
  :general
  (:states '(motion normal visual)
           :predicate 'magic_rb-koy-compat-p
           :keymaps 'magic_rb-koy-vterm-mode-map
           "t" 'evil-backward-char
           "r" 'evil-previous-visual-line
           "n" 'evil-next-visual-line
           "s" 'evil-forward-char
           "h" 'evil-find-char-to
           "j" 'evil-replace
           "k" 'evil-search-next
           "l" 'evil-substitute)
  (:states '(insert)
           :predicate 'magic_rb-koy-compat-p
           :keymaps 'magic_rb-koy-vterm-mode-map
           "j" (general-key-dispatch 'self-insert-command
                                     :timeout 0.25
                                     "j" 'evil-normal-state)))