summaryrefslogtreecommitdiff
path: root/mms-keyboard.org
blob: 17205b40cb86c389f04c20f0f3756a4b8e8d5100 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#+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 0))
#+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


* Xah Lee Flykeys

#+begin_src emacs-lisp
  (use-package xah-fly-keys
    :config
    (xah-fly-keys-set-layout "qwerty")
    (xah-fly-keys 1)

    (define-key xah-fly-command-map (kbd "SPC i o") 'consult-bookmark)
    (define-key xah-fly-command-map (kbd "SPC i f") 'consult-find)
    (define-key xah-fly-command-map (kbd "SPC i F") 'find-file)
    (define-key xah-fly-command-map (kbd "SPC i g") 'consult-ripgrep)
(load-file "~/.emacs.d/ext/xah-fk-org.el")

  )

#+end_src