-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
277 lines (235 loc) · 8.53 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
;; Nick Aldwin
;; Fix clipboard problems
(setq x-select-enable-clipboard t)
;; Add load paths
(add-to-list 'load-path "~/.emacs.d/libs/")
(add-to-list 'load-path "~/.emacs.d/utils/")
(add-to-list 'load-path "~/.emacs.d/modes/")
(add-to-list 'load-path "~/.emacs.d/modes/coffee-mode")
(add-to-list 'load-path "~/.emacs.d/modes/markdown-mode")
(add-to-list 'load-path "~/.emacs.d/modes/json-mode")
(add-to-list 'load-path "~/.emacs.d/modes/web-mode")
(add-to-list 'load-path "~/.emacs.d/modes/js2-mode")
(add-to-list 'load-path "~/.emacs.d/modes/yaml-mode")
(add-to-list 'load-path "~/.emacs.d/modes/haml-mode")
(add-to-list 'load-path "~/.emacs.d/modes/scss-mode")
(add-to-list 'load-path "~/.emacs.d/modes/sass-mode")
(add-to-list 'load-path "~/.emacs.d/modes/rust-mode")
(add-to-list 'load-path "~/.emacs.d/modes/toml-mode")
(add-to-list 'load-path "~/.emacs.d/modes/git-modes")
(add-to-list 'load-path "~/.emacs.d/modes/puppet-syntax-emacs")
(add-to-list 'load-path "~/.emacs.d/modes/jade-mode")
(add-to-list 'load-path "~/.emacs.d/color-theme/")
(add-to-list 'load-path "~/.emacs.d/emacs-color-theme-solarized/")
(add-to-list 'load-path "~/.emacs.d/deft/")
;; Path for executables
(if (eq system-type 'darwin)
(add-to-list 'exec-path "/usr/local/bin/"))
;; Get machine name
(defvar this-machine "default"
"The hostname of this machine.")
(if (getenv "HOST")
(setq this-machine (getenv "HOST")))
(if (string-match "default" this-machine)
(if (getenv "HOSTNAME")
(setq this-machine (getenv "HOSTNAME"))))
(if (string-match "default" this-machine)
(setq this-machine system-name))
;; Set font if on Windows
(if (equal system-type 'windows-nt)
(custom-set-faces
'(default ((t (:inherit nil :stipple nil :background "SystemWindow" :foreground "SystemWindowText" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "outline" :family "Consolas"))))))
;; Set font on OS X
(when (and (eq system-type 'darwin)
(member "Source Code Pro" (font-family-list)))
(set-face-attribute 'default nil :family "Source Code Pro")
(set-face-attribute 'default nil :height 130))
;; Kill toolbar
(tool-bar-mode -1)
;; Interactively do
(ido-mode 'both)
;; Fuzzy Matching
(setq ido-enable-flex-matching t)
;; Bar cursor
(setq-default cursor-type 'bar)
;; Select & type deletes text
(delete-selection-mode 1)
;; Indent using spaces only
(setq-default indent-tabs-mode nil)
;; Column number
(column-number-mode t)
;; Desktop & Window
(desktop-save-mode 1)
(setq desktop-restore-eager 5)
(winner-mode 1)
;; Color theme
(require 'color-theme)
(require 'color-theme-solarized)
(setq-default solarized-termcolors 256)
(if (not window-system)
(setq-default solarized-degrade t))
(color-theme-solarized)
;; Smart Tab (from https://github.com/genehack/smart-tab )
(require 'smart-tab)
(global-smart-tab-mode 1)
(setq smart-tab-using-hippie-expand t)
;; Flyspell
(require 'flyspell)
(global-set-key [M-down-mouse-1] 'flyspell-correct-word)
(defun turn-on-flyspell-lazy ()
"Enable flyspell and lazily flyspell the whole buffer on idle"
(turn-on-flyspell)
(run-with-idle-timer 5
nil
(lambda (buffer)
(if (buffer-live-p (get-buffer buffer))
(with-current-buffer buffer
(flyspell-buffer))))
(current-buffer)))
;; Markdown Mode
(require 'markdown-mode)
(add-to-list 'auto-mode-alist
(cons "\\.m\\(ar\\)?k?d\\(\\o?w?n\\|te?xt\\)?\\'" 'gfm-mode))
(add-hook 'markdown-mode-hook 'turn-on-auto-fill)
(add-hook 'markdown-mode-hook 'turn-on-flyspell-lazy)
;; Coffee Mode
(require 'coffee-mode)
(setq coffee-tab-width 2)
;; JSON Mode
(require 'json-mode)
(setq js-indent-level 2)
(add-to-list 'auto-mode-alist
(cons ".json" 'json-mode))
;; Protobuf Mode
(require 'protobuf-mode)
(add-to-list 'auto-mode-alist
(cons ".proto" 'protobuf-mode))
;; Web Mode
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(defun web-mode-hook ()
"Hooks for Web mode."
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
)
(add-hook 'web-mode-hook 'web-mode-hook)
;; js2 mode
(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(setq js2-missing-semi-one-line-override t)
(setq js2-mode-show-strict-warnings nil)
(setq js2-strict-missing-semi-warning nil)
(setq js2-strict-trailing-comma-warning nil)
;; YAML mode
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.[a-z]?ya?ml$" . yaml-mode))
;; SCSS mode
(require 'scss-mode)
(setq scss-compile-at-save nil)
(add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
;; SASS mode
(require 'haml-mode)
(require 'sass-mode)
(add-to-list 'auto-mode-alist '("\\.sass\\'" . sass-mode))
;; rust mode
(require 'rust-mode)
(autoload 'rust-mode "rust-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
;; toml mode
(require 'toml-mode)
;; Git modes
(require 'git-commit-mode)
(require 'git-rebase-mode)
(require 'gitattributes-mode)
(require 'gitconfig-mode)
(require 'gitignore-mode)
;; Puppet mode
(require 'puppet-mode)
(autoload 'puppet-mode "puppet-mode" "Major mode for editing puppet manifests")
(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode))
;; Jade mode
(require 'sws-mode)
(require 'jade-mode)
(add-to-list 'auto-mode-alist '("\\.styl\\'" . sws-mode))
;; Ruby mode
(require 'ruby-mode)
(add-to-list 'auto-mode-alist
'("\\.\\(?:gemspec\\|irbrc\\|gemrc\\|rake\\|rb\\|ru\\|thor\\)\\'" . ruby-mode))
(add-to-list 'auto-mode-alist
'("\\(Capfile\\|Gemfile\\(?:\\.[a-zA-Z0-9._-]+\\)?\\|[rR]akefile\\)\\'" . ruby-mode))
;; Word Count mode
;; From http://www.emacswiki.org/emacs/WordCountMode
(require 'wc-mode)
;; wc-based word counting on demand (the above doesn't work for <24)
(defun wc ()
(interactive)
(if (use-region-p)
(shell-command-on-region (point) (mark) "wc")
(shell-command-on-region (point-min) (point-max) "wc")))
(global-set-key "\C-cw" 'wc)
;; Intelligent buffer renaming
(require 'uniquify)
(setq uniquify-after-kill-buffer-p t)
(setq uniquify-ignore-buffers-re "^\\*") ; ignore special buffers
(setq uniquify-buffer-name-style 'post-forward)
;; Cache passwords in Tramp
(require 'tramp)
(setq password-cache-expiry nil)
;; Deft
(require 'deft)
(setq
deft-default-extension "md"
deft-recursive t
deft-markdown-mode-title-level 1
deft-new-file-format "%FT%T%z")
(global-set-key (kbd "<f9>") 'deft)
;; Server
(require 'server)
(require 'server)
(when (and (= emacs-major-version 23)
(equal window-system 'w32))
(defun server-ensure-safe-dir (dir) "Noop" t))
(unless (server-running-p)
(server-start))
(add-hook 'server-done-hook (lambda nil (kill-buffer nil)))
;; Number lines in programming modes
(add-hook 'prog-mode-hook 'linum-mode)
;; SQL
(setq sql-product (quote mysql))
(add-hook 'sql-interactive-mode-hook
(lambda ()
(toggle-truncate-lines t)))
;; PuTTY fix. Ugly. Bad. But it works. (Good)
;; from http://www.emacswiki.org/emacs/PuTTY
(define-key global-map "\M-[1~" 'beginning-of-line) ; HOME
(define-key global-map [select] 'end-of-line) ; END
;; Scrolling
(setq scroll-step 1)
(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)
(setq scroll-preserve-screen-position t)
(global-set-key (kbd "<M-up>") 'scroll-down-line)
(global-set-key (kbd "<M-down>") 'scroll-up-line)
;; macOS bindings
(defun use-keyboard ()
(interactive)
(setq mac-option-modifier 'super)
(setq mac-command-modifier 'meta))
(defun use-laptop ()
(interactive)
(setq mac-option-modifier 'meta)
(setq mac-command-modifier 'super))
(when (eq system-type 'darwin)
(use-keyboard)
(global-set-key [kp-delete] 'delete-char))
;; Go away, startup screen
(setq inhibit-startup-echo-area-message t)
(setq inhibit-startup-message t)