.emacs-all 11 KB

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