summary refs log tree commit diff stats
path: root/init.el
blob: 30ec37cf806d790158704023f90e5070ffb9b744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
;;; init.el -*- lexical-binding: t; coding: utf-8; -*-

;;; Commentary:
;; BANKRUPT_SCORE: 1
;; ^ the number of times I've declared Emacs bankruptcy.
;; Does this mean I'm part of the cool kids now?

;;; Macros
(defmacro cuss (var val)
  "Basically `use-package' `:custom' but without either."
  `(progn
     (funcall (or (get ',var 'custom-set) #'set-default)
	      ',var ,val)))

;;; Files
;; keep `emacs-user-directory' tidy
(use-package no-littering)

;; don't clutter `init.el' with customize crap
(cuss custom-file (no-littering-expand-etc-file-name "custom.el"))

;; backups
(cuss backup-directory-alist
      `((".*" . ,(no-littering-expand-var-file-name "backup/"))))

;; recent files
(use-package recentf
  :config
  (add-to-list 'recentf-exclude no-littering-var-directory)
  (add-to-list 'recentf-exclude no-littering-etc-directory)
  :custom
  (recentf-max-menu-items 100)
  (recentf-max-saved-items 100)
  :config
  (recentf-mode +1))

;; encoding
(set-charset-priority 'unicode)
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

;;; Save/Restore
;; save places in files
(use-package saveplace
  :custom
  (save-place-file (no-littering-expand-var-file-name "places"))
  :config
  (save-place-mode +1))

;; save history of variables
(use-package savehist
  :custom
  (savehist-additional-variables
   '(kill-ring
     search-ring
     regexp-search-ring))
  :config
  (savehist-mode +1))

;;; Buffers
;; uniquely name buffers
(cuss uniquify-buffer-name-style 'forward)

;;; UI
;; frame defaults
(cuss default-frame-alist '((tool-bar-lines . 0)
			    (menu-bar-lines . 0)
			    (vertical-scroll-bars . nil)
			    (horizontal-scroll-bars . nil)
			    (right-divider-width . 2)
			    (bottom-divider-width . 2)
			    (left-fringe-width . 2)
			    (right-fringe-width . 2)))

;; cursor
(cuss cursor-type 'bar)
(cuss cursor-in-non-selected-windows 'hollow)
(blink-cursor-mode 0)

;; mouse
(cuss mouse-yank-at-point t) ; yank at the point instead of where clicked

;; startup screen
(cuss inhibit-startup-buffer-menu t)
(cuss inhibit-startup-screen t)
(cuss initial-buffer-choice t) ; start in *scratch*
(cuss initial-scratch-message nil)

;; interactivity
(fset 'yes-or-no-p #'y-or-n-p)

;; themes
(use-package modus-operandi-theme
  :config
  (load-theme 'modus-operandi t))

(use-package modus-vivendi-theme)

;; fonts
(set-face-attribute 'default nil
		    :family "DejaVu Sans Mono"
		    :height 110)

(set-face-attribute 'fixed-pitch nil
		    :family "DejaVu Sans Mono"
		    :height 110)

(set-face-attribute 'variable-pitch nil
		    :family "DejaVu Serif"
		    :height 120)

;; unicode
(use-package unicode-fonts
  :config
  (unicode-fonts-setup))

;;; Text editing
;; visual line mode
(global-visual-line-mode +1)

;; delete the selection when typing
(delete-selection-mode +1)

;; clipboard
(cuss save-interprogram-paste-before-kill t) ; save existing clipboard text to kill ring before replacing it

;;; Programming
;; Git
(use-package magit
  :bind
  ("C-x g" . magit-status)
  :config
  (add-to-list 'magit-no-confirm 'stage-all-changes))

(when (executable-find "cmake")
  (use-package libgit)
  (use-package magit-libgit))

(use-package forge
  :after magit
  :custom
  (forge-owned-accounts '(("duckwork"))))

;; Code formatting
(use-package format-all
  :hook
  (prog-mode . format-all-mode))

;; display
(add-hook 'prog-mode-hook #'prettify-symbols-mode)

;; parentheses
(cuss show-paren-style 'mixed)
(show-paren-mode +1)

(use-package smartparens
  :init
  (defun acdw/setup-smartparens ()
    (require 'smartparens-config)
    (smartparens-mode +1))
  :hook
  (prog-mode . acdw/setup-smartparens))

(use-package rainbow-delimiters
  :hook
  (prog-mode . rainbow-delimiters-mode))

;; line numbers
(add-hook 'prog-mode-hook
	  (if (and (fboundp 'display-line-numbers-mode)
		   (display-graphic-p))
	      #'display-line-numbers-mode
	    #'linum-mode))