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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
|
#+TITLE: Cori's GNU Emacs Config
#+AUTHOR: Cori Barker
#+DESCRIPTION: Cori's personal Emacs config.
#+STARTUP: showeverything
#+OPTIONS: toc:2
* TABLE OF CONTENTS :toc:
- [[#important-programs-to-load-first][IMPORTANT PROGRAMS TO LOAD FIRST]]
- [[#elpaca-package-manager][Elpaca Package Manager]]
- [[#load-evil-mode][Load Evil Mode]]
- [[#general-keybindings][General Keybindings]]
- [[#all-the-icons][ALL THE ICONS]]
- [[#fonts][FONTS]]
- [[#setting-the-font-face][Setting The Font Face]]
- [[#zooming-inout][Zooming In/Out]]
- [[#gui-tweaks][GUI TWEAKS]]
- [[#disable-menubar-toolbars-and-scrollbars][Disable Menubar, Toolbars and Scrollbars]]
- [[#display-line-numbers-and-disable-truncated-lines][Display Line Numbers and Disable Truncated Lines]]
- [[#org-mode][ORG MODE]]
- [[#enabling-table-of-contents][Enabling Table of Contents]]
- [[#enabling-org-bullets][Enabling Org Bullets]]
- [[#source-code-block-tag-expansion][Source Code Block Tag Expansion]]
- [[#sudo-edit][SUDO EDIT]]
- [[#which-key][WHICH-KEY]]
- [[#ivy-counsel][IVY (COUNSEL)]]
* IMPORTANT PROGRAMS TO LOAD FIRST
** Elpaca Package Manager
#+begin_src emacs-lisp
(defvar elpaca-installer-version 0.12)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-sources-directory (expand-file-name "sources/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil :depth 1 :inherit ignore
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca-activate)))
(let* ((repo (expand-file-name "elpaca/" elpaca-sources-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (<= emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (apply #'call-process `("git" nil ,buffer t "clone"
,@(when-let* ((depth (plist-get order :depth)))
(list (format "--depth=%d" depth) "--no-single-branch"))
,(plist-get order :repo) ,repo))))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(let ((load-source-file-function nil)) (load "./elpaca-autoloads"))))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
#+end_src
** Load Evil Mode
#+begin_src emacs-lisp
;; Install a package via the elpaca macro
;; See the "recipes" section of the manual for more details.
;; (elpaca example-package)
;; Install use-package support
(elpaca elpaca-use-package
;; Enable use-package :ensure support for Elpaca.
(elpaca-use-package-mode)
(setq use-package-always-ensure t))
;;When installing a package used in the init file itself,
;;e.g. a package which adds a use-package key word,
;;use the :wait recipe keyword to block until that package is installed/configured.
;;For example:
;;(use-package general :ensure (:wait t) :demand t)
;; Expands to: (elpaca evil (use-package evil :demand t))
(use-package evil
:ensure t
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-vsplit-window-right t)
(setq evil-split-window-below t)
(evil-mode))
(use-package evil-collection
:ensure t
:after evil
:config
(setq evil-collection-mode-list '(dashboard dired ibuffer))
(evil-collection-init))
(use-package evil-tutor :ensure t)
;;Turns off elpaca-use-package-mode current declaration
;;Note this will cause evaluate the declaration immediately. It is not deferred.
;;Useful for configuring built-in emacs features.
(use-package emacs :ensure nil :config (setq ring-bell-function #'ignore))
#+end_src
** General Keybindings
#+begin_src emacs-lisp
(use-package general
:ensure t
:config
(general-evil-setup)
;; setup SPACE as the global leader key
(general-create-definer cb/leader-keys
:states '(normal insert visual emacs)
:keymaps 'override
:prefix "SPC" ;; set leader
:global-prefix "M-SPC") ;; access leader in insert mode
(cb/leader-keys
"." '(find-file :wk "Find file")
"fc" '((lambda () (interactive) (find-file "~/.config/emacs/config.org")) :wk "Edit emacs config")
"fr" '(counsel-recentf :wk "Find recent files")
"TAB TAB" '(comment-line :wk "Comment lines"))
(cb/leader-keys
"b" '(:ignore t :wk "Buffer")
"bb" '(switch-to-buffer :wk "Switch buffer")
"bi" '(ibuffer :wk "Ibuffer")
"bk" '(kill-this-buffer :wk "Kill this buffer")
"bn" '(next-buffer :wk "Next buffer")
"bp" '(previous-buffer :wk "Previous buffer")
"br" '(revert-buffer :wk "Reload buffer"))
(cb/leader-keys
"e" '(:ignore t :wk "Eshell/Evaluate")
"eb" '(eval-buffer :wk "Evaluate elisp in buffer")
"ed" '(eval-defun :wk "Evaluate defun containing or after point")
"ee" '(eval-expression :wk "Evaluate elisp expression")
"el" '(eval-last-sexp :wk "Evaluate elisp expression before point")
"er" '(eval-region :wk "Evaluate elisp in region")
"es" '(eshell :wk "Eshell")
"eh" '(counsel-esh-history :wk "Eshell history"))
(cb/leader-keys
"h" '(:ignore t :wk "Help")
"hf" '(describe-function :wk "Describe function")
"hv" '(describe-variable :wk "Describe variable")
"hrr" '((lambda () (interactive) (load-file "~/.config/emacs/init.el")) :wk "Reload emacs config"))
(cb/leader-keys
"t" '(:ignore t :wk "Toggle")
"tl" '(display-line-numbers-mode :wk "Toggle line numbers")
"tt" '(visual-line-mode :wk "Toggle truncated lines")
"tv" '(vterm-toggle :wk "Toggle vterm"))
(cb/leader-keys
"w" '(:ignore t :wk "Windows")
;; Window splits
"wc" '(evil-window-delete :wk "Close window")
"wn" '(evil-window-new :wk "New window")
"ws" '(evil-window-split :wk "Horizontal split window")
"wv" '(evil-window-vsplit :wk "Vertical split window")
;; Window motions
"wh" '(evil-window-left :wk "Window left")
"wj" '(evil-window-down :wk "Window down")
"wk" '(evil-window-up :wk "Window up")
"wl" '(evil-window-right :wk "Window right")
"ww" '(evil-window-next :wk "Goto next window")
;; Move windows
"wH" '(buf-move-left :wk "Buffer move left")
"wJ" '(buf-move down :wk "Buffer move down")
"wK" '(buf-move-up :wk "Buffer move up")
"wL" '(buf-move-right :wk "Buffer move right"))
)
#+end_src
* ALL THE ICONS
#+begin_src emacs-lisp
(use-package all-the-icons
:ensure t
:defer t)
(use-package all-the-icons-dired
:ensure t
:defer t
:hook (dired-mode . all-the-icons-dired-mode))
#+end_src
* BUFFER MOVE
#+begin_src emacs-lisp
(require 'windmove)
;;;###autoload
(defun buf-move-up ()
"Swap the current buffer and the buffer above the split.
If there is no split, ie now window above the current one, an
error is signaled."
;; "Switches between the current buffer, and the buffer above the
;; split, if possible."
(interactive)
(let* ((other-win (windmove-find-other-window 'up))
(buf-this-buf (window-buffer (selected-window))))
(if (null other-win)
(error "No window above this one")
;; swap top with this one
(set-window-buffer (selected-window) (window-buffer other-win))
;; move this one to top
(set-window-buffer other-win buf-this-buf)
(select-window other-win))))
;;;###autoload
(defun buf-move-down ()
"Swap the current buffer and the buffer under the split.
If there is no split, ie now window under the current one, an
error is signaled."
(interactive)
(let* ((other-win (windmove-find-other-window 'down))
(buf-this-buf (window-buffer (selected-window))))
(if (or (null other-win)
(string-match "^ \\*Minibuf" (buffer-name (window-buffer other-win))))
(error "No window under this one")
;; swap top with this one
(set-window-buffer (selected-window) (window-buffer other-win))
;; move this one to top
(set-window-buffer other-win buf-this-buf)
(select-window other-win))))
;;;###autoload
(defun buf-move-left ()
"Swap the current buffer and the buffer on the left of the split.
If there is no split, ie now window on the left of the current
one, an error is signaled."
(interactive)
(let* ((other-win (windmove-find-other-window 'left))
(buf-this-buf (window-buffer (selected-window))))
(if (null other-win)
(error "No left split")
;; swap top with this one
(set-window-buffer (selected-window) (window-buffer other-win))
;; move this one to top
(set-window-buffer other-win buf-this-buf)
(select-window other-win))))
;;;###autoload
(defun buf-move-right ()
"Swap the current buffer and the buffer on the right of the split.
If there is no split, ie now window on the right of the current
one, an error is signaled."
(interactive)
(let* ((other-win (windmove-find-other-window 'right))
(buf-this-buf (window-buffer (selected-window))))
(if (null other-win)
(error "No right split")
;; swap top with this one
(set-window-buffer (selected-window) (window-buffer other-win))
;; move this one to top
(set-window-buffer other-win buf-this-buf)
(select-window other-win))))
#+end_src
* FONTS
** Setting The Font Face
Defining the fonts that Emacs will use.
#+begin_src emacs-lisp
(defun cb/set-fonts ()
(set-face-attribute 'default nil
:font "FiraMono Nerd Font"
:height 100
:weight 'medium)
(set-face-attribute 'variable-pitch nil
:font "Hack"
:height 110
:weight 'medium)
(set-face-attribute 'fixed-pitch nil
:font "FiraMono Nerd Font"
:height 100
:weight 'medium))
(add-hook 'after-make-frame-functions
(lambda (frame)
(with-selected-frame frame
(cb/set-fonts))))
(add-to-list 'default-frame-alist '(font . "FiraMono Nerd Font-11"))
(setq-default line-spacing 0.12)
#+end_src
** Zooming In/Out
#+begin_src emacs-lisp
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
#+end_src
* GUI TWEAKS
Make GNU Emacs look better.
** Disable Menubar, Toolbars and Scrollbars
#+begin_src emacs-lisp
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
#+end_src
** Display Line Numbers and Disable Truncated Lines
#+begin_src emacs-lisp
(global-display-line-numbers-mode 1)
(global-visual-line-mode -1)
#+end_src
* ORG MODE
** Enabling Table of Contents
#+begin_src emacs-lisp
(use-package toc-org
:ensure t
:commands toc-org-enable
:init (add-hook 'org-mode-hook 'toc-org-enable))
#+end_src
** Enabling Org Bullets
#+begin_src emacs-lisp
(add-hook 'org-mode-hook 'org-indent-mode)
(use-package org-bullets :ensure t)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
#+end_src
** Source Code Block Tag Expansion
Type "<s" followed by TAB to expand to a begin_src tag.
#+begin_src emacs-lisp
(require 'org-tempo)
#+end_src
* SHELLS AND TERMINALS
** Eshell
#+begin_src emacs-lisp
(use-package eshell-syntax-highlighting
:ensure t
:after esh-mode
:config
(eshell-syntax-highlighting-global-mode +1))
(setq eshell-rc-script (concat user-emacs-directory "eshell/profile")
eshell-aliases-file (concat user-emacs-directory "eshell/aliases")
eshell-history-size 5000
eshell-buffer-maximum-lines 5000
eshell-hist-ignoredups t
eshell-scroll-to-bottom-on-input t
eshell-destroy-buffer-when-process-dies t
eshell-visual-commands '("bash" "fish" "htop" "ssh" "top" "zsh"))
#+end_src
** Vterm
#+begin_src emacs-lisp
(use-package vterm
:ensure t
:config
(setq shell-file-name "/bin/bash"
vterm-max-scrollback 5000))
#+end_src
** Vterm-Toggle
#+begin_src emacs-lisp
(use-package vterm-toggle
:ensure t
:after vterm
:config
(setq vterm-toggle-fullscreen-p nil)
(setq vterm-toggle-scope 'project)
(add-to-list 'display-buffer-alist
'((lambda (buffer-or-name _)
(let ((buffer (get-buffer buffer-or-name)))
(with-current-buffer buffer
(or (equal major-mode 'vterm-mode)
(string-prefix-p vterm-buffer-name (buffer-name buffer))))))
(display-buffer-reuse-window display-buffer-at-bottom)
(reusable-frames . visible)
(window-height . 0.3))))
#+end_src
* RAINBOW MODE
#+begin_src emacs-lisp
(use-package rainbow-mode
:ensure t
:hook org-mode prog-mode)
#+end_src
* SUDO EDIT
#+begin_src emacs-lisp
(use-package sudo-edit
:ensure t
:config
(cb/leader-keys
"fu" '(sudo-edit-find-file :wk "Sudo find file")
"fU" '(sudo-edit :wk "Sudo edit file")))
#+end_src
* THEME
#+begin_src emacs-lisp
(add-to-list 'custom-theme-load-path "~/.config/emacs/themes/")
(load-theme 'black t)
#+end_src
* PDF TOOLS
#+begin_src emacs-lisp
(use-package pdf-tools
:ensure t
:defer t
:magic ("%PDF" . pdf-view-mode)
:config (pdf-tools-install :no-query))
#+end_src
* AUCTEX
#+begin_src emacs-lisp
(use-package auctex
:ensure t
:defer t
:hook
(LaTeX-mode . LaTeX-math-mode)
(LaTeX-mode . flyspell-mode)
(LaTeX-mode . visual-line-mode)
:custom
(TeX-auto-save t)
(TeX-parse-self t)
(TeX-save-query nil)
(TeX-PDF-mode t)
(TeX-source-correlate-mode t)
(TeX-source-correlate-method 'synctex)
(TeX-view-program-selection '((output-pdf "Zathura")))
(TeX-view-program-list '(("Zathura" "zathura --synctex-forward %n:0:%b %o"))))
;; CDLaTeX — fast math input with tab completion
(use-package cdlatex
:ensure t
:hook (LaTeX-mode . cdlatex-mode))
(use-package preview-latex
:ensure nil
:hook (LaTeX-mode . LaTeX-preview-setup)
:custom
(preview-auto-cache-preamble t)
(preview-image-type 'svg))
(use-package company-auctex
:ensure t
:hook (LaTeX-mode . company-auctex-init))
#+end_src
* WHICH-KEY
#+begin_src emacs-lisp
(use-package which-key
:ensure t
:init
(which-key-mode 1)
:config
(setq which-key-side-window-location 'bottom
which-key-sort-order #'which-key-key-order-alpha
which-key-sort-uppercase-first nil
which-key-add-column-padding 1
which-key-max-display-columns nil
which-key-min-display-lines 6
which-key-side-window-slot -10
which-key-side-window-max-height 0.25
which-key-idle-delay 0.8
which-key-max-description-length 25
which-key-allow-imprecise-window-fit t
which-key-seperator " → " ))
#+end_src
* IVY (COUNSEL)
+ Ivy, a generic completion mechanism for Emacs.
+ Counsel, a collection of Ivy-enhanced versions of common Emacs commands.
+ Ivy-rich allows you to add descriptions alongside the commands in M-x.
#+begin_src emacs-lisp
(use-package counsel
:ensure t
:after ivy
:config (counsel-mode))
(use-package ivy
:ensure t
:bind
;; ivy-resume resumes the last Ivy-based completion.
(("C-c C-r" . ivy-resume)
("C-x B" . ivy-switch-buffer-other-window))
:custom
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
(setq enable-recursive-minibuffers t)
:config
(ivy-mode))
(use-package all-the-icons-ivy-rich
:ensure t
:defer t
:after ivy-rich
:init (all-the-icons-ivy-rich-mode 1))
(use-package ivy-rich
:ensure t
:after ivy
:init (ivy-rich-mode 1)
:custom
(ivy-virtual-abbreviate 'full
ivy-rich-switch-buffer-align-virtual-buffer t
ivy-rich-path-style 'abbrev)
:config
(ivy-set-display-transformer 'ivy-switch-buffer
'ivt-rich-switch-buffer-transformer))
#+end_src
|