#+TITLE: mms's Emacs Config - Keyboard configuration #+AUTHOR: MichaƂ Sapka (https://michal.sapka.me) #+STARTUP: showall indent logdoneGeneral settings #+HUGO_BASE_DIR: ~/ghq/vcs.sapka.me/michal-sapka-me/ #+HUGO_WEIGHT: 10 #+HUGO_SECTION: emacs/config #+HUGO_CATEGORIES: emacs emacs-config #+HUGO_MENU :menu "emacs-config" #+HUGO_CUSTOM_FRONT_MATTER: :abstract "My emacs config - keyboard config" #+HUGO_CUSTOM_FRONT_MATTER: :menu-abstract "evil mode, basic key bindings and misc" #+EXPORT_FILE_NAME: keyboard * Evil mode I've been using Vim for a long time so those keybindings are a must. My last attempt to use Emacs failed as I decided to learn Emacs native keybindings. While those aren't *bad*, I much prefer the classic VIM style. This time I am starting with Evil so anything I add to this config will be configured with those bindings at day 1. #+BEGIN_SRC emacs-lisp (use-package evil :elpaca t :ensure t :init (setq evil-want-keybinding nil evil-vsplit-window-right t evil-split-window-below t evil-want-C-u-scroll t) :config (evil-mode 1)) #+END_SRC #+RESULTS: : t * Which key WK adds a on-the-fly cheatsheet. #+begin_src emacs-lisp (use-package which-key :ensure t :config (which-key-mode)) #+end_src * Evil Collection Evil Collection is a ready-made package of evil mode keybings for multiple packages. You can see the full list [[https://github.com/emacs-evil/evil-collection/tree/master/modes][on Github]]. It saves me from doing /all that config/ by hand. It's also good that those bindings are kinda good actually. #+BEGIN_SRC emacs-lisp (use-package evil-collection :elpaca t :after evil :ensure t :config (evil-collection-init)) #+END_SRC * General I use General to manage keybindings. People said it's good, and I have to find a downside. All those bindings here should be to moved dedicated sections, but for now they are here. #+BEGIN_SRC emacs-lisp (use-package general :ensure t :elpaca t :config (setq general-use-package-emit-autoloads t) (general-evil-setup)) #+END_SRC I manage my packages via Elpaca. It has the amazing capability of loading the packages asynchronously, speeding up Emacs start. But this also means that order becomes a problem. I will define keybindings using =general-*= functions all over the place, and the package may not be loaded yet. To save myself the problem, just pause execution of the config until General is fully loaded. #+begin_src emacs-lisp (elpaca-wait) #+end_src * Basic keybindings I use =space= as my leader. It's a muscle memory back from when I first learned Vim. #+begin_src emacs-lisp (general-create-definer mms-leader-keys :states '(normal insert visual emacs) :keymaps 'override :prefix "SPC" ;; set leader :global-prefix "M-SPC") #+end_src I want to access my config /blazingly fast/[tm] #+begin_src emacs-lisp (mms-leader-keys "o c" '((lambda () (interactive) (find-file "~/.emacs.d/")) :wk "Open config dir")) #+end_src I also have a habit of wanting to quickly create new splits (/sigh/ windows) fast back from my Vim days. #+begin_src emacs-lisp (general-create-definer mms-split-mgt-keys :states '(normal visual) :keymaps 'override :prefix "s") (mms-split-mgt-keys ;; Window splits "s" '(evil-window-split :wk "Horizontal split window") "v" '(evil-window-vsplit :wk "Vertical split window") ;; Window motions "h" '(evil-window-left :wk "Window left") "j" '(evil-window-down :wk "Window down") "k" '(evil-window-up :wk "Window up") "l" '(evil-window-right :wk "Window right")) #+end_src And I have a few keybindings that are here for now. I'll move them to dedicated sections when I reach them. #+begin_src emacs-lisp (mms-leader-keys "c a" '(eglot-code-actions :wk "Code actions")) #+END_SRC