init.el
1 ;;; init.el --- My Emacs configuration 2 ;; 3 ;; Lars Wirzenius' Emacs config. I have no idea what I'm doing, I've 4 ;; cobbled this up from snippets on the net. 5 6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 7 ;; Set up packaging system. 8 9 (require 'package) 10 11 (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/")) 12 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) 13 14 ;; Uncomment this to force Emacs to update its package lists. 15 ;; Keep it commented to make startup faster. 16 ;(package-refresh-contents) 17 18 (unless (package-installed-p 'use-package) 19 (package-install 'use-package)) 20 (require 'use-package) 21 (setq use-package-always-ensure t) 22 23 ;; I don't want Emacs modifying my config file, so I tell it to save 24 ;; custom options elsewhere. 25 26 (setq custom-file "~/.emacs.d/custom.el") 27 (load custom-file) 28 29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 30 ;; Some UI / behavior customizations. 31 32 (setq inhibit-startup-screen t) 33 34 (tab-bar-mode t) 35 (setq tab-bar-new-tab-to 'rightmost) 36 37 (tool-bar-mode 0) 38 39 (column-number-mode t) 40 41 (global-display-line-numbers-mode) 42 (set-face-attribute 'line-number nil 43 :height 0.8) 44 (set-face-attribute 'line-number-current-line nil 45 :foreground "#ff0000") 46 47 (setq select-enable-clipboard t) 48 49 (setq buffers-menu-show-directories t) 50 51 (set-default 'truncate-lines t) 52 53 (add-hook 'text-mode-hook 'hl-line-mode) 54 (add-hook 'prog-mode-hook 'hl-line-mode) 55 56 (global-set-key (kbd "<f5>") 'compile) 57 (global-set-key (kbd "C-<f5>") 'recompile) 58 (global-unset-key "\C-x\C-b") 59 (global-unset-key "\C-x\C-n") 60 (global-unset-key (kbd "C-<prior>")) 61 (global-unset-key (kbd "C-<next>")) 62 (global-unset-key (kbd "C-x <left>")) 63 (global-unset-key (kbd "C-x <right>")) 64 65 (when (display-graphic-p) 66 (global-unset-key "\C-x\C-c") 67 (global-unset-key "\C-z") 68 (global-unset-key "\C-_") 69 (global-unset-key (kbd "\C-xe")) 70 (global-unset-key (kbd "\C-x(")) 71 (global-unset-key (kbd "\C-x)")) 72 (global-unset-key (kbd "\C-x\C-r")) 73 (global-unset-key (kbd "\C-x\C-w")) 74 (global-unset-key (kbd "\C-x.")) 75 (global-unset-key (kbd "\C-x\C-z")) 76 (global-unset-key (kbd "<insert>")) 77 (global-set-key (kbd "C-=") 'text-scale-adjust) 78 (global-set-key (kbd "C-+") 'text-scale-adjust) 79 (global-set-key (kbd "C--") 'text-scale-adjust) 80 (global-set-key (kbd "C-0") 'text-scale-adjust) 81 ) 82 83 (setq-default indent-tabs-mode nil) 84 85 (setq make-backup-files nil) 86 87 (setq text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify))) 88 89 (setq sentence-end-double-space nil) 90 91 (set-face-attribute 'default nil 92 :height 130 93 :family "Hack") 94 95 (add-hook 'text-mode-hook 'show-paren-mode) 96 (add-hook 'prog-mode-hook 'show-paren-mode) 97 98 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 99 ;; Packages I like, with their configuration. 100 101 (use-package magit 102 :config 103 (global-set-key (kbd "C-x g") 'magit-status)) 104 (setq vc-handled-backends nil) 105 (setq package-install-upgrade-built-in t) 106 107 (use-package blacken) 108 (use-package python-mode 109 :config 110 (add-hook 'python-mode-hook 'blacken-mode)) 111 112 (use-package yaml-mode 113 :config 114 (add-to-list 'auto-mode-alist '("\\.ick\\'" . yaml-mode)) 115 (add-to-list 'auto-mode-alist '("\\.subplot\\'" . yaml-mode)) 116 (add-to-list 'auto-mode-alist '("\\.vmdb\\'" . yaml-mode)) 117 (add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode)) 118 (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))) 119 120 (use-package markdown-mode 121 :config 122 (add-to-list 'auto-mode-alist '("NEWS" . markdown-mode)) 123 (add-to-list 'auto-mode-alist '("README" . markdown-mode)) 124 (add-to-list 'auto-mode-alist '("\\.mdwn\\'" . markdown-mode))) 125 126 (use-package shfmt 127 :config 128 (add-hook 'sh-mode-hook 'shfmt-on-save-mode)) 129 130 (use-package rustic 131 :config 132 (setq rustic-format-trigger 'on-save)) 133 134 (use-package lsp-mode 135 :commands lsp 136 :custom 137 (lsp-rust-analyzer-cargo-watch-command "clippy") 138 (lsp-eldoc-render-all t) 139 (lsp-idle-delay 0.6) 140 :config 141 (add-hook 'lsp-mode-hook 'lsp-ui-mode)) 142 143 (use-package lsp-ui 144 :commands lsp-ui-mode 145 :custom 146 (lsp-ui-peek-always-show t) 147 (lsp-ui-sideline-show-hover t) 148 (lsp-ui-doc-enable nil)) 149 150 (use-package company 151 :config 152 (setq company-tooltip-align-annotations t)) 153 154 (use-package flycheck 155 :config 156 (setq-default flycheck-disabled-checkers '(python-pylint))) 157 158 (use-package flycheck-rust) 159 160 (use-package flycheck-color-mode-line) 161 (eval-after-load 'flycheck 162 '(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)) 163 164 (add-hook 'prog-mode-hook 'flycheck-mode) 165 (add-hook 'yaml-mode-hook 'flycheck-mode) 166 (add-hook 'markdown-mode-hook 'flycheck-mode) 167 (set-face-attribute 'flycheck-error nil 168 :weight 'bold 169 :underline "#ff0000" 170 :foreground "#ff0000") 171 172 (require 'flyspell) 173 (add-hook 'text-mode-hook 'flyspell-mode) 174 (add-hook 'prog-mode-hook 'flyspell-prog-mode) 175 (add-hook 'prog-mode-hook 'subword-mode) 176 (set-face-attribute 'flyspell-incorrect nil 177 :foreground "#ff0000") 178 179 (use-package rainbow-delimiters) 180 181 182 (provide 'init)