-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
201 lines (151 loc) · 5.23 KB
/
init.el
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
;;; init.el --- Config for stand alone magit -*- lexical-binding: t; -*-
;;; Commentary:
;; This serves as the config associated with a
;; emacs-as-a-git-client
;;; Code:
;; Supports only 26+
(when (version< emacs-version "26")
(error "This version of Emacs is not supported"))
(setq user-init-file (or load-file-name (buffer-file-name)))
(setq user-emacs-directory (file-name-directory user-init-file))
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq gc-cons-threshold (* 800 1024))
;; Bootstrap straight
(setq package-enable-at-startup nil)
(eval-and-compile
(defvar bootstrap-version 5)
(defvar bootstrap-file (concat user-emacs-directory "straight/repos/straight.el/bootstrap.el")))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(defconst straight-cache-autoloads t)
(defconst straight-check-for-modifications 'live)
(require 'straight bootstrap-file t)
;; Setup basic packages
(straight-use-package 'dash)
(straight-use-package 'f)
(straight-use-package 's)
(straight-use-package 'noflet)
(straight-use-package 'memoize)
(straight-use-package 'general)
(straight-use-package 'doom-modeline)
(straight-use-package 'doom-themes)
(straight-use-package 'hydra)
(straight-use-package 'evil)
(straight-use-package 'evil-collection)
(straight-use-package 'magit)
(straight-use-package 'evil-magit)
(straight-use-package 'git-timemachine)
(straight-use-package 'pretty-hydra)
(straight-use-package 'which-key)
(straight-use-package 'ivy)
(straight-use-package 'counsel)
(straight-use-package 'swiper)
(straight-use-package 'bind-map)
(straight-use-package 'git-gutter-fringe)
(require 'recentf)
(require 'dash)
(require 'general)
(require 'f)
(require 's)
(require 'menu-bar)
(require 'tool-bar)
(require 'scroll-bar)
(require 'doom-modeline)
(require 'doom-themes)
(require 'hydra)
(require 'evil)
(require 'evil-collection)
(require 'magit)
(require 'evil-magit)
(require 'git-timemachine)
(require 'which-key)
(require 'pretty-hydra)
(require 'ivy)
(require 'swiper)
(require 'counsel)
(require 'git-gutter-fringe)
;; Setup basic stuff
(setq inhibit-splash-screen t)
(setq inhibit-startup-screen t)
(defun magito/init ()
"Initialise."
(toggle-frame-maximized))
(defalias #'yes-or-no-p #'y-or-n-p)
;; Scroll smoothly.
(setq scroll-preserve-screen-position t)
(setq scroll-margin 0)
(setq scroll-conservatively 101)
;; Instantly display current keystrokes in mini buffer
(setq echo-keystrokes 0.02)
;; Clean up visuals
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
;; Git gutter setup
(setq-default fringes-outside-margins t)
(define-fringe-bitmap 'git-gutter-fr:added [224]
nil nil '(center repeated))
(define-fringe-bitmap 'git-gutter-fr:modified [224]
nil nil '(center repeated))
(define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240]
nil nil 'bottom)
(add-hook 'prog-mode-hook #'git-gutter-mode)
;; Setup themes
(load-theme 'doom-nord t)
(general-setq doom-modeline-icon nil)
(doom-modeline-mode 1)
;; The meat and potatoes
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(evil-mode +1)
(which-key-mode)
(setq evil-collection-mode-list '(git-timemachine help info))
(evil-collection-init)
(general-setq magit-log-section-commit-count 0)
(general-setq magit-diff-refine-hunk t)
(general-setq magit-section-visibility-indicator nil)
(general-setq magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
(magit-status-setup-buffer default-directory)
;; Timemachine
(pretty-hydra-define magito/timemachine
(:title "Hot Git Time Machine" :pre (unless (bound-and-true-p git-timemachine-mode) (call-interactively 'git-timemachine)) :post (when (bound-and-true-p git-timemachine-mode) (git-timemachine-quit)) :foreign-keys run :quit-key "q")
("Goto"
(("p" git-timemachine-show-previous-revision "previous commit")
("n" git-timemachine-show-next-revision "next commit")
("c" git-timemachine-show-current-revision "current commit")
("g" git-timemachine-show-nth-revision "nth commit"))
"Misc"
(("Y" git-timemachine-kill-revision "copy hash"))))
;; Base bindings
(pretty-hydra-define magito/base
(:title "Magito" :foreign-keys run :quit-key "C-g")
("General"
(("SPC" counsel-M-x "M-x" :exit t)
("TAB" evil-switch-to-windows-last-buffer "last buffer"))
"File/Project"
(("f" find-file "find file" :exit t))
"Git"
(("t" magito/timemachine/body "time machine" :exit t)
("s" magit-status "status" :exit t))))
(general-define-key :states '(normal motion visual)
"SPC" 'magito/base/body
"/" 'swiper)
(general-define-key :keymaps 'magit-status-mode-map :states 'normal
"SPC" 'magito/base/body
"q" 'kill-emacs)
(general-def ivy-minibuffer-map
"C-j" #'ivy-next-line
"C-k" #'ivy-previous-line)
(add-hook 'emacs-startup-hook #'magito/init)
;; Extend this with personal config, if it exists
(-when-let* ((personal-config "~/.magito-config.el")
(config-exists-p (f-exists-p personal-config)))
(load-file personal-config))
;;; init.el ends here