/
init.el
447 lines (374 loc) · 14.8 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
(add-to-list 'load-path "~/.emacs.d/vendor/")
;; Default to home dir
(cd "~/")
;; Using MELPA for packages
(when (>= emacs-major-version 24)
(require 'package)
(when (>= emacs-major-version 24)
(setq package-archives '(("melpa" . "http://melpa.org/packages/")))))
;; Load necessary packages
(package-initialize)
(setq my-required-packages
(list 'magit
'solarized-theme
'swiper ;; visual regex search
'expand-region
'wrap-region
'exec-path-from-shell
'visual-regexp
'buffer-move ;; used for rotating buffers
'visual-regexp-steroids
'ido-vertical-mode
'yafolding
's
'coffee-mode
'git-timemachine ;; Walk through git revisions of a file
'sourcemap
'slim-mode
'bundler
'projectile
'projectile-rails
'scss-mode
'sass-mode
'f
'jump
'discover
'fiplr
'yard-mode ;; fontification in ruby comments
'goto-gem ;; Open dired in a gem directory
'ruby-tools
'ruby-block
'ruby-additional
'ruby-hash-syntax
'ruby-refactor
'dired-details
'yasnippet
'yari
'ibuffer-vc
'rvm
'rinari
'web-mode
'feature-mode
'auto-compile
'yaml-mode
'rspec-mode
'undo-tree
'inf-ruby
'smartscan ;; Quickly jumps between other symbols found at point in Emacs
'discover-my-major
'goto-chg
'anzu
'fullframe
))
(dolist (package my-required-packages)
(when (not (package-installed-p package))
(package-refresh-contents)
(package-install package)))
;; Set PATH, MANPATH and exec-path
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
;; Emacs's version of `tail -f`
;; or you can use M-x auto-revert-tail-mode
(add-to-list 'auto-mode-alist '("\\.log\\'" . auto-revert-mode))
;; for smooth scrolling and disabling the automatical recentering of emacs when moving the cursor
(setq scroll-margin 5
scroll-preserve-screen-position 1)
;; Display full path in the window title bar
(setq-default frame-title-format '((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name)) "%f"))))
;; Disable the scroll bar
(scroll-bar-mode 0)
(require 'anzu) ;; Shows a count of search matches
(global-anzu-mode +1)
(global-set-key (kbd "M-%") 'anzu-query-replace)
(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp)
(require 'iso-transl) ;; Enable accents in GUI
(require 'goto-chg) ;; Go to last change
(require 'fullframe)
(fullframe magit-status magit-mode-quit-window nil)
(require 'slim-mode)
;; Set fill-column
(setq-default fill-column 80)
;; Enable SmartScan
(smartscan-mode 1)
;; No splash screen
(setq inhibit-startup-screen t)
;; Don't warn me when opening large files
(setq large-file-warning-threshold nil)
;; Enable copy and pasting from clipboard
(setq x-select-enable-clipboard t)
;; Enable IDO
(load "~/.emacs.d/my-ido.el")
;; To get rid of Weird color escape sequences in Emacs.
;; Instruct Emacs to use emacs term-info not system term info
;; http://stackoverflow.com/questions/8918910/weird-character-zsh-in-emacs-terminal
(setq system-uses-terminfo nil)
;; Prefer utf-8 encoding
(prefer-coding-system 'utf-8)
;; Display information about the current function
(require 'eldoc)
;; Configure hippie-expand
(defadvice hippie-expand (around hippie-expand-case-fold)
"Try to do case-sensitive matching (not effective with all functions)."
(let ((case-fold-search nil))
ad-do-it))
(ad-activate 'hippie-expand)
(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
try-expand-dabbrev-all-buffers
))
;; Web mode
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
;; Coffee Script
(setq coffee-args-compile '("-c" "-m")) ;; generating sourcemap
(add-hook 'coffee-after-compile-hook 'sourcemap-goto-corresponding-point)
;; If you want to remove sourcemap file after jumping corresponding point
(defun my/coffee-after-compile-hook (props)
(sourcemap-goto-corresponding-point props)
(delete-file (plist-get props :sourcemap)))
(add-hook 'coffee-after-compile-hook 'my/coffee-after-compile-hook)
;; Custom themes
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
;; Choosing a dark theme
;; (load-theme 'base16-default t)
;; (load-theme 'tango-dark t)
;;(load-theme 'wilson t)
(load-theme 'solarized-dark t)
;; Always open split windows horizontally
(setq split-height-threshold 0)
(setq split-width-threshold nil)
;; Stop that bell sound
(setq visible-bell nil)
(setq ring-bell-function (lambda () (message "*beep*")))
;; Yaml
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;; Load custom snippets
(require 'yasnippet)
(yas-global-mode 1)
(setq yas-snippet-dirs "~/.emacs.d/snippets")
;; Disable skeletons in projectile-rails
(setq projectile-rails-expand-snippet nil)
;; Always ident with 2 spaces
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq-default c-basic-offset 2)
(setq css-indent-offset 2)
(setq js-indent-level 2)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-css-indent-offset 2)
;; Use the short version for yes/no
(fset 'yes-or-no-p 'y-or-n-p)
;; Confirm quit
(setq confirm-kill-emacs 'yes-or-no-p)
;; Always refresh file contents if they change on disk
(global-auto-revert-mode 1)
;; Diable bold and underline faces
(when (display-graphic-p)
(menu-bar-mode 1)
(set-face-attribute 'default nil :foreground "gray" :font "Inconsolata-13" :height 155))
;; ;; Showing whitespace
(require 'whitespace)
(setq whitespace-line-column 80) ;; limit line length
;;(setq whitespace-style '(spaces tabs newline space-mark tab-mark newline-mark lines-tail))
(setq whitespace-style '(spaces tabs newline space-mark tab-mark newline-mark face lines-tail))
(setq whitespace-display-mappings
;; all numbers are Unicode codepoint in decimal. e.g. (insert-char 182 1)
'(
(space-mark nil) ; 32 SPACE, 183 MIDDLE DOT
(newline-mark 10 [172 10]) ; 10 LINE FEED
(tab-mark 9 [183 9] [92 9]) ; 9 TAB, MIDDLE DOT
))
;;(add-hook 'prog-mode-hook 'whitespace-mode)
(setq whitespace-global-modes '(not org-mode web-mode "Web" emacs-lisp-mode))
(global-whitespace-mode)
;; Setting a default line-height
(setq-default line-spacing 1)
;; store all backup and autosave files in the tmp dir
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;; Highlight parenthesis
(show-paren-mode 1)
;; Save point position between sessions
(require 'saveplace)
(setq-default save-place t)
(setq save-place-file (expand-file-name ".places" user-emacs-directory))
;; Dired
(load "~/.emacs.d/my-dired")
;; Magit
(load "~/.emacs.d/my-magit")
;; Custom functions
(load "~/.emacs.d/my-functions")
;; Make CMD work like ALT (on the Mac)
(setq mac-command-modifier 'meta)
;; (setq mac-option-modifier 'none)
;; (setq mac-option-key-is-meta t)
;; (setq mac-right-option-modifier nil)
;; SRGB support
(setq ns-use-srgb-colorspace t)
;; Default frame size
(setq initial-frame-alist
'((top . 10) (left . 50) (width . 185) (height . 55)))
;; Making dabbrev a bit nicer
(setq dabbrev-abbrev-skip-leading-regexp ":")
(setq dabbrev-backward-only t)
;; Use frames instead of windows for compilation popups
;; (setq-default display-buffer-reuse-frames t)
;; Format line numbers
(setq linum-format "%4d ")
;; M-f should move to the beginning of the next word
(require 'misc)
;; Turn on the left fringe
(set-fringe-mode '(10 . 0)) ;; 10px left, 0px right
;; Remove the fringe indicators
(when (boundp 'fringe-indicator-alist)
(setq-default fringe-indicator-alist
'(
(continuation . nil)
(overlay-arrow . nil)
(up . nil)
(down . nil)
(top . nil)
(bottom . nil)
(top-bottom . nil)
(empty-line . nil)
(unknown . nil))))
;; Disabling the toolbar
(tool-bar-mode 0)
;; IBuffer
(setq ibuffer-formats
'((mark modified read-only " "
(name 50 50 :left :elide) " "
filename-and-process)
(mark " " (name 16 -1) " " filename)))
(setq ibuffer-show-empty-filter-groups nil)
;;(add-to-list 'ibuffer-never-show-predicates "TAGS")
;;(add-to-list 'ibuffer-never-show-predicates "*Backtrace*")
(add-hook 'ibuffer-mode-hook
'(lambda ()
(ibuffer-vc-set-filter-groups-by-vc-root)))
;; Uniquify buffers
(require 'uniquify)
(setq
uniquify-buffer-name-style 'post-forward
uniquify-separator " : ")
;; Ruby
(load "~/.emacs.d/my-ruby")
;; Discover mode
(require 'discover)
(global-discover-mode 1)
;; Scss
(autoload 'scss-mode "scss-mode")
(add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
;; Undo tree
(require 'undo-tree)
(global-undo-tree-mode 1)
(defun prelude-move-beginning-of-line (arg)
"Move point back to indentation of beginning of line.
Move point to the first non-whitespace character on this line.
If point is already there, move to the beginning of the line.
Effectively toggle between the first non-whitespace character and
the beginning of the line.
If ARG is not nil or 1, move forward ARG - 1 lines first. If
point reaches the beginning or end of the buffer, stop there."
(interactive "^p")
(setq arg (or arg 1))
;; Move lines first
(when (/= arg 1)
(let ((line-move-visual nil))
(forward-line (1- arg))))
(let ((orig-point (point)))
(back-to-indentation)
(when (= orig-point (point))
(move-beginning-of-line 1))))
(global-set-key [remap move-beginning-of-line]
'prelude-move-beginning-of-line)
(defun open-emacs-init-file()
"Opens the init.el file"
(interactive)
(find-file (expand-file-name "init.el" user-emacs-directory)))
;; Key bindings
(global-set-key (kbd "M-z") 'zap-up-to-char)
(global-set-key (kbd "M-f") 'forward-to-word)
(global-set-key (kbd "M-F") 'forward-word)
(global-set-key (kbd "C-c g x") 'git-extract-number-from-branch-name)
(global-set-key (kbd "C-c g s") 'magit-status)
(global-set-key (kbd "C-h C-m") 'discover-my-major)
(global-set-key (kbd "C-x C-5") 'toggle-frame-split)
(global-set-key "\C-x2" (lambda () (interactive)(split-window-vertically) (other-window 1)))
(global-set-key "\C-x3" (lambda () (interactive)(split-window-horizontally) (other-window 1)))
(global-set-key (kbd "<f2>") 'open-emacs-init-file)
(global-unset-key (kbd "C-c C-x"))
(global-set-key (kbd "C-c C-x") 'execute-extended-command)
(global-set-key (kbd "C-c a") 'ag)
(global-set-key (kbd "C-c j") 'dired-jump)
(global-set-key (kbd "C-c d") 'duplicate-line)
;;(global-set-key (kbd "C-x b") 'helm-buffers-list)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-x k") 'kill-this-buffer)
(global-set-key (kbd "C-c K") 'kill-buffer-and-window)
(global-set-key (kbd "C-c o") 'vi-open-line-below)
(global-set-key (kbd "C-c O") 'vi-open-line-above)
(global-set-key (kbd "C-c , s") 'rspec-verify-single)
(global-set-key (kbd "C-c , r") 'rspec-rerun)
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "C-r") 'isearch-backward-regexp)
(global-set-key (kbd "M-/") 'hippie-expand)
(global-set-key (kbd "M-<SPC>") 'cycle-spacing)
(global-set-key [(control ?.)] 'goto-last-change)
(global-set-key [(control ?,)] 'goto-last-change-reverse)
(global-set-key (kbd "<down>") (ignore-error-wrapper 'windmove-down))
(global-set-key (kbd "<up>") (ignore-error-wrapper 'windmove-up))
(global-set-key (kbd "<left>") (ignore-error-wrapper 'windmove-left))
(global-set-key (kbd "<right>") (ignore-error-wrapper 'windmove-right))
(define-key isearch-mode-map (kbd "C-<return>") 'isearch-exit-other-end)
;; Load a personal.el file if it exists
;; to be able to override stuff in here
(if (file-exists-p "~/.emacs.d/personal.el")
(load "personal"))
(server-start)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
(quote
("a8245b7cc985a0610d71f9852e9f2767ad1b852c2bdea6f4aadc12cce9c4d6d0" "cdc7555f0b34ed32eb510be295b6b967526dd8060e5d04ff0dce719af789f8e5" "3a727bdc09a7a141e58925258b6e873c65ccf393b2240c51553098ca93957723" "6a37be365d1d95fad2f4d185e51928c789ef7a4ccf17e7ca13ad63a8bf5b922f" "756597b162f1be60a12dbd52bab71d40d6a2845a3e3c2584c6573ee9c332a66e" "af9761c65a81bd14ee3f32bc2ffc966000f57e0c9d31e392bc011504674c07d6" "a4f8d45297894ffdd98738551505a336a7b3096605b467da83fae00f53b13f01" "1affe85e8ae2667fb571fc8331e1e12840746dae5c46112d5abb0c3a973f5f5a" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "de2c46ed1752b0d0423cde9b6401062b67a6a1300c068d5d7f67725adc6c3afb" "405fda54905200f202dd2e6ccbf94c1b7cc1312671894bc8eca7e6ec9e8a41a2" "41b6698b5f9ab241ad6c30aea8c9f53d539e23ad4e3963abff4b57c0f8bf6730" "b47a3e837ae97400c43661368be754599ef3b7c33a39fd55da03a6ad489aafee" default)))
'(feature-cucumber-command "bundle exec cucumber {options} {feature}")
'(magit-emacsclient-executable "/usr/local/bin/emacsclient")
'(magit-restore-window-configuration t)
'(magit-server-window-for-commit nil)
'(rspec-spec-command "rspec")
'(rspec-use-bundler-when-possible nil)
'(rspec-use-rvm t)
'(rspec-use-spring-when-possible t)
'(scss-compile-at-save nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(compilation-mode-line-fail ((t (:inherit compilation-error :weight bold))))
'(diff-added ((t (:inherit diff-changed :foreground "#00cc33"))))
'(diff-removed ((t (:inherit diff-changed :foreground "tomato"))))
'(ediff-even-diff-C ((t nil)))
'(ediff-odd-diff-B ((t (:background "dark blue"))))
'(ediff-odd-diff-C ((t nil)))
'(erb-face ((t nil)))
'(erb-out-delim-face ((t (:foreground "#aaffff"))))
'(error ((t (:foreground "pink2" :underline nil :weight normal))))
'(helm-source-header ((t (:background "#22083397778B" :foreground "white"))))
'(magit-item-highlight ((t nil)))
'(vertical-border ((((type tty)) (:inherit gray9))))
'(web-mode-html-attr-name-face ((t (:foreground "dark gray" :underline nil :weight normal))))
'(web-mode-html-tag-bracket-face ((t (:foreground "gray58" :underline nil :weight normal))))
'(web-mode-html-tag-face ((t (:foreground "dark cyan" :underline nil :weight normal))))
'(whitespace-newline ((t (:foreground "gray31" :weight thin))))
'(whitespace-space ((t nil))))
(put 'downcase-region 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)