-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
350 lines (277 loc) · 11.1 KB
/
init.el
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
(require 'package)
(setq package-archives '(
("melpa" . "http://melpa.milkbox.net/packages/")
("gnu" . "http://elpa.gnu.org/packages/")
))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(markdown-mode
less-css-mode
js2-mode
yaml-mode
puppet-mode
systemd
clojure-mode
auto-complete
ac-cider
cider
kill-ring-search
expand-region
multi-term
;; anzu
fiplr
ido-vertical-mode
latest-clojure-libraries
py-autopep8
py-isort
go-eldoc
dockerfile-mode
magit-gh-pulls
paredit
powerline
rainbow-delimiters
company
flycheck
gitconfig-mode
toml-mode
terraform-mode
typescript-mode
dumb-jump
;; colors:
doom-themes
forest-blue-theme
cycle-themes
cyberpunk-theme
apropospriate-theme
material-theme
darktooth-theme
gruvbox-theme
base16-theme
subatomic256-theme
warm-night-theme
color-theme ;; http://www.nongnu.org/color-theme/
color-theme-sanityinc-solarized
color-theme-sanityinc-tomorrow
zenburn-theme
soothe-theme
solarized-theme ;; this is the one from bbatsov
planet-theme
niflheim-theme
distinguished-theme
colorsarenice-theme
noctilux-theme
darkburn-theme
clues-theme
gruber-darker-theme
ample-theme
phoenix-dark-pink-theme
underwater-theme
purple-haze-theme
bubbleberry-theme
cherry-blossom-theme
))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
(require 'cl)
;; better defaults
(setq-default visible-bell nil)
(global-linum-mode 1)
(global-set-key (kbd "C-c c") 'comment-dwim)
(global-set-key (kbd "M-l") 'goto-line)
(global-set-key (kbd "C-x C-a") 'ag)
(setq x-select-enable-clipboard t)
(global-set-key (kbd "M-c") 'kill-ring-save)
(defalias 'yes-or-no-p 'y-or-n-p)
(show-paren-mode 1)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq-default standard-indent 2)
(setq-default initial-buffer-choice t)
(setq-default initial-scratch-message "")
(setq-default show-trailing-whitespace t)
(setq-default vc-follow-symlinks t)
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(setq inhibit-startup-message t)
(setq-default make-backup-files nil)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Yes! Source: http://news.ycombinator.com/item?id=5197828
(setq mac-option-key-is-meta nil)
(setq mac-command-key-is-meta t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil)
(require 'yaml-mode)
(require 'dockerfile-mode)
(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.raml$" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.ronn" . markdwon-mode))
(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode))
(add-to-list 'auto-mode-alist '("\\.service$" . systemd-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'magic-mode-alist '("#!/usr/bin/env bundle exec ruby" . ruby-mode))
(set-face-attribute 'default nil :height 140)
(set-face-attribute 'default nil :family "Consolas")
;; http://stackoverflow.com/questions/7616761/even-when-emacsclient-is-started-in-a-terminal-window-system-is-non-nil
(defun color-config (&optional frame)
(select-frame frame)
(if window-system (load-theme 'planet t)
(load-theme 'zenburn t)))
;; for emacsclient:
(add-hook 'after-make-frame-functions 'color-config)
;; for regular emacs:
(color-config (selected-frame))
(if (equal system-type 'darwin)
(progn
(setq prefix "~/external_src/")
(add-to-list 'custom-theme-load-path "~/my_src/dotfiles/")
)
(progn
(setq prefix "/mnt/external/clones/")
(add-to-list 'custom-theme-load-path "~/mblair_src/dotfiles/")
))
(add-to-list 'custom-theme-load-path (concat prefix "emacs-color-themes/themes"))
(add-to-list 'custom-theme-load-path (concat prefix "emacs-deep-thought-theme"))
(require 'powerline)
(powerline-default-theme)
(Autoload 'kill-ring-search "kill-ring-search"
"Search the kill ring in the minibuffer."
(interactive))
(global-set-key "\M-\C-y" 'kill-ring-search)
(require 'expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)
;; basically all of this multi-term customization is from here:
;; http://rawsyntax.com/blog/learn-emacs-zsh-and-multi-term/
(require 'multi-term)
;; todo: fix this on linux
(setq multi-term-program "/usr/local/bin/zsh")
(add-hook 'term-mode-hook
(lambda ()
(setq term-buffer-maximum-size 10000)))
(add-hook 'term-mode-hook
(lambda ()
(add-to-list 'term-bind-key-alist '("M-[" . multi-term-prev))
(add-to-list 'term-bind-key-alist '("M-]" . multi-term-next))))
(add-hook 'term-mode-hook
(lambda ()
(define-key term-raw-map (kbd "C-y") 'term-paste)))
;; TODO Find out why this is screwing up the bg color on linum-mode.
;; (require 'anzu)
;; (global-anzu-mode +1)
(setq cider-repl-popup-stacktraces t)
;; Don't `C-x o` to a Cider REPL.
;; That's what `C-c C-z` is for.
;; Source:
;; http://stackoverflow.com/questions/4941960/how-do-i-make-emacs-other-window-command-ignore-terminal-windows/4948239#4948239
(defvar avoid-window-regexp "^\*cider\-repl")
(defun my-other-window ()
"Similar to 'other-window, only try to avoid windows whose buffers match avoid-window-regexp"
(interactive)
(let* ((window-list (delq (selected-window) (window-list)))
(filtered-window-list (remove-if
(lambda (w)
(string-match-p avoid-window-regexp (buffer-name (window-buffer w))))
window-list)))
(if filtered-window-list
(select-window (car filtered-window-list))
(and window-list
(select-window (car window-list))))))
(global-set-key (kbd "C-x o") 'my-other-window)
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
(add-hook 'cider-repl-mode-hook 'paredit-mode)
(add-hook 'clojure-mode-hook #'paredit-mode)
(add-hook 'clojure-mode-hook #'rainbow-delimiters-mode)
;; C-c C-z to access it.
(setq cider-repl-pop-to-buffer-on-connect nil)
(setq cider-popup-stacktraces nil)
(savehist-mode 1)
(global-set-key (kbd "C-x f") 'fiplr-find-file)
(require 'ido-vertical-mode)
(ido-mode 1)
(ido-vertical-mode 1)
;; http://www.emacswiki.org/emacs/TransparentEmacs
(defun toggle-transparency ()
(interactive)
(if (/=
(cadr (frame-parameter nil 'alpha))
100)
(set-frame-parameter nil 'alpha '(100 100))
(set-frame-parameter nil 'alpha '(85 50))))
(global-set-key (kbd "C-c t") 'toggle-transparency)
;; (defun cider-namespace-refresh ()
;; (interactive)
;; (cider-interactive-eval
;; "(require 'clojure.tools.namespace.repl)
;; (clojure.tools.namespace.repl/refresh)"))
;; (define-key clojure-mode-map (kbd "M-r") 'cider-namespace-refresh)
;; go stuff
(add-to-list 'load-path (concat prefix "go-mode.el"))
(require 'go-mode)
(add-to-list 'load-path (concat prefix "gocode/emacs"))
(require 'go-autocomplete)
(require 'auto-complete-config)
(ac-config-default)
;; thanks, dustin + bradfitz
(defun my-go-mode-hook ()
(setq gofmt-command "goimports")
(add-hook 'before-save-hook 'gofmt-before-save)
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
"go vet && go build -v"))
(setq tab-width 8 indent-tabs-mode 1)
(local-set-key (kbd "M-.") 'godef-jump))
(add-hook 'go-mode-hook 'my-go-mode-hook)
(add-hook 'go-mode-hook 'go-eldoc-setup)
(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(setq-default js2-basic-offset 2)
(setq-default js2-strict-missing-semi-warning nil)
(add-hook 'before-save-hook 'py-autopep8-before-save)
;; http://www.emacswiki.org/emacs/DeletingWhitespace
(defun my-delete-leading-whitespace (start end)
"Delete whitespace at the beginning of each line in region."
(interactive "*r")
(save-excursion
(if (not (bolp)) (forward-line 1))
(delete-whitespace-rectangle (point) end nil)))
(global-set-key (kbd "C-x C-h") 'my-delete-leading-whitespace)
(require 'ac-cider)
(add-hook 'cider-mode-hook 'ac-flyspell-workaround)
(add-hook 'cider-mode-hook 'ac-cider-setup)
(add-hook 'cider-repl-mode-hook 'ac-cider-setup)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'cider-mode))
(defun set-auto-complete-as-completion-at-point-function ()
(setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'set-auto-complete-as-completion-at-point-function)
;; http://www.masteringemacs.org/article/find-files-faster-recent-files-package
(require 'recentf)
;; get rid of `find-file-read-only' and replace it with something
;; more useful.
(global-set-key (kbd "C-x C-r") 'ido-recentf-open)
;; enable recent files mode.
(recentf-mode t)
;; 50 files ought to be enough.
(setq recentf-max-saved-items 50)
(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
(require 'magit-gh-pulls)
(add-hook 'magit-mode-hook 'turn-on-magit-gh-pulls)
(add-hook 'after-init-hook 'global-company-mode)
(global-set-key (kbd "TAB") #'company-indent-or-complete-common)
(setq company-tooltip-align-annotations t)
(global-flycheck-mode)
(setq-default flycheck-disabled-checkers '(javascript-eslint javascript-jshint javascript-gjshint))
(require 'dumb-jump)