;;; init-evil.el --- VIM dentro de emacs -*- lexical-binding: t -*- ;; Author: kj ;; URL: https://git.kj2.me/kj/confi-emacs-actual ;;; Commentary: ;;; Code: (use-package evil :defer t :straight t :hook (after-init . evil-mode) :config ;; Configuraciones básicas (setq evil-default-state 'emacs) ;; Modo por defecto en emacs (setq evil-emacs-state-cursor 'bar) ;; Cursor de emacs state en bar (evil-set-leader 'motion (kbd "SPC")) ;; Leader key ;; Habilitar atajos de de tecla de emacs en insert state (setq evil-insert-state-map (make-sparse-keymap)) (evil-define-key 'insert 'global (kbd "") 'evil-normal-state) ;; Variales locales (setq all-states '(normal insert visual replace operator motion emacs)) (setq vim-states '(normal insert visual replace operator motion)) (evil-define-key all-states 'global (kbd "C-z") 'evil-undo) (evil-define-key vim-states 'global (kbd "C-'") 'evil-emacs-state) (evil-define-key '(emacs) 'global (kbd "C-'") 'evil-normal-state) ;; Navegación entre frames (evil-define-key 'motion 'global (kbd "wh") 'windmove-left) (evil-define-key 'motion 'global (kbd "wj") 'windmove-down) (evil-define-key 'motion 'global (kbd "wk") 'windmove-up) (evil-define-key 'motion 'global (kbd "wl") 'windmove-right) ;; Atajos con leader key para frames (evil-define-key 'motion 'global (kbd "0") 'delete-window) (evil-define-key 'motion 'global (kbd "1") 'delete-other-windows) (evil-define-key 'motion 'global (kbd "2") 'split-window-below) (evil-define-key 'motion 'global (kbd "3") 'split-window-right) (evil-define-key 'motion 'global (kbd "k") 'kill-buffer) (evil-define-key 'motion 'global (kbd "wu") 'winner-undo) (evil-define-key 'motion 'global (kbd "wr") 'winner-redo) ;; Cambios de modos (evil-define-key 'normal 'global (kbd "mh") 'html-mode) (evil-define-key 'normal 'global (kbd "mj") 'js-mode) (evil-define-key 'normal 'global (kbd "mp") 'php-mode) (evil-define-key 'normal 'global (kbd "mr") 'rust-mode) (evil-define-key 'normal 'global (kbd "mw") 'web-mode) ;; Otros atajos (evil-define-key 'motion 'global (kbd "b") 'ivy-switch-buffer) (evil-define-key 'motion 'global (kbd "p") 'counsel-projectile) (evil-define-key 'motion 'global (kbd "cp") 'projectile-switch-project) (evil-define-key 'motion 'global (kbd "ff") 'counsel-find-file) ;; Iniciar en normal state si es un lenguaje de programación (evil-set-initial-state 'prog-mode 'normal) ) (provide 'init-evil) ;;; init-evil.el ends here