use counsel-recentf instead of ivy-recentf
[dotemacs] / lisp / my-keys.el
1 ;;; -*- lexical-binding: t -*-
2
3 ;; Disable suspend-frame, it's annoying
4 (global-set-key (kbd "C-z") nil)
5 (global-set-key (kbd "C-x C-z") nil)
6
7 ;; General commands
8 (global-set-key (kbd "M-x") 'counsel-M-x)
9
10 ;; Search
11 (global-set-key (kbd "C-s") 'swiper)
12 (global-set-key (kbd "C-r") 'ivy-resume)
13
14 ;; Files/buffers
15 (global-set-key (kbd "C-x C-f") 'counsel-find-file)
16 (global-set-key (kbd "C-x f") 'counsel-git)
17 (global-set-key (kbd "C-x g") 'counsel-git-grep)
18 (global-set-key (kbd "C-x c") 'my/kill-buffers-not-in-frame)
19 (global-set-key (kbd "C-x C-b") 'ibuffer)
20 (global-set-key (kbd "C-x C-r") 'counsel-recentf)
21 (global-set-key (kbd "C-x t") 'my/find-prod-or-test-file)
22 (global-set-key (kbd "C-c g d") 'git-gutter:popup-hunk)
23 (global-set-key (kbd "C-c g p") 'git-gutter:previous-hunk)
24 (global-set-key (kbd "C-c g n") 'git-gutter:next-hunk)
25 (global-set-key (kbd "C-c g r") 'git-gutter:revert-hunk)
26
27 ;; Windows/frames
28 (global-set-key (kbd "C-x o") 'ace-window)
29 (global-set-key (kbd "C-x 9") 'my/window-resize-mode)
30 (global-set-key (kbd "<C-up>") 'windmove-up)
31 (global-set-key (kbd "<C-down>") 'windmove-down)
32 (global-set-key (kbd "<C-left>") 'windmove-left)
33 (global-set-key (kbd "<C-right>") 'windmove-right)
34
35 ;; Movement
36 (global-set-key (kbd "M-g f") 'avy-goto-char-in-line)
37 (global-set-key (kbd "M-g g") 'avy-goto-line)
38 (global-set-key (kbd "M-g M-g") 'avy-goto-line)
39 (global-set-key (kbd "M-g j") 'avy-goto-word-1)
40
41 ;; Text formatting
42 (global-set-key (kbd "M-/") 'hippie-expand)
43 (global-set-key (kbd "M-;") 'my/comment-dwim)
44 (global-set-key (kbd "M-i") 'change-inner)
45 (global-set-key (kbd "C-o") 'my/open-line-above)
46 (global-set-key (kbd "M-o") 'my/open-line-below)
47 (global-set-key (kbd "C-c c") 'my/copy-line)
48 (global-set-key (kbd "C-c d") 'my/duplicate-line)
49
50 ;; Marking
51 (global-set-key (kbd "C-=") 'er/expand-region)
52 (global-set-key (kbd "C-c l") 'mc/edit-lines)
53 (global-set-key (kbd "C-c m") 'mc/mark-more-like-this-extended)
54
55 ;; Killing and deleting
56 (global-set-key (kbd "C-y") 'my/yank)
57 (global-set-key (kbd "M-y") 'counsel-yank-pop)
58 (global-set-key (kbd "M-z") 'zap-up-to-char)
59 (global-set-key (kbd "C-c k") 'kill-whole-line)
60 (global-set-key (kbd "C-c s") 'my/substitute-line)
61
62 ;; Mode switching
63 (global-set-key (kbd "C-x C-j") 'direx-project:jump-to-project-root-other-window)
64 (global-set-key (kbd "C-c g s") 'magit-status)
65 (global-set-key (kbd "C-c g g") 'magit-dispatch-popup)
66 (global-set-key (kbd "C-c g f") 'magit-file-popup)
67 (global-set-key (kbd "<f8>") 'flyspell-mode)
68 (global-set-key (kbd "<f9>") 'whitespace-mode)
69 (global-set-key (kbd "<f10>") 'toggle-truncate-lines)
70
71
72 (defun my/window-resize-mode ()
73 (interactive)
74 (message "Resize window with the arrow keys")
75 (let ((keymap (make-sparse-keymap)))
76 (define-key keymap [up] #'enlarge-window)
77 (define-key keymap [down] #'shrink-window)
78 (define-key keymap [left] #'shrink-window-horizontally)
79 (define-key keymap [right] #'enlarge-window-horizontally)
80 (set-transient-map keymap t)))