.emacs-all 13 KB

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