.emacs-all 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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-r") '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) ; Exit screen
  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. ;;; Erc config
  279. (setq erc-nick "speskk")
  280. (setq erc-hide-list '("JOIN" "PART" "QUIT"))
  281. (if (file-exists-p "~/.emacs.d/.erc-auth.el")
  282. (progn
  283. (load "~/.emacs.d/.erc-auth.el")
  284. (defun connect-to-libera-erc () (interactive)
  285. (erc :server "irc.libera.chat" :port "6667"
  286. :nick "speskk" :password *libera-chat*))))
  287. ;; Allow M-up / M-down behavior to switch windows
  288. (windmove-default-keybindings 'meta)
  289. (display-time-mode t)
  290. ;; Perl Config
  291. (setq
  292. perl-indent-parens-as-block 0
  293. perl-indent-level 8)
  294. ;; Set to make mouse focus window
  295. (setq mouse-autoselect-window t
  296. focus-follows-mouse t)
  297. ;; Custom eshell prompt
  298. (setq eshell-prompt-function
  299. (lambda nil
  300. " λ > "))
  301. (setq eshell-prompt-regexp "^ λ > ")
  302. (set-language-environment "UTF-8")
  303. ;; Simple rclone cli wrapper
  304. (load "~/Repos/dotfiles/emacs/elisp/rclone.el")
  305. (global-set-key (kbd "C-c o") 'rclone-post-buffer)
  306. (global-set-key (kbd "C-c C-o") 'rclone-get-org)
  307. ;; Small helper functions
  308. (load "~/Repos/dotfiles/emacs/elisp/helpers.el")
  309. (global-set-key (kbd "C-c p") 'display-full-buffer-path)
  310. (global-set-key (kbd "C-c C-P") 'post-region-to-pb)
  311. (global-set-key (kbd "C-c 2 p") 'display-pb)
  312. ;; Disable bars
  313. ;; (menu-bar-mode -1)
  314. (tool-bar-mode -1)
  315. (scroll-bar-mode -1)
  316. ;; Start in server mode
  317. (server-start)
  318. ;; Load for macOS
  319. ;;; Slime/etc
  320. (if (eq system-type 'darwin)
  321. (progn
  322. ;; Configure yasnippet
  323. (setq yas-snippet-dirs
  324. '("~/Repos/dotfiles/emacs/yasnippets/"))
  325. (yas-global-mode 1)
  326. (setq inferior-lisp-program "/opt/homebrew/bin/sbcl")
  327. (load (expand-file-name "~/.local/opt/quicklisp/slime-helper.el"))
  328. ;; Font/themes/etc
  329. (load "/Users/swatson/Repos/dotfiles/emacs/mac-load/customs.el")
  330. ;; Easily set cua mode on/off so that I don't have to
  331. ;; use shift+insert for paste on mac
  332. (global-set-key (kbd "C-c c") 'cua-mode)
  333. ;; (global-set-key (kbd "C-c n") 'toggle-frame-fullscreen)
  334. ;; Graphic Display
  335. (if (display-graphic-p)
  336. (progn
  337. (load-theme 'solarized-dark t)))))
  338. ;; Load for GUI Linux
  339. (if (eq system-type 'gnu/linux)
  340. (if (display-graphic-p)
  341. (progn
  342. ;; normal home/end behavior in GUI
  343. (global-set-key (kbd "<home>") 'beginning-of-line)
  344. (global-set-key (kbd "<end>") 'end-of-line)
  345. (load (expand-file-name "~/quicklisp/slime-helper.el"))
  346. (setq inferior-lisp-program (locate-file "sbcl" exec-path exec-suffixes 1))
  347. ;; https://emacs.stackexchange.com/questions/332/how-can-i-find-the-path-to-an-executable-with-emacs-lisp
  348. (setq yas-snippet-dirs
  349. '("~/Repos/dotfiles/emacs/yasnippets/"))
  350. (yas-global-mode 1)
  351. (if (file-exists-p "~/.enable_exwm")
  352. (progn
  353. (straight-use-package 'exwm)
  354. (require 'exwm)
  355. (load "~/Repos/dotfiles/emacs/linux-load/exwm-config.el")
  356. (require 'exwm-config-spw)
  357. (exwm-config-spw)))
  358. (setq visible-bell 1)
  359. (load "~/Repos/dotfiles/emacs/linux-load/customs.el")
  360. (load-theme 'solarized-light t))))
  361. ;; Load for Term
  362. (unless (display-graphic-p)
  363. (progn
  364. (load "~/Repos/dotfiles/emacs/linux-load/customs.el")
  365. (xterm-mouse-mode t)
  366. (menu-bar-mode -1)
  367. (setq vc-follow-symlinks t) ;;; Typically in the full GUI I want to know it's a symlink
  368. (global-set-key (kbd "<home>") 'beginning-of-line)
  369. (global-set-key (kbd "<end>") 'end-of-line)
  370. (global-set-key (kbd "C-c c c") (lambda ()
  371. (interactive)
  372. (shell-command-on-region (point) (mark) "xclip -selection clipboard")))
  373. (load (expand-file-name "~/quicklisp/slime-helper.el"))
  374. (setq inferior-lisp-program (locate-file "sbcl" exec-path exec-suffixes 1))))
  375. (custom-set-variables
  376. ;; custom-set-variables was added by Custom.
  377. ;; If you edit it by hand, you could mess it up, so be careful.
  378. ;; Your init file should contain only one such instance.
  379. ;; If there is more than one, they won't work right.
  380. '(custom-safe-themes
  381. '("ab058aa22bdaf17b5d8a9e21632a62c8966728ae10ef8fd07e95637e9cdf7a7b" "f0eb51d80f73b247eb03ab216f94e9f86177863fb7e48b44aacaddbfe3357cf1" "4c56af497ddf0e30f65a7232a8ee21b3d62a8c332c6b268c81e9ea99b11da0d3" "fee7287586b17efbfda432f05539b58e86e059e78006ce9237b8732fde991b4c" "2809bcb77ad21312897b541134981282dc455ccd7c14d74cc333b6e549b824f3" "c433c87bd4b64b8ba9890e8ed64597ea0f8eb0396f4c9a9e01bd20a04d15d358" "0fffa9669425ff140ff2ae8568c7719705ef33b7a927a0ba7c5e2ffcfac09b75" "01106ca9b4446341ecb86a76b9db48f1100e2eb13980aa0ec6f6adf8e69fd9a7" default))
  382. '(display-time-mode t)
  383. '(frame-background-mode 'dark))
  384. (custom-set-faces
  385. ;; custom-set-faces was added by Custom.
  386. ;; If you edit it by hand, you could mess it up, so be careful.
  387. ;; Your init file should contain only one such instance.
  388. ;; If there is more than one, they won't work right.
  389. '(default ((t (:family "Envy Code R" :foundry "UNKN" :slant normal :weight normal :height 100 :width normal))))
  390. '(org-level-1 ((t (:inherit variable-pitch :foreground "#cb4b16" :height 1.0))))
  391. '(org-level-2 ((t (:inherit variable-pitch :foreground "#859900" :height 1.0))))
  392. '(org-level-3 ((t (:inherit variable-pitch :foreground "#268bd2" :height 1.0))))
  393. '(org-level-4 ((t (:inherit variable-pitch :foreground "#b58900" :height 1.0)))))