.emacs-all 12 KB

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