files related to my current emacs configuration
1
fork

Configure Feed

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

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