files related to my current emacs configuration
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: init repo

Signed-off-by: Amy <amy+git@amogus.cloud>

Amy bfdcb566

+174
+174
.emacs
··· 1 + ;; -*- lexical-binding: t -*- 2 + 3 + ;;; gc 4 + (setq gc-cons-threshold (* 1024 1024 100)) 5 + (add-hook 'emacs-startup-hook #'(lambda () 6 + (message "Startup in %s sec with %d garbage collections" 7 + (emacs-init-time "%.2f") 8 + gcs-done))) 9 + 10 + ;;; macros 11 + (defmacro amy/add-package (name &optional should-require) 12 + "Add a package by `NAME' and automatically require it if `SHOULD-REQUIRE' is not nil." 13 + (if should-require 14 + `(progn (unless (package-installed-p ,name) 15 + (package-install ,name)) 16 + (require ,name)) 17 + `(unless (package-installed-p ,name) 18 + (package-install ,name)))) 19 + 20 + (defmacro amy/set-key (key func) 21 + "Wrapper of `global-set-key' for setting keybinds without directly using the `kbd' function. 22 + See the documentation for `kbd' and `global-set-key' to learn about the `KEY' and `FUNC' arguments." 23 + `(global-set-key (kbd ,key) ,func)) 24 + 25 + (defmacro amy/add-hooks (modes &rest args) 26 + "Hook into multiple `MODES'. 27 + Where `ARGS' is the rest of the arguments passed to `add-hook'. 28 + See `add-hook' for more information." 29 + (let ((hooks (mapcar (lambda (mode) 30 + (intern (concat (symbol-name mode) "-hook"))) 31 + modes))) 32 + `(mapc (lambda (name) 33 + (add-hook name ,@args)) 34 + ',hooks))) 35 + 36 + (defmacro amy/add-languages (&rest langs) 37 + "Wrapper of `add-to-list', made specifically to add languages to `auto-mode-alist'. 38 + `LANGS' should be a continuous list of pairs containing regexp and mode. 39 + 40 + See `auto-mode-alist' for more information." 41 + `(amy/map-2 ',langs 42 + (lambda (rgxp mode-to-assign) 43 + (add-to-list 'auto-mode-alist (cons rgxp mode-to-assign))))) 44 + 45 + ;;; funcs 46 + (defun amy/map-2 (list func) 47 + "Map function with 2 variables. 48 + Where: 49 + `LIST' is the list that we are iterating through. 50 + `FUNC' is the function to apply to those two elements. 51 + `LIST' must ALWAYS be divisible by two." 52 + (cond 53 + ((> (mod (length list) 2) 0) (error "List is not divisible by 2")) 54 + ((eq list nil) t) 55 + (t (progn 56 + (funcall func (car list) (car (cdr list))) 57 + (amy/map-2 (cdr (cdr list)) func))))) 58 + 59 + (defun amy/get-active-minor-modes () 60 + "Function to get a list of all active minor modes." 61 + (let ((active-modes)) 62 + (mapc (lambda (mode) (condition-case nil 63 + (if (and (symbolp mode) (symbol-value mode)) 64 + (add-to-list 'active-modes mode)) 65 + (error nil))) 66 + minor-mode-list) 67 + active-modes)) 68 + 69 + ;;; emacs-customizations 70 + (setq 71 + ring-bell-function nil 72 + visible-bell t 73 + custom-file (expand-file-name ".emacs.d/custom.el" "~")) 74 + 75 + (load custom-file t) 76 + (set-frame-name "Emacs") 77 + (set-frame-font "Iosevka 20") 78 + (set-face-attribute 'fixed-pitch nil :font "Iosevka 20") 79 + 80 + 81 + ;;; package-setup 82 + (require 'package) 83 + (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) 84 + (add-to-list 'package-archives '( "jcs-elpa" . "https://jcs-emacs.github.io/jcs-elpa/packages/") t) 85 + (setq package-archive-priorities '(("melpa" . 5) 86 + ("jcs-elpa" . 0))) 87 + 88 + (package-initialize) 89 + 90 + ;;; Shell env 91 + (amy/add-package 'exec-path-from-shell t) 92 + (when (memq window-system '(mac ns x pgtk)) 93 + (exec-path-from-shell-initialize)) 94 + 95 + ;;; theme 96 + (amy/add-package 'spacemacs-theme) 97 + (load-theme 'spacemacs-light t) 98 + 99 + ;; code-editing 100 + (amy/add-package 'multiple-cursors t) 101 + (amy/set-key "C-S-c C-S-c" 'mc/edit-lines) 102 + (amy/set-key "C->" 'mc/mark-next-like-this) 103 + (amy/set-key "C-<" 'mc/mark-previous-like-this) 104 + (amy/set-key "C-c C-<" 'mc/mark-all-like-this) 105 + 106 + (amy/add-package 'paredit t) 107 + (amy/add-hooks (emacs-lisp-mode lisp-mode clojure-mode) 108 + #'paredit-mode) 109 + 110 + (amy/add-package 'flycheck t) 111 + (amy/add-package 'flycheck-eglot) 112 + (require 'eglot) 113 + 114 + ;; Install pre-compiled language grammars 115 + (amy/add-package 'treesit-langs t) 116 + (treesit-langs-major-mode-setup) 117 + 118 + ;; TODO: get rid of all of these add-to-list statements 119 + (amy/add-languages "\\.ts\\'" typescript-ts-mode 120 + "\\.[tj]sx\\'" tsx-ts-mode 121 + "\\.js\\'" js-ts-mode) 122 + 123 + (amy/add-hooks (js-ts-mode tsx-ts-mode typescript-ts-mode) 124 + #'eglot-ensure) 125 + 126 + (amy/add-hooks (js-ts-mode tsx-ts-mode typescript-ts-mode) 127 + #'flycheck-mode) 128 + 129 + ;; TODO: get rid of all of these "eval-after-load"s 130 + (with-eval-after-load 'flycheck-posframe 131 + (flycheck-posframe-configure-pretty-defaults)) 132 + 133 + (with-eval-after-load 'flycheck 134 + (require 'flycheck-eglot) 135 + (add-hook 'flycheck-mode-hook #'flycheck-eglot-mode)) 136 + 137 + (with-eval-after-load 'eglot 138 + (add-to-list 'eglot-server-programs '(js-base-mode . ("typescript-language-server" "--stdio")))) 139 + 140 + (amy/add-package 'slime t) 141 + (setq inferior-lisp-program "sbcl") 142 + 143 + (amy/add-package 'cider t) 144 + 145 + (amy/add-package 'corfu t) 146 + (global-corfu-mode) 147 + (corfu-history-mode) 148 + (corfu-echo-mode) 149 + 150 + (setq 151 + corfu-auto t 152 + corfu-auto-prefix 2 153 + corfu-auto-delay 0.0 154 + corfu-echo-documentation 0.25 155 + corfu-quit-at-boundary 'separator 156 + corfu-preview-current 'insert 157 + corfu-preselect-first nil 158 + corfu-cycle t 159 + 160 + tab-always-indent 'complete) 161 + 162 + (keymap-set corfu-map "TAB" #'corfu-next) 163 + (keymap-set corfu-map "S-TAB" #'corfu-previous) 164 + 165 + (amy/add-package 'cape t) 166 + (add-to-list 'completion-at-point-functions #'cape-file) 167 + (add-to-list 'completion-at-point-functions #'cape-dabbrev) 168 + 169 + (with-eval-after-load 'cape 170 + (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent) 171 + (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)) 172 + 173 + ;; Dired config 174 + (setq dired-listing-switches "-al --group-directories-first")