summaryrefslogtreecommitdiff
path: root/mms-keyboard.org
diff options
context:
space:
mode:
authormms <michal@sapka.me>2024-01-19 15:22:13 +0100
committermms <michal@sapka.me>2024-01-19 15:22:13 +0100
commit9ab57ee255a03b86ed7303aa94959e3b104e1719 (patch)
tree926293dc6d9460f1eab12231573b71abc8d5ac4e /mms-keyboard.org
feat: extract into dedicated repo
Diffstat (limited to 'mms-keyboard.org')
-rw-r--r--mms-keyboard.org134
1 files changed, 134 insertions, 0 deletions
diff --git a/mms-keyboard.org b/mms-keyboard.org
new file mode 100644
index 0000000..1d0e9a6
--- /dev/null
+++ b/mms-keyboard.org
@@ -0,0 +1,134 @@
+#+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)
+ :config
+ (evil-mode 1))
+#+END_SRC
+
+* 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