-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathabedra.el
381 lines (303 loc) · 10.4 KB
/
abedra.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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
(setq user-full-name "Aaron Bedra")
(setq user-mail-address "[email protected]")
(setenv "PATH" (concat "/usr/local/bin:/opt/local/bin:/usr/bin:/bin" (getenv "PATH")))
(setq exec-path (append exec-path '("/usr/local/bin")))
(require 'cl)
(load "package")
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(defvar abedra/packages '(ansible
ac-slime
auto-complete
autopair
cider
clojure-mode
company-irony
company-terraform
docker
dockerfile-mode
elpy
f
feature-mode
flycheck
graphviz-dot-mode
htmlize
magit
markdown-mode
org
paredit
powerline
rvm
smex
solarized-theme
terraform-mode
web-mode
writegood-mode
yaml-mode)
"Default packages")
(defun abedra/packages-installed-p ()
(loop for pkg in abedra/packages
when (not (package-installed-p pkg)) do (return nil)
finally (return t)))
(unless (abedra/packages-installed-p)
(message "%s" "Refreshing package database...")
(package-refresh-contents)
(dolist (pkg abedra/packages)
(when (not (package-installed-p pkg))
(package-install pkg))))
(setq inhibit-splash-screen t
initial-scratch-message nil
initial-major-mode 'org-mode)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(delete-selection-mode t)
(transient-mark-mode t)
(setq x-select-enable-clipboard t)
(setq-default indicate-empty-lines t)
(when (not indicate-empty-lines)
(toggle-indicate-empty-lines))
(setq tab-width 2
indent-tabs-mode nil)
(setq make-backup-files nil)
(defalias 'yes-or-no-p 'y-or-n-p)
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "C-;") 'comment-or-uncomment-region)
(global-set-key (kbd "M-/") 'hippie-expand)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-c C-k") 'compile)
(global-set-key (kbd "C-x g") 'magit-status)
(setq echo-keystrokes 0.1
use-dialog-box nil
visible-bell t)
(show-paren-mode t)
(defvar abedra/vendor-dir (expand-file-name "vendor" user-emacs-directory))
(add-to-list 'load-path abedra/vendor-dir)
(dolist (project (directory-files abedra/vendor-dir t "\\w+"))
(when (file-directory-p project)
(add-to-list 'load-path project)))
(setq org-log-done t
org-todo-keywords '((sequence "TODO" "INPROGRESS" "DONE"))
org-todo-keyword-faces '(("INPROGRESS" . (:foreground "blue" :weight bold))))
(add-hook 'org-mode-hook
(lambda ()
(flyspell-mode)))
(add-hook 'org-mode-hook
(lambda ()
(writegood-mode)))
(global-set-key (kbd "C-c a") 'org-agenda)
(setq org-agenda-show-log t
org-agenda-todo-ignore-scheduled t
org-agenda-todo-ignore-deadlines t)
(setq org-agenda-files (list "~/Dropbox/org/personal.org"))
(require 'org)
(require 'org-install)
(require 'org-habit)
(add-to-list 'org-modules "org-habit")
(setq org-habit-preceding-days 7
org-habit-following-days 1
org-habit-graph-column 80
org-habit-show-habits-only-for-today t
org-habit-show-all-today t)
(require 'ob)
(org-babel-do-load-languages
'org-babel-load-languages
'((shell . t)
(ditaa . t)
(plantuml . t)
(dot . t)
(ruby . t)
(js . t)
(C . t)))
(add-to-list 'org-src-lang-modes (quote ("dot". graphviz-dot)))
(add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
(defvar org-babel-default-header-args:clojure
'((:results . "silent") (:tangle . "yes")))
(defun org-babel-execute:clojure (body params)
(lisp-eval-string body)
"Done!")
(provide 'ob-clojure)
(setq org-src-fontify-natively t
org-confirm-babel-evaluate nil)
(add-hook 'org-babel-after-execute-hook (lambda ()
(condition-case nil
(org-display-inline-images)
(error nil)))
'append)
(add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))
(setq org-plantuml-jar-path "~/.emacs.d/vendor/plantuml.jar")
(setq smex-save-file (expand-file-name ".smex-items" user-emacs-directory))
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
(ido-mode t)
(setq ido-enable-flex-matching t
ido-use-virtual-buffers t)
(setq column-number-mode t)
(setq backup-directory-alist `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
(require 'autopair)
(setq lisp-modes '(lisp-mode
emacs-lisp-mode
common-lisp-mode
scheme-mode
clojure-mode))
(defvar lisp-power-map (make-keymap))
(define-minor-mode lisp-power-mode "Fix keybindings; add power."
:lighter " (power)"
:keymap lisp-power-map
(paredit-mode t))
(define-key lisp-power-map [delete] 'paredit-forward-delete)
(define-key lisp-power-map [backspace] 'paredit-backward-delete)
(defun abedra/engage-lisp-power ()
(lisp-power-mode t))
(dolist (mode lisp-modes)
(add-hook (intern (format "%s-hook" mode))
#'abedra/engage-lisp-power))
(setq inferior-lisp-program "clisp")
(setq scheme-program-name "racket")
(require 'auto-complete-config)
(ac-config-default)
(defun untabify-buffer ()
(interactive)
(untabify (point-min) (point-max)))
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(defun cleanup-buffer ()
"Perform a bunch of operations on the whitespace content of a buffer."
(interactive)
(indent-buffer)
(untabify-buffer)
(delete-trailing-whitespace))
(defun cleanup-region (beg end)
"Remove tmux artifacts from region."
(interactive "r")
(dolist (re '("\\\\│\·*\n" "\W*│\·*"))
(replace-regexp re "" nil beg end)))
(global-set-key (kbd "C-x M-t") 'cleanup-region)
(global-set-key (kbd "C-c n") 'cleanup-buffer)
(setq-default show-trailing-whitespace t)
(setq flyspell-issue-welcome-flag nil)
(if (eq system-type 'darwin)
(setq-default ispell-program-name "/usr/local/bin/aspell")
(setq-default ispell-program-name "/usr/bin/aspell"))
(setq-default ispell-list-command "list")
(require 'f)
(setq eshell-visual-commands
'("less" "tmux" "htop" "top" "bash" "zsh" "fish"))
(setq eshell-visual-subcommands
'(("git" "log" "l" "diff" "show")))
;; Prompt with a bit of help from http://www.emacswiki.org/emacs/EshellPrompt
(defmacro with-face (str &rest properties)
`(propertize ,str 'face (list ,@properties)))
(defun eshell/abbr-pwd ()
(let ((home (getenv "HOME"))
(path (eshell/pwd)))
(cond
((string-equal home path) "~")
((f-ancestor-of? home path) (concat "~/" (f-relative path home)))
(path))))
(defun eshell/my-prompt ()
(let ((header-bg "#161616"))
(concat
(with-face (eshell/abbr-pwd) :foreground "#008700")
(if (= (user-uid) 0)
(with-face "#" :foreground "red")
(with-face "$" :foreground "#2345ba"))
" ")))
(setq eshell-prompt-function 'eshell/my-prompt)
(setq eshell-highlight-prompt nil)
(setq eshell-prompt-regexp "^[^#$\n]+[#$] ")
(setq eshell-cmpl-cycle-completions nil)
(require 'powerline)
(powerline-default-theme)
(setq user-email-address "[email protected]"
gnus-select-method
'(nnimap "personal"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl))
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 587
message-send-mail-function 'smtpmail-send-it
nntp-authinfo-file "~/.authinfo.gpg"
gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]"
gnus-agent nil
gnus-message-archive-group nil
gnus-fetch-old-headers 'some)
(add-hook 'gnus-summary-mode-hook 'my-gnus-summary-keys)
(defun my-gnus-summary-keys ()
(local-set-key "y" 'gmail-archive)
(local-set-key "$" 'gmail-report-spam))
(defun gmail-archive ()
(interactive)
(gnus-summary-move-article nil "nnimap+imap.gmail.com:[Gmail]/All Mail"))
(defun gmail-report-spam ()
(interactive)
(gnus-summary-move-article nil "nnimap+imap.gmail.com:[Gmail]/Spam"))
(global-company-mode)
(add-hook 'c-mode-hook
(lambda ()
(irony-mode)
(company-mode)
(autopair-mode)
(add-to-list 'company-backends 'company-irony)))
(add-hook 'c-mode-common-hook
(lambda ()
(define-key c-mode-base-map (kbd "C-c C-k") 'compile)))
(add-hook 'terraform-mode-hook
(lambda ()
(company-terraform-init)
(autopair-mode)
(auto-complete-mode)))
(elpy-enable)
(add-to-list 'auto-mode-alist '("\\.zsh$" . shell-script-mode))
(add-to-list 'auto-mode-alist '("\\.gitconfig$" . conf-mode))
(setq web-mode-style-padding 2)
(setq web-mode-script-padding 2)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(add-to-list 'auto-mode-alist '("\\.hbs$" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb$" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html$" . web-mode))
(add-hook 'ruby-mode-hook
(lambda ()
(autopair-mode)))
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Guardfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml$" . yaml-mode))
(defun js-custom ()
"js-mode-hook"
(setq js-indent-level 2))
(add-hook 'js-mode-hook 'js-custom)
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mdown$" . markdown-mode))
(add-hook 'markdown-mode-hook
(lambda ()
(visual-line-mode t)
(writegood-mode t)
(flyspell-mode t)))
(setq markdown-command "pandoc --smart -f markdown -t html")
(setq markdown-css-paths `(,(expand-file-name "markdown.css" abedra/vendor-dir)))
(load-theme 'wombat t)
(when window-system
(set-default-font "JetBrains Mono")
(set-face-attribute 'default nil :height 130))
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region (point-min) (point-max))
(toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)