.emacs-all 12 KB

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