80 lines
3.5 KiB
EmacsLisp
80 lines
3.5 KiB
EmacsLisp
;;; 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:
|
|
|
|
;;; 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
|
|
(evil-set-undo-system 'undo-redo)
|
|
|
|
;; Habilitar atajos de de tecla de emacs en insert state
|
|
(setq evil-insert-state-map (make-sparse-keymap))
|
|
|
|
;; Ingresar en normal state con ESC desde insert state o desde Emacs state
|
|
(evil-define-key 'insert 'global (kbd "<escape>") 'evil-normal-state)
|
|
;; (evil-define-key 'emacs 'global (kbd "<escape>") 'evil-normal-state)
|
|
;; Cambiar Insert state por emacs state.
|
|
;; (defalias 'evil-insert-state 'evil-emacs-state)
|
|
|
|
;; Variales locales (todos los estados o solo los estados de VIM)
|
|
(setq all-states '(normal insert visual replace operator motion emacs))
|
|
(setq vim-states '(normal insert visual replace operator motion))
|
|
|
|
;; Cambiar entre modo emacs y evil (Mi pripio evil toggle)
|
|
(evil-define-key vim-states 'global (kbd "C-'") 'evil-emacs-state)
|
|
(evil-define-key 'emacs 'global (kbd "C-'") 'evil-normal-state)
|
|
|
|
;; 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
|
|
(evil-define-key vim-states 'global (kbd "C-r") 'rg)
|
|
(evil-define-key 'normal 'global (kbd "U") 'undo-redo)
|
|
|
|
;; 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
|
|
(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
|
|
|
|
;; Iniciar en normal state si es un lenguaje de programación
|
|
(evil-set-initial-state 'prog-mode 'normal)
|
|
(evil-set-initial-state 'org-mode 'normal)
|
|
(evil-set-initial-state 'dashboard-mode 'normal)
|
|
)
|
|
|
|
(provide 'init-evil)
|
|
;;; init-evil.el ends here
|