2022-11-28 12:23:27 +01:00
|
|
|
;;; init-evil.el --- VIM dentro de emacs -*- lexical-binding: t -*-
|
|
|
|
|
|
|
|
;; Author: kj <webmaster@outcontrol.net>
|
|
|
|
;; URL: https://git.kj2.me/kj/confi-emacs-actual
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
2023-04-14 18:39:19 +02:00
|
|
|
;; En este archivo está toda la configuración relacionada
|
|
|
|
;; con el paquete Evil.
|
|
|
|
;;
|
|
|
|
;; Evil es un paquete para Emacs, que básicamente nos
|
|
|
|
;; permite tener VIM dentro de Emacs.
|
|
|
|
|
2022-11-28 12:23:27 +01:00
|
|
|
;;; Code:
|
|
|
|
(use-package evil
|
|
|
|
:defer t
|
|
|
|
:straight t
|
|
|
|
:hook (after-init . evil-mode)
|
|
|
|
:config
|
2022-11-29 08:46:08 +01:00
|
|
|
;; 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
|
2023-01-22 03:38:30 +01:00
|
|
|
(evil-set-undo-system 'undo-redo)
|
2022-11-28 12:23:27 +01:00
|
|
|
|
2022-11-29 08:46:08 +01:00
|
|
|
;; Habilitar atajos de de tecla de emacs en insert state
|
|
|
|
(setq evil-insert-state-map (make-sparse-keymap))
|
2023-01-22 03:11:44 +01:00
|
|
|
|
|
|
|
;; Ingresar en normal state con ESC desde insert state o desde Emacs state
|
2022-11-29 08:46:08 +01:00
|
|
|
(evil-define-key 'insert 'global (kbd "<escape>") 'evil-normal-state)
|
2023-01-22 03:11:44 +01:00
|
|
|
;; (evil-define-key 'emacs 'global (kbd "<escape>") 'evil-normal-state)
|
|
|
|
;; Cambiar Insert state por emacs state.
|
|
|
|
;; (defalias 'evil-insert-state 'evil-emacs-state)
|
2022-11-28 12:23:27 +01:00
|
|
|
|
2023-01-22 03:11:44 +01:00
|
|
|
;; Variales locales (todos los estados o solo los estados de VIM)
|
2022-11-29 08:46:08 +01:00
|
|
|
(setq all-states '(normal insert visual replace operator motion emacs))
|
|
|
|
(setq vim-states '(normal insert visual replace operator motion))
|
|
|
|
|
2023-01-22 03:11:44 +01:00
|
|
|
;; Cambiar entre modo emacs y evil (Mi pripio evil toggle)
|
2022-11-29 08:46:08 +01:00
|
|
|
(evil-define-key vim-states 'global (kbd "C-'") 'evil-emacs-state)
|
2023-01-22 03:11:44 +01:00
|
|
|
(evil-define-key 'emacs 'global (kbd "C-'") 'evil-normal-state)
|
2022-11-29 08:46:08 +01:00
|
|
|
|
2023-01-22 03:38:30 +01:00
|
|
|
;; Cambiar C-z a deshacer
|
|
|
|
(evil-define-key all-states 'global (kbd "C-z") 'undo)
|
|
|
|
|
|
|
|
;; Cambiar C-r a ripgrep y U hasta hacer redo
|
2023-04-13 08:01:17 +02:00
|
|
|
(evil-define-key vim-states 'global (kbd "C-r") 'counsel-rg)
|
2023-01-22 03:38:30 +01:00
|
|
|
(evil-define-key 'normal 'global (kbd "U") 'undo-redo)
|
|
|
|
|
2023-03-24 19:53:41 +01:00
|
|
|
;; Arreglar yank-pop en normal mode
|
|
|
|
(evil-define-key 'normal 'global (kbd "M-y") 'counsel-yank-pop)
|
|
|
|
|
|
|
|
;; Re-bindear C-p y C-n a como es normalmente
|
|
|
|
(evil-define-key 'normal 'global (kbd "C-p") 'previous-line)
|
|
|
|
(evil-define-key 'normal 'global (kbd "C-n") 'next-line)
|
|
|
|
|
2022-11-29 08:46:08 +01:00
|
|
|
;; Navegación entre frames
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>wh") 'windmove-left)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>wj") 'windmove-down)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>wk") 'windmove-up)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>wl") 'windmove-right)
|
|
|
|
|
|
|
|
;; Atajos con leader key para frames
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>0") 'delete-window)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>1") 'delete-other-windows)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>2") 'split-window-below)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>3") 'split-window-right)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>k") 'kill-buffer)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>wu") 'winner-undo)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>wr") 'winner-redo)
|
|
|
|
|
|
|
|
;; Cambios de modos
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mh") 'html-mode)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mj") 'js-mode)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mp") 'php-mode)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mr") 'rust-mode)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mw") 'web-mode)
|
|
|
|
|
|
|
|
;; Otros atajos
|
2023-01-22 03:11:44 +01:00
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>b") 'ivy-switch-buffer) ;; Cambiar de buffer
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>p") 'counsel-projectile) ;; Archivos del proyecto (o abrir proyecto si no hay alguno)
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>cp") 'projectile-switch-project) ;; Cambiar proyecto
|
|
|
|
(evil-define-key 'motion 'global (kbd "<leader>ff") 'counsel-find-file) ;; Abrir archivo
|
2022-11-29 08:46:08 +01:00
|
|
|
|
2023-06-17 12:13:53 +02:00
|
|
|
;; Iniciar en normal state si es un lenguaje de programación u org-mode
|
2023-04-14 02:40:26 +02:00
|
|
|
;; (evil-set-initial-state 'prog-mode 'normal)
|
|
|
|
;; (evil-set-initial-state 'org-mode 'normal)
|
2023-06-17 12:13:53 +02:00
|
|
|
(evil-set-initial-state 'dashboard-mode 'normal)
|
2022-11-28 12:23:27 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
(provide 'init-evil)
|
|
|
|
;;; init-evil.el ends here
|