.emacs-all 12 KB

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