.emacs-all 11 KB

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