.emacs-all 13 KB

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