about summary refs log tree commit diff
path: root/emacs.d/wpc/packages/wpc-keybindings.el
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2018-04-25T17·26-0400
committerWilliam Carroll <wpcarro@gmail.com>2018-07-19T16·00-0400
commit3c8e6f0cc5eac51e369b8ffbd0441366cdc6da40 (patch)
treee1c98f5b22dd258e4ae331c0591e0527fe5233a1 /emacs.d/wpc/packages/wpc-keybindings.el
parent56a7b9fa41c6edbb960686ccffb7a8949d242eab (diff)
Support updated emacs
Finally ported my up-to-date emacs configuration here. I was putting
this off for a long while, unsure of how to handle all of the work. All
it took was my laptop being fried to force me to do this. So... voila!
Diffstat (limited to 'emacs.d/wpc/packages/wpc-keybindings.el')
-rw-r--r--emacs.d/wpc/packages/wpc-keybindings.el131
1 files changed, 131 insertions, 0 deletions
diff --git a/emacs.d/wpc/packages/wpc-keybindings.el b/emacs.d/wpc/packages/wpc-keybindings.el
new file mode 100644
index 000000000000..0e74ce68bacb
--- /dev/null
+++ b/emacs.d/wpc/packages/wpc-keybindings.el
@@ -0,0 +1,131 @@
+;;; keybindings.el --- My Evil preferences -*- lexical-binding: t -*-
+;; Author: William Carroll <wpcarro@gmail.com>
+
+;;; Commentary:
+;; This module hosts my Evil preferences
+
+;;; Code:
+
+(quelpa
+ '(general
+   :repo "noctuid/general.el"
+   :fetcher github))
+(general-evil-setup t)
+
+;; vim...
+(use-package evil
+  :general
+  (m
+   "RET" 'evil-goto-line
+   "H"   'evil-first-non-blank
+   "L"   'evil-end-of-line
+   "-"   'dired-jump
+   "sl"  'wpc/evil-window-vsplit-right
+   "sh"  'evil-window-vsplit
+   "sk"  'evil-window-split
+   "sj"  'wpc/evil-window-split-down
+   "sj"  'wpc/evil-window-split-down)
+  (general-unbind m "M-." "C-p")
+  (general-unbind n "s" "M-.")
+  (general-unbind i "C-d" "C-a" "C-e" "C-n" "C-p" "C-k")
+  (evil-ex-map
+   "M-p" 'previous-complete-history-element
+   "M-n" 'next-complete-history-element)
+  :init
+  (setq evil-want-integration nil)
+  :config
+  (setq evil-symbol-word-search t)
+  (evil-mode 1))
+
+;; evil keybindings
+(use-package evil-collection
+  :after evil
+  :config
+  (evil-collection-init))
+
+;; expose a leader key
+(use-package evil-leader
+  :after (evil counsel)
+  :config
+  (global-evil-leader-mode)
+  (evil-leader/set-leader "<SPC>")
+  ;; global
+  (evil-leader/set-key
+    "i"  #'counsel-semantic-or-imenu
+    "j"  #'jump-to-register
+    "h"  #'help
+    "a"  #'wpc/toggle-terminal
+    "p"  #'counsel-git-grep
+    "P"  #'counsel-git-grep
+    "f"  #'wpc/find-file
+    "N"  #'smerge-next
+    "P"  #'smerge-prev
+    "s"  #'slack-send-code-snippet
+    "S"  #'slack-select-unread-rooms
+    "b"  #'ivy-switch-buffer
+    "gs" #'magit-status
+    "es" #'wpc/create-snippet
+    "ev" #'wpc/edit-init-el
+    "B"  #'magit-blame
+    "w"  #'save-buffer
+    "x"  #'evil-save-and-close
+    "W"  #'save-all-buffers
+    "r"  #'wpc/evil-replace-under-point
+    ))
+
+;; create comments easily
+(use-package evil-commentary
+  :after (evil)
+  :config
+  (evil-commentary-mode))
+
+;; evil surround
+(use-package evil-surround
+  :after (evil)
+  :config
+  (global-evil-surround-mode 1))
+
+;; Custom minor mode that ensures that my kbds are available no matter which major
+;; or minor modes are active.
+(add-hook 'after-load-functions #'ensure-william-carroll-kbds)
+
+(defun ensure-william-carroll-kbds (_ignore)
+  "Try to ensure that my keybindings retain priority over other minor modes."
+  (unless (eq (caar minor-mode-map-alist) 'wpc/kbds-minor-mode)
+    (let ((mykbds (assq 'wpc/kbds-minor-mode minor-mode-map-alist)))
+      (assq-delete-all 'wpc/kbds-minor-mode minor-mode-map-alist)
+      (add-to-list 'minor-mode-map-alist mykbds))))
+
+(defvar wpc/kbds
+  (let ((map (make-sparse-keymap)))
+    (bind-keys :map map
+               ("M-q" . delete-window)
+               ("C-x C-;" . comment-or-uncomment-region)
+               ("C-x h" . help)
+               ("<s-return>" . toggle-frame-fullscreen)
+               ("<down-mouse-1>" . ffap-other-window)
+               ("M-h"  . wpc/tmux-emacs-windmove-left)
+               ("M-l"  . wpc/tmux-emacs-windmove-right)
+               ("M-k"  . wpc/tmux-emacs-windmove-up)
+               ("M-j"  . wpc/tmux-emacs-windmove-down)
+               ("M--"  . split-window-below)
+               ("M-\\" . split-window-right)
+               ("M-q"  . delete-window))
+    map)
+  "William Carroll's keybindings that should have the highest precedence.")
+
+(define-minor-mode wpc/kbds-minor-mode
+  "A minor mode so that my key settings override annoying major modes."
+  :init-value t
+  :lighter " wpc/kbds"
+  :keymap wpc/kbds)
+
+;; allow jk to escape
+(use-package key-chord
+  :after (evil)
+  :config
+  (key-chord-mode 1)
+  (key-chord-define evil-insert-state-map "jk" 'evil-normal-state))
+
+(provide 'wpc-keybindings)
+;;; wpc-keybindings.el ends here