-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathinit.el
executable file
·468 lines (387 loc) · 12.4 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
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
;;; init.el - Fragor Maximus -*- lexical-binding: t; -*-
(mapc
(lambda (mode)
(when (fboundp mode)
(funcall mode -1)))
'(menu-bar-mode tool-bar-mode scroll-bar-mode))
(require 'cask "~/.cask/cask.el")
(cask-initialize)
(require 'pallet)
(require 's)
(require 'f)
(require 'ht)
(require 'git)
(require 'ert)
(require 'use-package)
(setq default-directory (f-full (getenv "HOME")))
(defun load-local (file)
(load (f-expand file user-emacs-directory)))
(load-local "defuns")
(load-local "misc")
(when (eq system-type 'darwin)
(load-local "osx"))
(load-theme 'solarized-light :no-confirm)
(add-hook 'emacs-startup-hook
(lambda ()
(when (string= (buffer-name) "*scratch*")
(animate-string "(message \"Welcome Sir!\")" (/ (frame-height) 2)))))
;;;; Packages
(use-package hl-line
:config (set-face-background 'hl-line "#073642"))
(use-package dash
:config (dash-enable-font-lock))
(use-package dired-x)
(use-package nyan-mode
:init (nyan-mode 1))
(use-package smex
:init (smex-initialize)
:bind ("M-x" . smex))
(use-package multiple-cursors
:bind (("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)))
(use-package popwin
:config (popwin-mode 1))
(use-package projectile
:init (projectile-mode 1)
:config
(progn
(setq projectile-enable-caching t)
(setq projectile-require-project-root nil)
(setq projectile-completion-system 'ivy)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(add-to-list 'projectile-globally-ignored-files ".DS_Store")))
(use-package drag-stuff
:init (drag-stuff-global-mode 1)
:bind (("M-N" . drag-stuff-down)
("M-P" . drag-stuff-up)))
(use-package misc
:bind ("M-z" . zap-up-to-char))
(use-package magit
:init
(progn
(use-package magit-blame)
(bind-key "C-c C-a" 'magit-just-amend magit-mode-map))
:config
(progn
(setq magit-completing-read-function 'ivy-completing-read)
(setq magit-branch-arguments nil))
:bind ("C-x g" . magit-status))
(use-package expand-region
:bind ("C-=" . er/expand-region))
(use-package cua-base
:init (cua-mode 1)
:config
(progn
(setq cua-enable-cua-keys nil)
(setq cua-toggle-set-mark nil)))
(use-package uniquify
:config (setq uniquify-buffer-name-style 'forward))
(use-package saveplace
:init (save-place-mode 1)
:config
(progn
(setq-default save-place t)
(setq save-place-limit nil)))
(use-package diff-hl
:init (global-diff-hl-mode)
:config (add-hook 'vc-checkin-hook 'diff-hl-update))
(use-package windmove
:config (windmove-default-keybindings 'shift))
(use-package ruby-mode
:config
(progn
(use-package rvm
:init (rvm-use-default)
:config (setq rvm-verbose nil))
(use-package rbenv
:init (global-rbenv-mode))
(use-package ruby-tools)
(use-package rspec-mode
:config
(progn
(add-hook 'compilation-mode-hook
(lambda ()
(when (eq major-mode 'rspec-compilation-mode)
(setq compilation-scroll-output t)
(local-set-key (kbd "g") (lambda () (interactive) (rspec-rerun))))))
(setq rspec-use-rvm t)
(setq rspec-use-rake-when-possible nil)
(defadvice rspec-compile (around rspec-compile-around activate)
"Use BASH shell for running the specs because of ZSH issues."
(let ((shell-file-name "/bin/bash"))
ad-do-it))))
(setq ruby-align-to-stmt-keywords '(begin if while unless until case for def))
(setq ruby-insert-encoding-magic-comment nil)
(setq ruby-deep-indent-paren nil))
:bind (("C-M-h" . backward-kill-word)
("C-M-n" . scroll-up-five)
("C-M-p" . scroll-down-five))
:mode (("\\.rake$" . ruby-mode)
("\\.gemspec$" . ruby-mode)
("\\.ru$" . ruby-mode)
("Rakefile$" . ruby-mode)
("Gemfile$" . ruby-mode)
("Capfile$" . ruby-mode)
("Guardfile$" . ruby-mode)))
(use-package markdown-mode
:config
(progn
(bind-key "M-n" 'open-line-below markdown-mode-map)
(bind-key "M-p" 'open-line-above markdown-mode-map))
:mode (("\\.markdown$" . markdown-mode)
("\\.md$" . markdown-mode)))
(use-package smartparens
:init
(progn
(use-package smartparens-config)
(use-package smartparens-ruby)
(use-package smartparens-html)
(smartparens-global-mode 1)
(show-smartparens-global-mode 1))
:config
(progn
(setq smartparens-strict-mode t)
(sp-local-pair 'emacs-lisp-mode "`" nil :when '(sp-in-string-p)))
:bind
(("C-M-k" . sp-kill-sexp-with-a-twist-of-lime)
("C-M-f" . sp-forward-sexp)
("C-M-b" . sp-backward-sexp)
("C-M-n" . sp-up-sexp)
("C-M-d" . sp-down-sexp)
("C-M-u" . sp-backward-up-sexp)
("C-M-p" . sp-backward-down-sexp)
("C-M-w" . sp-copy-sexp)
("M-s" . sp-splice-sexp)
("M-r" . sp-splice-sexp-killing-around)
("C-)" . sp-forward-slurp-sexp)
("C-}" . sp-forward-barf-sexp)
("C-(" . sp-backward-slurp-sexp)
("C-{" . sp-backward-barf-sexp)
("M-S" . sp-split-sexp)
("M-J" . sp-join-sexp)
("C-M-t" . sp-transpose-sexp)))
(use-package flycheck
:config
(progn
(setq flycheck-display-errors-function nil)
(add-hook 'after-init-hook 'global-flycheck-mode)))
(use-package flycheck-cask
:init (add-hook 'flycheck-mode-hook 'flycheck-cask-setup))
(use-package yasnippet
:init
(progn
(add-hook 'after-save-hook
(lambda ()
(when (eql major-mode 'snippet-mode)
(yas-reload-all))))
(setq yas-snippet-dirs (list (f-expand "snippets" user-emacs-directory)))
(setq yas-indent-line 'fixed)
(yas-global-mode 1))
:mode ("\\.yasnippet" . snippet-mode))
(use-package yaml-mode
:mode ("\\.yml$" . yaml-mode))
(use-package feature-mode
:mode ("\\.feature$" . feature-mode)
:config
(add-hook 'feature-mode-hook
(lambda ()
(electric-indent-mode -1))))
(use-package cc-mode
:config
(progn
(add-hook 'c-mode-hook (lambda () (c-set-style "bsd")))
(add-hook 'java-mode-hook (lambda () (c-set-style "bsd")))
(setq tab-width 2)
(setq c-basic-offset 2)))
(use-package css-mode
:config (setq css-indent-offset 2))
(use-package js-mode
:mode ("\\.json$" . js-mode)
:init
(progn
(add-hook 'js-mode-hook (lambda () (setq js-indent-level 2)))))
(use-package js2-mode
:mode (("\\.js$" . js2-mode)
("Jakefile$" . js2-mode))
:interpreter ("node" . js2-mode)
:bind (("C-a" . back-to-indentation-or-beginning-of-line)
("C-M-h" . backward-kill-word))
:config
(progn
(add-hook 'js2-mode-hook (lambda () (setq js2-basic-offset 2)))
(add-hook 'js2-mode-hook (lambda ()
(bind-key "M-j" 'join-line-or-lines-in-region js2-mode-map)))))
(use-package coffee-mode
:config
(progn
(add-hook 'coffee-mode-hook
(lambda ()
(bind-key "C-j" 'coffee-newline-and-indent coffee-mode-map)
(bind-key "C-M-h" 'backward-kill-word coffee-mode-map)
(setq coffee-tab-width 2)))))
(use-package nvm)
(use-package sh-script
:config (setq sh-basic-offset 2))
(use-package emacs-lisp-mode
:init
(progn
(use-package eldoc
:init (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode))
(use-package macrostep
:bind ("C-c e" . macrostep-expand))
(use-package ert
:config (add-to-list 'emacs-lisp-mode-hook 'ert--activate-font-lock-keywords)))
:config
(progn
(setq tab-always-indent 'complete)
(add-to-list 'completion-styles 'initials t))
:bind (("M-." . find-function-at-point)
("M-&" . complete-symbol))
:interpreter (("emacs" . emacs-lisp-mode)))
(use-package html-script-src)
(use-package haml-mode)
(use-package sass-mode)
(use-package eshell
:bind ("M-e" . eshell)
:init
(add-hook 'eshell-first-time-mode-hook
(lambda ()
(add-to-list 'eshell-visual-commands "htop")))
:config
(progn
(setq eshell-history-size 5000)
(setq eshell-save-history-on-exit t)))
(use-package web-mode
:init (progn
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)))
:config (progn
(add-hook 'web-mode-hook
(lambda ()
(setq web-mode-enable-css-colorization t)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-style-padding 2)
(setq web-mode-script-padding 2)))))
(use-package zencoding-mode
:init (add-hook 'web-mode-hook 'zencoding-mode)
:config
(progn
(setq zencoding-preview-default nil)
(setq zencoding-indentation 2)
(add-hook 'zencoding-mode-hook
(lambda ()
(define-key zencoding-mode-keymap (kbd "M-RET") 'zencoding-expand-line)))))
(use-package prodigy
:config
(progn
(add-hook 'prodigy-mode-hook (lambda () (setq-local show-trailing-whitespace nil))))
:bind ("C-x p" . prodigy))
(use-package ert-async
:config (progn
(remove-hook 'emacs-lisp-mode-hook 'ert--activate-font-lock-keywords)
(add-hook 'emacs-lisp-mode-hook 'ert-async-activate-font-lock-keywords)))
(use-package ibuffer
:config (setq ibuffer-expert t)
:bind ("C-x C-b" . ibuffer))
(use-package cl-lib-highlight
:init (cl-lib-highlight-initialize))
(use-package httprepl)
(use-package cask-mode)
(use-package ag)
(use-package git-gutter
:init (global-git-gutter-mode +1))
(use-package ibuffer-projectile
:init (add-hook 'ibuffer-hook
(lambda ()
(ibuffer-projectile-set-filter-groups)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic)))))
(use-package rainbow-delimiters
:config (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
(use-package overseer)
(use-package visible-mark
:init (global-visible-mark-mode 1))
(use-package beacon
:init (beacon-mode 1))
(use-package avy
:bind (("C-\\" . avy-goto-char)
("M-g" . avy-goto-line))
:config (avy-setup-default))
(use-package mocha
:init
(progn (setq mocha-reporter "spec"))
:config
(progn
(add-hook 'mocha-compilation-mode-hook
(lambda () (setq-local show-trailing-whitespace nil))))
:bind (("C-c , v" . mocha-test-file)
("C-c , s" . mocha-test-at-point)))
(use-package mustache)
(use-package ivy
:init (ivy-mode 1)
:config
(progn
(setq ivy-use-virtual-buffers t)
(setq ivy-extra-directories nil)
(bind-key "C-f" 'ivy-alt-done ivy-minibuffer-map)
(bind-key "C-b" 'ivy-backward-delete-char ivy-minibuffer-map))
:bind
(("C-s" . swiper)
("C-r" . swiper)
("C-c C-r" . ivy-resume)
("C-c a" . counsel-ag)
("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file)))
(use-package scala-mode
:interpreter ("scala" . scala-mode))
(use-package csv-mode)
(use-package idle-highlight-mode
:init (idle-highlight-mode 1))
(use-package flyspell
:init (flyspell-mode +1))
(use-package dockerfile-mode)
;;;; Bindings
(bind-key "C-a" 'back-to-indentation-or-beginning-of-line)
(bind-key "C-7" 'comment-or-uncomment-current-line-or-region)
(bind-key "C-6" 'linum-mode)
(bind-key "C-v" 'scroll-up-five)
(bind-key "C-j" 'newline-and-indent)
(bind-key "M-n" 'open-line-below)
(bind-key "M-p" 'open-line-above)
(bind-key "M-+" 'text-scale-increase)
(bind-key "M-_" 'text-scale-decrease)
(bind-key "M-j" 'join-line-or-lines-in-region)
(bind-key "M-v" 'scroll-down-five)
(bind-key "M-k" 'kill-this-buffer)
(bind-key "M-o" 'other-window)
(bind-key "M-1" 'delete-other-windows)
(bind-key "M-2" 'split-window-below)
(bind-key "M-3" 'split-window-right)
(bind-key "M-0" 'delete-window)
(bind-key "M-}" 'next-buffer)
(bind-key "M-{" 'previous-buffer)
(bind-key "M-`" 'other-frame)
(bind-key "M-w" 'kill-region-or-thing-at-point)
(bind-key "C-c g" 'google)
(bind-key "C-c d" 'duplicate-current-line-or-region)
(bind-key "C-c n" 'clean-up-buffer-or-region)
(bind-key "C-c s" 'swap-windows)
(bind-key "C-c r" 'rename-this-buffer-and-file)
(bind-key "C-c k" 'delete-this-buffer-and-file)
(bind-key "C-M-h" 'backward-kill-word)
(bind-key "C-c C-n" 'todo)
(bind-key
"C-x C-c"
(lambda ()
(interactive)
(when (y-or-n-p "Quit Emacs? ")
(save-buffers-kill-emacs))))
(bind-key
"C-8"
(lambda ()
(interactive)
(find-file user-init-file)))
;;;; Sandbox
(let ((sandbox-path (f-expand "sandbox" user-emacs-directory)))
(when (f-dir? sandbox-path)
(-each (f--files sandbox-path (f-ext? it "el")) 'load)))