-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
254 lines (205 loc) · 6.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
251
252
253
;;;; Meta-note: usage
; This used to be called `dotemacs.el`, and I pointed to it from a top-level `.emacs`.
; However, recent versions of Emacs look for `init.el` within `~/.emacs.d` by default,
; so simply placing this there has the desired effect !!
;;;; Meta-note: useful packages to install
; doom-themes
; company
; helm
; helm-swoop
; clang-format
; yasnippet
; yasnippet-snippets
; helm-ag
; powerline
; magit
; smartparens
; pp-c-l
; srefactor
; multiple-cursors
; undo-tree
; easy-kill
; use-package
; spaceline
; elixir-mode
; org-journal
; deft
; zetteldeft
;; Note: some themes require Emacs 25 to be present (disable them for Emacs 24)
;; Only for lisp
; sly
; sly-company
; sly-quicklisp
; sly-named-readtables
; sly-macrostep
;; Common lisp stuff
(require 'cl)
;; Replace meta sequence
;; Update: replaced with Helm!
;; (global-set-key "\C-x\C-m" 'execute-extended-command)
;; Backspace improvement
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key "\C-c\C-k" 'kill-region)
;; Fonts and colors
(global-font-lock-mode t)
;; "Lose the UI"
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
;; Installing packages is better than downloading and copy-pasting .el files
(require 'package)
(package-initialize)
(require 'use-package)
;; Add melpa and marmalade to the mix
(setq package-archives '(("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
;; Doom theme coolness
(require 'doom-themes)
(load-theme 'doom-dracula t)
;; Lisp
;; (require 'slime)
;; We don't use SLIME, coz we SLY!
(setq inferior-lisp-program "/usr/bin/sbcl")
;; When would I _not_ want column numbers ??
(column-number-mode t)
;; Ditto for matching up parentheses
(show-paren-mode t)
;; Please don't show me the ugly "^L" characters
(require 'pp-c-l)
(pretty-control-l-mode t)
;; Don't create backup files -- I have _version control_ for that
(setq make-backup-files nil)
;; Make picking buffers and files a better experience
(require 'helm-config)
(helm-mode 1)
;; Use my M-x key sequence (and others) to trigger Helm instead of the bultin
(global-set-key (kbd "C-x C-m") 'helm-M-x)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
;; Use helm-swoop by default ...
(global-set-key (kbd "C-s") 'helm-swoop)
;; Saner undo/redo model
(require 'undo-tree)
(global-undo-tree-mode 1)
;; Allow 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)
;; When I select a region and start typing, I obviously want
;; to replace the text I've just selected (and I want to
;; delete it, not add it to the kill ring (if I wanted to
;; kill it, I would do this explicitly)
(delete-selection-mode t)
;; The default fill-column of 70 is pointless; whenever I care
;; about the "wrap width" of lines in my code, I usually want 80.
(set-fill-column 80)
;; Ctrl-z makes the frame freeze ... why would I _ever_ want this?
(put 'suspend-frame 'disabled t)
;; Quickly fix long lines
(add-hook 'c-mode-common-hook
(lambda ()
(local-set-key "\C-cf" 'fill-paragraph)))
;; clang-format before I save any C++ code
(add-hook 'c++-mode-hook
(lambda () (add-hook 'before-save-hook 'clang-format-buffer nil 'local)))
;; goimports is our friend
;; Remember to run `go get golang.org/x/tools/cmd/goimports` first.
(setq gofmt-command "goimports")
;;;;;;;;;;;;;;;;;;;;
;; Refactoring support
;(require 'srefactor)
;(semantic-mode 1)
;;;;;;;;;;;;;;;;;;;;
;; Get `M-x gofmt` to do something better
(setq gofmt-command "/Users/abrahma/go/bin/goimports")
;;;;;;;;;;;;;;;;;;;;
;; Snippets, because I am _sick_ of repeatedly typing in some stuff.
(require 'yasnippet)
(yas-global-mode 1)
;; MEMO: Install the `yasnippets-snippets` package to get some good defaults.
;; Fix exec-path
(setq exec-path (append exec-path '("/usr/local/bin")))
;;;;;;;;;;;;;;;;;;;;
;; The "just works" solution for Emacs and Haskell
(add-hook 'haskell-mode-hook 'intero-mode)
;;;;;;;;;;;;;;;;;;;;
;; Better text selection and cut/copy/paste
(require 'easy-kill)
(global-set-key [remap kill-ring-save] #'easy-kill)
(global-set-key [remap mark-sexp] #'easy-mark)
;;;;;;;;;;;;;;;;;;;;
;; Elixir stuff
(require 'elixir-mode)
;;;;;;;;;;;;;;;;;;;;
;; Org Stuff
;;
;; Journal directory
(require 'org-journal)
(setq org-journal-dir "/Users/abrahma/Documents/Org/ActivityLog")
(setq org-journal-file-format "%Y%m%d.org")
;; Log timestamps for TODO items in Org-mode
(setq org-log-done 'time)
(use-package deft
:ensure t
:custom
(deft-extensions '("org"))
(deft-directory "~/Documents/Org/Deft/")
(deft-use-filename-as-title t))
;;;;;;;;;;;;;;;;;;;;
;; Defined functions
;;;;;;;;;;;;;;;;;;;;
;; "smart tab", or the poor man's autocomplete
;; Coped from http://www.emacswiki.org/emacs/TabCompletion
(defun smart-tab ()
"If at the end of minibuffer, or at end of line,
act like usual 'tab'.
If a region is selected, indent it.
Otherwise, expand current symbol"
(interactive)
(if (minibufferp)
(unless (minibuffer-complete)
(dabbrev-expand nil))
(if mark-active
(indent-region (region-beginning)
(region-end))
(if (looking-at "\\_>")
(dabbrev-expand nil)
(indent-for-tab-command)))))
;; For now, use this only for c++
(add-hook 'c-mode-common-hook
(lambda ()
(local-set-key (kbd "TAB") 'smart-tab)))
(defun end-of-line-and-newline ()
"Create a new line below and jump to it"
(interactive)
(end-of-line)
(newline-and-indent))
(global-set-key "\C-o" 'end-of-line-and-newline)
(defun back-to-previous-line ()
"Delete back to beginning of current line, and then one
character more, leaving POINT at the end of the previous line."
(interactive)
(let ((cur-point (point)))
(forward-line 0)
(forward-char -1)
(delete-region (point) cur-point)))
(global-set-key "\C-cu" 'back-to-previous-line)
(defun kill-other-buffers ()
"Kill buffers other than the current one."
(interactive)
(mapc 'kill-buffer (delq (current-buffer) (buffer-list))))
;; Window navigation (moved to the end to overwrite conflicting assignments)
(global-set-key "\C-x\C-h" 'windmove-left)
(global-set-key "\C-x\C-j" 'windmove-down)
(global-set-key "\C-x\C-k" 'windmove-up)
(global-set-key "\C-x\C-l" 'windmove-right)
;; Get that ol' Spacemacs feeling
(use-package spaceline
:demand t
:init
(setq powerline-default-separator 'arrow-fade)
:config
(require 'spaceline-config)
(spaceline-spacemacs-theme))