-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.el
More file actions
461 lines (372 loc) · 11.8 KB
/
init.el
File metadata and controls
461 lines (372 loc) · 11.8 KB
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
;;; rnjns_dotemacs --- Summary
;;; Commentary:
;;; This is a simplistic Emacs setup. For the last few years (2015-2021) I have been using
;;; Spacemacs and while it still works and I love the mnemonic keys and layered system
;;; it has become a slow, and I am tired of waiting for updates, breaking changes. This is
;;; an attempt to declutter. Updating the setup using what's now available in 2021.
;;; In a bind really whether to write literate configuration, choosing a simple single
;;; file for now, to avoid the clutter.
;;; Code:
;;; Packages
;;; setup where to pull packages from
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("melpa" . "http://melpa.org/packages/")))
(setq package-enable-at-startup nil)
(package-initialize)
;;; init use-package. Thanks to @irfn for pointing out use-package;
;;; it is a great addition. Lazy loading enables a faster setup and
;;; the added benefit of a clean config. If you are here, you may want to see
;;; https://github.com/irfn/emacs which is a far better emacs config
(package-install 'use-package)
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
;;; install quelpa so we can install packages directly from source
(use-package quelpa
:ensure t)
(quelpa
'(quelpa-use-package
:fetcher git
:url "https://github.com/quelpa/quelpa-use-package.git"))
(require 'quelpa-use-package)
(setq-default quelpa-build-tar-executable "/opt/homebrew/bin/gtar")
;;; Add /usr/local/bin to exec path, load env vars
(use-package exec-path-from-shell
:ensure t
:config (setq exec-path-from-shell-variables '("PATH"))
:init
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))
(use-package load-env-vars
:ensure t
:init (load-env-vars "~/.profile"))
(setq exec-path (append exec-path '("/usr/local/bin")))
;;list of packages to be installed by elpa
(use-package nerd-icons
:ensure t)
;;; Fonts and Themes
(set-face-attribute 'default nil :font "Monaco-16")
(when (member "Fira Code" (font-family-list))
(set-face-attribute 'default nil :font "Fira Code Retina-18"))
;;; too lazy to setup a list of safe themes
;;; this is dangerous, only controlled because I have a small
;;; controlled list of themes - solarized-light and material dark
(setq custom-safe-themes t)
(use-package solarized-theme
:ensure t
:defer t)
(use-package material-theme
:ensure t)
(load-theme 'material)
(use-package rainbow-delimiters
:ensure t)
(use-package all-the-icons
;; Uncomment this while setting up a new machine.
;; :config
;; (all-the-icons-install-fonts)
:ensure t)
;;; Bells and whistles
(setq ring-bell-function 'ignore )
(use-package diminish
:defer 5
:config (diminish 'org-indent-mode)
:ensure t)
;;; hints and shortcut discovery
(use-package which-key
:diminish
:ensure t
:config
(which-key-mode)
(which-key-setup-side-window-bottom)
(setq which-key-idle-delay 0.1))
;;; Helm
(use-package helm
:diminish
:init
(helm-mode t)
:bind (("M-x" . helm-M-x)
("C-x C-f" . helm-find-files)
("C-x b" . helm-mini) ;; See buffers & recent files; more useful.
("C-x r b" . helm-filtered-bookmarks)
("C-x C-r" . helm-recentf) ;; Search for recently edited files
("C-c i" . helm-imenu)
("C-h a" . helm-apropos)
("M-y" . helm-show-kill-ring)
:map helm-map
;; We can list ‘actions’ on the currently selected item by C-z.
("C-z" . helm-select-action)
("TAB" . helm-execute-persistent-action)
("<tab>" . helm-execute-persistent-action))
:config (progn
(setq helm-buffers-fuzzy-matching t)
(setq helm-recentf-fuzzy-matching t)
(setq helm-M-x-fuzzy-match t))
:ensure t)
;; need for ripgrep speed
(use-package rg
:config
(global-set-key (kbd "M-s g") 'rg)
(global-set-key (kbd "M-s d") 'rg-dwim)
:ensure t)
(use-package helm-rg
:ensure t)
;;; Dashboards and Projects
;;; to get a useful homescreen
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-banner-logo-title "oh come on!")
(setq dashboard-items '((recents . 5)
(projects . 5)
(agenda . 5)))
)
(use-package all-the-icons
:ensure t)
(use-package page-break-lines
:ensure t)
(use-package projectile
:ensure t
:diminish
:init
(projectile-mode +1)
:config
(setq projectile-project-search-path '("~/Desktop/" "~/work/"))
(setq projectile-switch-project-action 'helm-projectile)
:bind (:map projectile-mode-map
("s-p" . projectile-command-map)
("C-c p" . projectile-command-map)))
(use-package helm-projectile
:ensure t)
;;; Layout
(global-set-key (kbd "C-<f11>") 'toggle-fullscreen)
;; fullscreen post init
(add-hook 'window-setup-hook 'toggle-frame-maximized t)
;; (use-package nav
;; :commands nav-toggle nav-disable-overeager-window-splitting
;; :init
;; (bind-key "C-M-l" 'nav-toggle)
;; :ensure t)
;;; using neotree instead of nav
(use-package neotree
:init
(bind-key "C-M-l" 'neotree-toggle)
(bind-key "<f8>" 'neotree-refresh)
:config
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
:ensure t)
;;
;; (use-package nano-sidebar
;; :ensure t
;; :quelpa (nano-sidebar
;; :fetcher github
;; :repo "rougier/nano-sidebar"))
(use-package ace-window
:delight
:bind ("M-o" . ace-window)
:config (ace-window-display-mode 1)
:ensure t)
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode))
(use-package doom-themes
:ensure t
:config
(setq doom-themes-enable-bold 'nil
doom-themes-enable-italic 'nil)
(load-theme 'doom-tokyo-night t)
(doom-themes-visual-bell-config)
(doom-themes-org-config))
(use-package markdown-mode
:config
(custom-set-variables
'(markdown-command "/opt/homebrew/bin/pandoc"))
:ensure t)
;;; hide tool bar
(if window-system
(tool-bar-mode -1)
)
;;; show line numbers
(global-display-line-numbers-mode 0)
(global-set-key (kbd "s-M-l") 'nlinum-mode)
;;; Finger memory
;;; cua
(cua-mode 1)
;;; File and folder management
(setq auto-save-default nil)
(use-package super-save
:ensure t
:config
(add-to-list 'super-save-triggers 'ace-window)
(add-to-list 'super-save-hook-triggers 'find-file-hook)
(super-save-mode +1)
:diminish)
;;; Org Mode
(use-package org
:ensure t
:bind (("\C-ca" . org-agenda))
:config (progn
(setq org-todo-keywords (quote ((sequence "TODO(t)" "STARTED(s)" "WAITING(w)" "POSTPONED(p)" "|" "CANCELLED(c)" "DONE(d)"))))
(setq org-agenda-files '("~/Desktop/diary"))
(setq org-log-done 'time)
(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right)
)
:init (progn
(add-hook 'org-mode-hook 'flyspell-mode)
(add-hook 'org-mode-hook 'org-bullets-mode))
:custom
(org-archive-location "::* Completed")
(org-startup-with-inline-images t)
(org-modules '(org-crypt
org-habit
org-mouse
org-protocol
org-tempo))
(org-tag-alist '(("@research" . ?s)
("@reading" . ?r)
("@writing" . ?w)
("@spike" . ?k)
("@home" . ?h)
("@chore" . ?e)
("@meeting" . ?m)
("@notes" . ?n)
("todo" . ?0)
("@post" . ?p)))
)
(use-package org-bullets
:ensure t
:config (setq org-bullets-bullet-list '("◉" "○" "⌗" "⌘" )))
;; Org journal
(use-package org-journal
:ensure t
:bind(("\C-cjs" . org-journal-search))
:init
(setq org-journal-prefix-key "C-c j")
:config
(setq org-journal-file-header "#+TITLE: %Y-%m-%d")
(setq org-journal-dir "~/Desktop/diary")
(setq org-journal-file-format "%Y-%m-%d.org")
)
(dolist (face '((org-level-1 . 1.2)
(org-level-2 . 1.05)
(org-level-3 . 1.0)
(org-level-4 . 1.0)
(org-level-5 . 1.0)
(org-level-6 . 1.0)
(org-level-7 . 1.0)
(org-level-8 . 1.0)))
(set-face-attribute (car face) nil :weight 'regular :height (cdr face) :box nil)
)
;;; Programming
(use-package flycheck
:ensure t
:diminish
:init
(add-hook 'after-init-hook #'global-flycheck-mode)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
:hook (
(prog-mode . flycheck-mode)))
(use-package company
:ensure t
:init (global-company-mode)
:bind ("s-/" . company-complete)
:config (
progn
(bind-key [remap-completion-at-point] #'company-complete company-mode-map)
(setq company-tooltip-align-annotations t)
(setq company-dabbrev-downcase t)
(setq company-idle-delay 0)
(setq company-minimum-prefix-length 1))
:diminish company-mode)
(use-package expand-region
:ensure t
:bind ("C-=" . er/expand-region))
(use-package yaml-mode
:ensure t)
(use-package smartparens
:ensure t
:config
(setq sp-show-pair-from-inside nil)
(require 'smartparens-config)
:diminish smartparens-mode)
(use-package yasnippet
:ensure t
:diminish
:init
(yas-global-mode 1))
(use-package magit
:ensure t
:bind (
("C-c g" . magit-status))
:config (setq magit-auto-revert-mode nil))
;; flymake keys and custom faces
(global-set-key [f2] 'flymake-display-err-menu-for-current-line)
(global-set-key [f3] 'flymake-goto-prev-error)
(global-set-key [f4] 'flymake-goto-next-error)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(flymake-errline ((((class color)) (:underline "Red" :background nil))))
'(flymake-warnline ((((class color)) (:underline "Orange")))))
;;MISC
;;; revert buffers when backing file changes
(global-auto-revert-mode t)
;;; visual line mode
(global-visual-line-mode t)
;;; server
(server-start)
;;; show me the clock
(display-time-mode 1)
(setq display-time-string-forms
'((propertize (concat " " 24-hours ":" minutes " "))))
;;; recentf
(recentf-mode t)
;;; no need for scrollbars and window divider
(scroll-bar-mode -1)
(window-divider-mode -1)
;;; custom functions
(defun reload-dot-emacs ()
"Reload init file."
(interactive)
(load-file "~/.emacs.d/init.el"))
(defun open-dot-emacs ()
"Open this init file."
(interactive)
(find-file "~/.emacs.d/init.el"))
(defun toggle-fullscreen ()
"Toggle full screen mode."
(interactive)
(set-frame-parameter
nil 'fullscreen
(when (not (frame-parameter nil 'fullscreen)) 'fullboth)))
(defun duplicate-line()
"Copy a line to the next line, mimics intellij."
(interactive)
(move-beginning-of-line 1)
(kill-line)
(yank)
(open-line 1)
(forward-line 1)
(yank))
(global-set-key (kbd "C-d") 'duplicate-line)
(defun close-all-buffers ()
"Kill all buffers."
(interactive)
(mapc 'kill-buffer (buffer-list)))
(provide 'init)
;;; init.el ends here
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(markdown-command "/opt/homebrew/bin/pandoc")
'(package-selected-packages
'(neotree neo-tree dir-treeview nano-sidebar quelpa-use-package quelpa markdown-mode doom-themes nerd-icons yasnippet yaml-mode which-key use-package super-save solarized-theme smartparens rg rainbow-delimiters page-break-lines org-journal org-bullets nav material-theme magit load-env-vars helm-rg helm-projectile flycheck expand-region exec-path-from-shell doom-modeline diminish dashboard company ace-window)))