-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
250 lines (207 loc) · 7.68 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
;;; package configuration
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t)
(package-initialize)
;;; global configuration
(setq inhibit-startup-screen t) ; no welcome screen
(menu-bar-mode t) ; enable menus
(global-linum-mode t) ; line numbers
(column-number-mode t) ; modeline column numbers
(winner-mode t) ; window layout history
(delete-selection-mode t) ; overwrite/delete selection
(global-auto-revert-mode t) ; reload external file changes
(electric-indent-mode t) ; auto indent where appropriate
(load-theme 'twilight t) ; tango-dark is nice too
;; nicer scrolling defaults
(setq scroll-margin 2)
(setq scroll-error-top-bottom t)
(setq scroll-preserve-screen-position t)
;; disable file interlocking
(setq create-lockfiles nil)
;; short prompts
(defalias 'yes-or-no-p 'y-or-n-p)
;; clean whitespace on save
(add-hook 'before-save-hook
'delete-trailing-whitespace)
;; set default font
;; Cousine: apt install fonts-croscore
;; Hack: apt install fonts-hack-otf
;; Source Code Pro: https://github.com/adobe/source-code-pro
(when window-system
(cond ((x-list-fonts "Cousine")
(set-frame-font "Cousine-13" t t))
((x-list-fonts "Hack")
(set-frame-font "Hack-13" t t))
((x-list-fonts "SourceCodePro")
(set-frame-font "SourceCodePro-11" t t))))
;; put buffer name or file path in frame title
(setq frame-title-format
'((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
;; window navigation
;; (global-set-key (kbd "M-o") 'next-multiframe-window)
(global-set-key (kbd "M-o") 'switch-window) ; testing switch-window
;; (global-set-key (kbd "M-O") 'previous-multiframe-window)
;; C-h and M-h as delete and delete word
(global-set-key (kbd "C-h") 'backward-delete-char-untabify)
(global-set-key (kbd "M-h") 'backward-kill-word)
;; C-x k kills current buffer
(global-set-key (kbd "C-x k") 'kill-this-buffer)
;; camelcase editing in programming modes
(add-hook 'prog-mode-hook 'syntax-subword-mode)
;; spell check comments in programming modes
(add-hook 'prog-mode-hook 'flyspell-prog-mode)
;; grep-find ignores
(grep-compute-defaults)
(add-to-list 'grep-find-ignored-directories "log")
(add-to-list 'grep-find-ignored-directories "tmp")
;; C-c g runs vc-git-grep
(global-set-key (kbd "C-c g") 'vc-git-grep)
;; toggle dedicated window
(defun toggle-window-dedicated ()
"Control whether or not Emacs is allowed to display another
buffer in current window."
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window (not (window-dedicated-p window))))
"%s: Can't touch this!"
"%s is up for grabs.")
(current-buffer)))
(global-set-key (kbd "C-c t") 'toggle-window-dedicated)
;; display-buffer-alist for grep buffers
(add-to-list 'display-buffer-alist
`(,(rx bos "*grep*" eos)
(display-buffer-reuse-window
display-buffer-in-side-window)
(reusable-frames . visible)
(side . bottom)
(window-height . 0.4)))
;; display-buffer-alist for alchemist test buffers
(add-to-list 'display-buffer-alist
`(,(rx bos "*alchemist test report*" eos)
(display-buffer-reuse-window
display-buffer-in-side-window)
(reusable-frames . visible)
(side . bottom)
(window-height . 0.4)))
;; display-buffer-alist for rspec buffers
(add-to-list 'display-buffer-alist
`(,(rx bos "*rspec-compilation*" eos)
(display-buffer-reuse-window
display-buffer-in-side-window)
(reusable-frames . visible)
(side . bottom)
(window-height . 0.4)))
(defun ak-quit-bottom-side-windows ()
"Quit side windows of the current frame."
(interactive)
(dolist (window (window-at-side-list))
(quit-window nil window)))
(global-set-key (kbd "C-c q") #'ak-quit-bottom-side-windows)
;; find recent files
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-saved-items 400)
(setq recentf-max-menu-items 80)
(defun ido-recentf-find-file ()
"Find a recent file using ido."
(interactive)
(let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
(when file
(find-file file))))
(global-set-key (kbd "C-x f") 'ido-recentf-find-file)
;;; package specific configuration
;; powerline
;; separators: alternate arrow arrow-fade bar box brace butt chamfer
;; contour curve rounded roundstub slant wave zigzag
;; themes: default center center-evil vim nano
(require 'powerline)
(setq powerline-default-separator 'arrow)
(powerline-default-theme)
;; adjust active/inactive colors
(set-face-attribute 'mode-line nil :box nil :foreground "white")
(set-face-attribute 'mode-line-inactive nil :box nil :weight 'unspecified :background "gray75" :foreground "gray50")
;; flx-ido
(require 'flx-ido)
(flx-ido-mode 1)
(setq ido-use-faces nil)
(setq ido-use-virtual-buffers t)
;; ido-vertical-mode
(require 'ido-vertical-mode)
(ido-vertical-mode)
(setq ido-vertical-define-keys 'C-n-and-C-p-only)
;; magit
(global-set-key "\C-xg" 'magit-status)
(setq magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
;; browse-kill-ring
(browse-kill-ring-default-keybindings) ; M-y opens browser
;; smartparens
(require 'smartparens-config)
(smartparens-global-mode t)
(show-smartparens-global-mode t)
(setq sp-highlight-pair-overlay nil)
(require 'smartparens-ruby)
;; multiple-cursors
(require 'multiple-cursors)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-set-key (kbd "C-c C-SPC") 'mc/mark-all-dwim)
;; linum-off
(require 'linum-off) ; disables linum-mode where appropriate
;; company mode
(add-hook 'after-init-hook 'global-company-mode)
(setq company-minimum-prefix-length 4)
;; flycheck mode
(add-hook 'after-init-hook #'global-flycheck-mode)
;; js-mode
(setq js-indent-level 2)
;; web-mode
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.hbs\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.eex\\'" . web-mode))
(setq web-mode-markup-indent-offset 2)
;; scss-mode
(setq css-indent-offset 2)
;; coffee-mode
(require 'coffee-mode)
(setq coffee-tab-width 2)
;; ruby-mode
(setq ruby-deep-indent-paren nil)
;; ruby-tools
(require 'ruby-tools) ; needed to hook ruby-mode
;; rinari
(require 'rinari)
(global-rinari-mode)
;; haml-mode
(require 'haml-mode)
(add-to-list 'auto-mode-alist '("\\.slim\\'" . haml-mode))
;; markdown-mode
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '(".md$" . gfm-mode))
;; elixir
(require 'elixir-mode)
(sp-with-modes '(elixir-mode)
(sp-local-pair "fn" "end"
:when '(("SPC" "RET"))
:actions '(insert navigate))
(sp-local-pair "do" "end"
:when '(("SPC" "RET"))
:post-handlers '(sp-ruby-def-post-handler)
:actions '(insert navigate)))
;; alchemist
(require 'alchemist)
;; org-mode
(setq org-directory "~/org")
(if (file-exists-p org-directory)
(setq org-agenda-files (directory-files org-directory 1 "\.org$")))
(setq org-agenda-clockreport-parameter-plist (quote (:fileskip0 t)))
(setq org-agenda-start-with-clockreport-mode t)
(setq org-agenda-start-with-log-mode t)
(global-set-key "\C-ca" 'org-agenda)
(setq org-time-clocksum-format
'(:hours "%d" :require-hours t :minutes ":%02d" :require-minutes t))