emacs/.emacs-all
1	;; Bootstrap Straight Package Manager
2 (defvar bootstrap-version)
3 (let ((bootstrap-file
4 (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
5 (bootstrap-version 5))
6 (unless (file-exists-p bootstrap-file)
7 (with-current-buffer
8 (url-retrieve-synchronously
9 "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
10 'silent 'inhibit-cookies)
11 (goto-char (point-max))
12 (eval-print-last-sexp)))
13 (load bootstrap-file nil 'nomessage))
14
15 ;; packages to install and load
16 (straight-use-package 'auto-complete)
17 (straight-use-package '(nano-theme :type git :host github
18 :repo "rougier/nano-theme"))
19 (straight-use-package
20 '(slime-company :type git :host github :repo "anwyn/slime-company"))
21 (straight-use-package 'sublimity)
22 (straight-use-package 'all-the-icons)
23 (straight-use-package 'neotree)
24 (straight-use-package 'rust-mode)
25 (straight-use-package 'markdown-mode)
26 (straight-use-package 'slime)
27 (straight-use-package 'ac-slime)
28 (straight-use-package 'evil)
29 (straight-use-package 'dimmer)
30 (straight-use-package 'magit)
31 (straight-use-package 'diff-hl)
32 (straight-use-package 'rainbow-delimiters)
33 (straight-use-package 'focus)
34 (straight-use-package 'solarized-theme)
35 (straight-use-package 'windresize)
36 (straight-use-package 'yasnippet)
37 (straight-use-package
38 '(janet-mode :type git :host github
39 :repo "ALSchwalm/janet-mode"))
40 (straight-use-package
41 '(puppet-mode :type git :host github
42 :repo "voxpupuli/puppet-mode"))
43 (straight-use-package
44 '(pico8-mode :type git :host github
45 :repo "Kaali/pico8-mode"))
46 (straight-use-package
47 '(fzf :type git :host github
48 :repo "bling/fzf.el"))
49
50 ;; EasyPG settings
51 (setq epa-pinentry-mode 'loopback)
52
53 ;; add hook for searching in zeal
54 ;; https://zealdocs.org/
55 (straight-use-package
56 '(zeal-at-point :type git :host github
57 :repo "jinzhu/zeal-at-point"))
58
59 (global-set-key (kbd "C-c v") 'zeal-at-point)
60
61 ;; newlisp mode
62 ;; (straight-use-package
63 ;; '(newlisp-mode
64 ;; :type git :host github
65 ;; :repo "may/newlisp-mode"))
66 ;; ;; Straight weirdly doesn't resolve this correctly
67 ;; (load-file "~/.emacs.d/straight/repos/newlisp-mode/newlisp.el")
68
69 ;; Mastodon
70 ;; (straight-use-package
71 ;; '(mastodon
72 ;; :type git :host nil
73 ;; :repo "https://codeberg.org/martianh/mastodon.el"))
74
75 ;; Gopher browser
76 (straight-use-package 'elpher)
77 (straight-use-package 'xterm-color)
78 (defun display-ansi-colors ()
79 (interactive)
80 (let ((inhibit-read-only t))
81 (ansi-color-apply-on-region (point-min) (point-max))))
82
83 ;;; Terminal in emacs via vterm lib
84 (straight-use-package
85 '(vterm :type git :host github
86 :repo "akermu/emacs-libvterm"))
87
88 ;;; Vterm config
89 (setq vterm-buffer-name-string "%s")
90 (add-hook 'vterm-mode-hook
91 (lambda ()
92 (set (make-local-variable 'buffer-face-mode-face) 'fixed-pitch)
93 (buffer-face-mode t)))
94
95 (global-set-key (kbd "C-c <escape>") 'vterm-send-escape) ;
96 (global-set-key (kbd "C-c C-u") 'vterm-send-C-u) ; Readline line
97 (global-set-key (kbd "C-c C-w") 'vterm-send-C-w) ; Readline word
98 (global-set-key (kbd "C-c C-d") 'vterm-send-C-d) ; Exit
99 (global-set-key (kbd "C-c C-s") 'vterm-send-C-r) ; Reverse search
100 (global-set-key (kbd "C-b") 'vterm-send-C-b) ; Tmux
101 (global-set-key (kbd "C-c C-a") 'vterm-send-C-a) ; Screen prefix
102
103 ;;; Syntax highlights for uxn-tal
104 ;; (straight-use-package
105 ;; '(tal-mode :type git :host github
106 ;; :repo "rafapaezbas/uxntal-mode"))
107
108 ;; Haskell Mode
109 (straight-use-package 'haskell-mode)
110
111 ;;; Cursor highlighter
112 (straight-use-package
113 '(beacon :type git :host github
114 :repo "Malabarba/beacon"))
115 (beacon-mode)
116 (global-set-key (kbd "C-c B") 'beacon-mode)
117
118 ;; Racket config
119 ;; (straight-use-package 'racket-mode)
120 ;; Using DrRacket for now
121
122 ;; Org to reveal.js presentations
123 ;; Docs: https://github.com/yjwen/org-reveal#configuration
124 (straight-use-package 'org-reveal)
125 (require 'ox-reveal)
126 (setq org-reveal-root "file:///home/swatson/Repos/reveal.js")
127
128 ;; Vimperator like hints for
129 ;; file navigationaki2o/emacs-pophint
130 (straight-use-package
131 '(pophint :type git :host github
132 :repo "aki2o/emacs-pophint"))
133
134 (global-set-key (kbd "C-c f") 'pophint:do-flexibly)
135
136 ;;; Code folding
137 (add-hook 'prog-mode-hook 'hs-minor-mode)
138
139 (global-set-key (kbd "C-c a") 'hs-toggle-hiding)
140
141 ;;; Error checking
142 (global-set-key (kbd "C-c 2 e") 'flymake-mode)
143
144 ;; System monitor
145 ;; (straight-use-package
146 ;; '(symon :type git :host github
147 ;; :repo "zk-phi/symon"))
148 ;; For whatever reason, using straight to build this
149 ;; package results in bugs on Linux (not OSX). I'm assuming
150 ;; because straight is building from git and there is a regression.
151 ;; As such -- MELPA config
152 ;; This config is likely redudant and I can use the straight
153 ;; MELPA interface, but it's working and I'm too lazy to change it
154 ;; 2022/03/03 - Using straight MEPLA interface also surfaces this bug.
155 ;; Below seems to be only reliable cross platform way to include this package
156 ;; (require 'package)
157 ;; (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
158 ;; (package-install 'symon)
159 ;; ;;(symon-mode 1)
160
161 (straight-use-package
162 '(telephone-line :type git :host github
163 :repo "dbordak/telephone-line"))
164 (telephone-line-mode 1)
165
166 ;;; Indent highlighting
167 (straight-use-package
168 '(highlight-indent-guides
169 :type git :host github
170 :repo "DarthFennec/highlight-indent-guides"))
171 (setq highlight-indent-guides-method 'character)
172 (add-hook 'prog-mode-hook 'highlight-indent-guides-mode)
173
174 ;; Org mode
175 ;; Get src block tabs to work how I expect
176 (setq org-src-tab-acts-natively t)
177 (setq org-src-preserve-indentation nil
178 org-edit-src-content-indentation 0)
179
180 ;; tramp
181 (setq tramp-default-method "ssh")
182
183 ;; Ivy
184 ;; (straight-use-package 'ivy)
185 ;; (ivy-mode)
186 ;; (setq ivy-use-virtual-buffers t)
187 ;; (setq enable-recursive-minibuffers t)
188
189 ;; (require 'ido)
190 (ido-mode t)
191
192 (require 'yasnippet)
193
194 ;; Configure focus
195 (require 'focus)
196 (add-to-list 'focus-mode-to-thing '(lisp-mode . paragraph))
197
198 ;; rainbow delims
199 (require 'rainbow-delimiters)
200 (add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
201
202 ;; Git stuff
203 (require 'magit)
204 (require 'diff-hl)
205 ;; Just enable diff-hl per buffer,
206 ;; it seems expensive
207 ;; (global-diff-hl-mode)
208 (add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
209 (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
210 (diff-hl-margin-mode t)
211
212 (require 'dimmer)
213 (setq dimmer-fraction 0.4)
214
215 (require 'evil)
216 (evil-mode 1)
217
218 ;; Enable tab behavior like vi
219 (straight-use-package '(evil-tabs :type git :host github
220 :repo "krisajenkins/evil-tabs"))
221 (require 'evil-tabs)
222 (global-evil-tabs-mode t)
223
224 (require 'auto-complete)
225 (global-auto-complete-mode t)
226
227 ;; Common Lisp
228 (require 'slime)
229 (require 'ac-slime)
230 (slime-setup '(slime-fancy ac-slime))
231 (add-hook 'slime-mode-hook 'set-up-slime-ac)
232 (add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
233 (eval-after-load "auto-complete"
234 '(add-to-list 'ac-modes 'slime-repl-mode))
235
236 ;; Guile
237 (straight-use-package 'geiser)
238 (straight-use-package 'geiser-guile)
239 (setq geiser-active-implementations '(guile))
240
241 (require 'markdown-mode)
242
243 (require 'neotree)
244 (global-set-key (kbd "C-c n") 'neotree-toggle)
245
246 (require 'all-the-icons)
247
248 (require 'sublimity)
249 (require 'sublimity-scroll)
250 (require 'sublimity-map) ;; experimental
251 (require 'sublimity-attractive)
252 (setq sublimity-scroll-weight 10
253 sublimity-scroll-drift-length 5)
254 (setq sublimity-map-size 40)
255 (setq sublimity-map-fraction 0.3)
256 (setq sublimity-map-text-scale -5)
257 (sublimity-map-set-delay 0.1)
258 (setq sublimity-attractive-centering-width nil)
259
260 (setq backup-directory-alist
261 `((".*" . ,temporary-file-directory)))
262 (setq auto-save-file-name-transforms
263 `((".*" ,temporary-file-directory t)))
264
265 ;;; Generic options for all OSs
266 ;;; Smooth mouse scroll a bit
267 ;;; If scrolling performance is bad, remember the profiler:
268 ;;; https://christiantietze.de/posts/2020/12/emacs-scroll-performance-projectile/
269 (setq mouse-wheel-progressive-speed t)
270
271 ;; whitespace config
272 ;; make whitespace-mode use just basic coloring
273 (setq whitespace-style '(face tabs))
274 (setq tab-face (make-face 'tab-face))
275 (set-face-background 'tab-face "gray")
276 (setq whitespace-tab 'tab-face)
277
278 (defun sol-dk ()
279 (interactive)
280 (load-theme 'solarized-dark))
281
282 (defun sol-l ()
283 (interactive)
284 (load-theme 'solarized-light))
285
286 ;; General is typically used for mode specific
287 ;; rebinds and keymaps, while 'global-set-key
288 ;; is still used for global keymaps for the sake of
289 ;; clarity
290 (straight-use-package 'general)
291 ;; Keybinds/macros
292 (global-set-key (kbd "C-c C-q") #'mu-magit-kill-buffers)
293 (global-set-key (kbd "C-c ;") 'comment-line)
294 (global-set-key (kbd "C-c b") 'fzf-switch-buffer)
295 (global-set-key (kbd "C-c z") '(lambda ()
296 (interactive)
297 (switch-to-buffer "*scratch*")
298 (fzf-find-file)))
299 (global-set-key (kbd "C-c e") '(lambda ()
300 (interactive)
301 (diff-hl-mode)
302 (diff-hl-flydiff-mode)))
303 (global-set-key (kbd "C-c d") 'slime-describe-symbol)
304 (global-set-key (kbd "C-c M-r") 'slime-restart-inferior-lisp)
305 (global-set-key (kbd "C-c D") 'dimmer-mode)
306 (global-set-key (kbd "C-c S") 'sublimity-mode)
307 (global-set-key (kbd "C-c s") 'flyspell-correct-word-before-point)
308 (global-set-key (kbd "C-c F") 'focus-mode)
309 (global-set-key (kbd "C-c r") '(lambda ()
310 (interactive)
311 (load-file (file-truename "~/.emacs"))))
312 (global-set-key (kbd "C-c C-e") '(lambda ()
313 (interactive)
314 (find-file (file-truename "~/.emacs"))
315 (with-current-buffer (buffer-name)
316 (emacs-lisp-mode))))
317 (global-set-key (kbd "C-c l") 'display-line-numbers-mode)
318 (global-set-key (kbd "C-c w") 'window-swap-states)
319 (global-set-key (kbd "C-c C-W") 'windresize)
320 (global-set-key (kbd "C-c W") 'whitespace-mode)
321 (global-set-key (kbd "C-c t") 'sol-dk)
322 (global-set-key (kbd "C-c y") 'sol-l)
323 (global-set-key (kbd "C-c g") 'magit)
324 (global-set-key (kbd "C-c C-.") '(lambda ()
325 (interactive)
326 (switch-to-buffer "*Messages*")))
327 (global-set-key (kbd "C-c C-f") 'find-file-at-point)
328 (global-set-key (kbd "C-c m p") '(lambda ()
329 (interactive)
330 (shell-command "mpc toggle")))
331 (global-set-key (kbd "C-c n") 'neotree-toggle)
332
333 ;;; Erc config
334 (setq erc-nick "speskk")
335 (setq erc-hide-list '("JOIN" "PART" "QUIT"))
336 (if (file-exists-p "~/.emacs.d/.erc-auth.el")
337 (progn
338 (load "~/.emacs.d/.erc-auth.el")
339 (defun connect-to-libera-erc () (interactive)
340 (erc :server "irc.libera.chat" :port "6667"
341 :nick "speskk" :password *libera-chat*))))
342
343 ;; Allow M-up / M-down behavior to switch windows
344 (windmove-default-keybindings 'meta)
345
346 (display-time-mode t)
347
348 ;; Perl Config
349 (setq
350 perl-indent-parens-as-block 0
351 perl-indent-level 8)
352
353 ;; Set to make mouse focus window
354 (setq mouse-autoselect-window t
355 focus-follows-mouse t)
356
357 ;; Custom eshell prompt
358 (setq eshell-prompt-function
359 (lambda nil
360 " λ > "))
361 (setq eshell-prompt-regexp "^ λ > ")
362
363 (set-language-environment "UTF-8")
364
365 ;; Simple rclone cli wrapper
366 (load "~/Repos/dotfiles/emacs/elisp/rclone.el")
367 (global-set-key (kbd "C-c o") 'rclone-post-buffer)
368 (global-set-key (kbd "C-c C-o") 'rclone-get-org)
369
370 ;; Small helper functions
371 (load "~/Repos/dotfiles/emacs/elisp/helpers.el")
372 (global-set-key (kbd "C-c p") 'display-full-buffer-path)
373 (global-set-key (kbd "C-c C-P") 'post-region-to-pb)
374 (global-set-key (kbd "C-c 2 p") 'display-pb)
375
376 ;; OpenAI script
377 (load "~/Repos/dotfiles/emacs/elisp/openai.el")
378 (global-set-key (kbd "C-c q") 'ask-gpt)
379
380 ;; Disable bars
381 ;; (menu-bar-mode -1)
382 (tool-bar-mode -1)
383 (scroll-bar-mode -1)
384
385 ;; Start in server mode
386 (server-start)
387
388 ;; Load for macOS
389 ;;; Slime/etc
390 (if (eq system-type 'darwin)
391 (progn
392 ;; Configure yasnippet
393 (setq yas-snippet-dirs
394 '("~/Repos/dotfiles/emacs/yasnippets/"))
395 (yas-global-mode 1)
396
397 (setq inferior-lisp-program "/opt/homebrew/bin/sbcl")
398 (load (expand-file-name "~/.local/opt/quicklisp/slime-helper.el"))
399 ;; Font/themes/etc
400 (load "/Users/swatson/Repos/dotfiles/emacs/mac-load/customs.el")
401
402 ;; Easily set cua mode on/off so that I don't have to
403 ;; use shift+insert for paste on mac
404 (global-set-key (kbd "C-c c") 'cua-mode)
405 ;; (global-set-key (kbd "C-c n") 'toggle-frame-fullscreen)
406 ;; Graphic Display
407 (if (display-graphic-p)
408 (progn
409 (load-theme 'solarized-dark t)))))
410
411 ;; Load for GUI Linux
412 (if (eq system-type 'gnu/linux)
413 (if (display-graphic-p)
414 (progn
415 ;; normal home/end behavior in GUI
416 (global-set-key (kbd "<home>") 'beginning-of-line)
417 (global-set-key (kbd "<end>") 'end-of-line)
418 (load (expand-file-name "~/quicklisp/slime-helper.el"))
419 (setq inferior-lisp-program (locate-file "sbcl" exec-path exec-suffixes 1))
420 ;; https://emacs.stackexchange.com/questions/332/how-can-i-find-the-path-to-an-executable-with-emacs-lisp
421 (setq yas-snippet-dirs
422 '("~/Repos/dotfiles/emacs/yasnippets/"))
423 (yas-global-mode 1)
424
425 (if (file-exists-p "~/.enable_exwm")
426 (progn
427 (straight-use-package 'exwm)
428 (require 'exwm)
429 (load "~/Repos/dotfiles/emacs/linux-load/exwm-config.el")
430
431 (require 'exwm-config-spw)
432 (exwm-config-spw)))
433
434 (setq visible-bell 1)
435 (load "~/Repos/dotfiles/emacs/linux-load/customs.el")
436 (load-theme 'solarized-light t))))
437
438 ;; Load for Term
439 (unless (display-graphic-p)
440 (progn
441 (load "~/Repos/dotfiles/emacs/linux-load/customs.el")
442 (xterm-mouse-mode t)
443 (menu-bar-mode -1)
444 (setq vc-follow-symlinks t) ;;; Typically in the full GUI I want to know it's a symlink
445 (global-set-key (kbd "<home>") 'beginning-of-line)
446 (global-set-key (kbd "<end>") 'end-of-line)
447 (global-set-key (kbd "C-c c c") (lambda ()
448 (interactive)
449 (shell-command-on-region (point) (mark) "xclip -selection clipboard")))
450 (load (expand-file-name "~/quicklisp/slime-helper.el"))
451 (setq inferior-lisp-program (locate-file "sbcl" exec-path exec-suffixes 1))))