-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
455 lines (364 loc) · 11.7 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
;;; package -- Summary:
;;; Commentary:
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;;; Code:
(require 'package)
(setq
package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/"))
package-archive-priorities '(("melpa-stable" . 1)))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents)
(package-install 'use-package))
;; scroll one line at a time (less "jumpy" than defaults)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
;; With this Emacs starts automatically on fullscreen mode
(add-hook 'window-setup-hook 'toggle-frame-fullscreen t)
;; This clears the message that shows at the scratch buffer by default
(setq initial-scratch-message "")
;; This way I can just type 'y' instead of 'yes<RET>' to confirm
(fset 'yes-or-no-p 'y-or-n-p)
;; Checks if Tamzen is on the system and uses it as a global font
;; (when (member "Tamzen" (font-family-list))
;; (add-to-list 'default-frame-alist '(font . "Tamzen-15"))
;; (set-face-attribute 'default t :font "Tamzen-15"))
;; Something to do with backups files lmao
(setq make-backup-files nil)
(setq backup-directory-alist '(("" . "~/.emacs.d/backup")))
;; Settings just for macOS
(setq mac-option-key-is-meta t) ;; This way I can use Alt (option) key as Meta on Mac
(setq mac-right-option-modifier nil) ;; With this I can use the right Alt key as normally (rather than as Meta)
;; This hides the much-dreaded bars on the top of Emacs GUI
(tooltip-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
;; This prevents the cursor from blinking
(blink-cursor-mode 0)
;; Shows line numbers in programming languages
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
;; This sets the Mode Line to display not just the line number
;; but also the column number (it's not that useful but ¯\_(ツ)_/¯)
(column-number-mode t)
;; Mandatory packages
(require 'use-package)
(require 'all-the-icons)
;;(require 'smartparens-config) ;; Do I need this?
;; display “lambda” as “λ”
(global-prettify-symbols-mode 1)
;; and add it to Haskell mode
(defun pretty-lambdas-haskell ()
(font-lock-add-keywords
nil `((,(concat "\\(" (regexp-quote "\\") "\\)")
(0 (progn (compose-region (match-beginning 1) (match-end 1)
,(make-char 'greek-iso8859-7 107))
nil))))))
(add-hook 'haskell-mode-hook 'pretty-lambdas-haskell)
;; Using the Hasklig font
(set-face-attribute 'default nil
:family "Hasklig"
:height 130
:weight 'normal
:width 'normal)
(use-package hasklig-mode
:ensure t
:hook (haskell-mode))
;;(define-key key-translation-map (kbd ",") ", ")
;;(global-unset-key (kbd ","))
;; Global keybindings
(global-set-key (kbd "C-;") 'comment-or-uncomment-region)
;; Ciao Prolog
;; (if (file-exists-p "~/.ciaoroot/master/ciao_emacs/elisp/ciao-site-file.el")
;; (load-file "~/.ciaoroot/master/ciao_emacs/elisp/ciao-site-file.el"))
;; (require 'ciao)
;; (add-to-list 'auto-mode-alist '("\\.pl\\'" . ciao-mode))
;;;;;; use-package declarations ;;;;;;
;; (use-package exec-path-from-shell
;; :ensure t
;; :config
;; (when (memq window-system '(mac ns x))
;; (exec-path-from-shell-initialize))
;; )
(use-package random-splash-image
:ensure t
:config
(setq random-splash-image-dir (concat (getenv "HOME") "/.emacs.d/splash-images"))
(random-splash-image-set)
)
;; (use-package darkokai-theme
;; :ensure t
;; :config (load-theme 'darkokai t)
;; )
;; (use-package kaolin-themes
;; :ensure t
;; :config (load-theme 'kaolin-galaxy t)
;; )
;; (use-package doom-themes
;; :ensure t
;; :config (load-theme 'doom-fairy-floss t)
;; (doom-themes-neotree-config)
;; (doom-themes-org-config)
;; )
(use-package gruvbox-theme
:ensure t
:config (load-theme 'gruvbox-dark-soft t)
)
;;(use-package rebecca-theme
;; :ensure t
;; :config (load-theme 'rebecca t)
;; )
(use-package all-the-icons
:ensure t
)
(use-package restart-emacs
:ensure t
)
;; (use-package visual-regexp-steroids
;; :ensure t
;; :config
;; (define-key global-map (kbd "C-c r") 'vr/replace)
;; (define-key global-map (kbd "C-c q") 'vr/query-replace)
;; ;; if you use multiple-cursors, this is for you:
;; (define-key global-map (kbd "C-c m") 'vr/mc-mark)
;; ;; to use visual-regexp-steroids's isearch instead of the built-in regexp isearch, also include the following lines:
;; ;; (define-key esc-map (kbd "C-r") 'vr/isearch-backward) ;; C-M-r
;; ;; (define-key esc-map (kbd "C-s") 'vr/isearch-forward) ;; C-M-s
;; (define-key global-map (kbd "C-r") 'vr/isearch-backward)
;; (define-key global-map (kbd "C-s") 'vr/isearch-forward)
;; )
(use-package rainbow-delimiters
:ensure t
:init
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
)
(use-package rainbow-mode
:ensure t
:mode "\\.css\\'"
)
(use-package pretty-mode
:ensure t
:init
;;(add-hook 'haskell-mode-hook #'pretty-mode)
)
(use-package wrap-region
:ensure t
:config
(wrap-region-add-wrappers
'(("$" "$" nil (org-mode latex-mode))))
(add-hook 'org-mode-hook 'wrap-region-mode)
(add-hook 'latex-mode-hook 'wrap-region-mode)
)
(use-package visual-regexp-steroids
:ensure t
:init
(setq neo-theme 'icons)
:bind ("M-n t" . neotree-toggle)
)
(use-package lua-mode
:ensure t
:mode "\\.p8\\'"
:config
(define-key global-map (kbd "C-c r") 'vr/replace)
(define-key global-map (kbd "C-c q") 'vr/query-replace)
;; if you use multiple-cursors, this is for you:
(define-key global-map (kbd "C-c m") 'vr/mc-mark)
;; to use visual-regexp-steroids's isearch instead of the built-in regexp isearch, also include the following lines:
;; (define-key esc-map (kbd "C-r") 'vr/isearch-backward) ;; C-M-r
;; (define-key esc-map (kbd "C-s") 'vr/isearch-forward) ;; C-M-s
(define-key global-map (kbd "C-r") 'vr/isearch-backward)
(define-key global-map (kbd "C-s") 'vr/isearch-forward)
)
;; (use-package neotree
;; :ensure t
;; :init
;; (setq neo-theme 'icons)
;; (neotree)
;; :bind ("M-n t" . neotree-toggle)
;; )
(use-package ido
:ensure
:init
(progn
(ido-mode 1)
(use-package ido-vertical-mode
:ensure t
:init (ido-vertical-mode 1)
)
(use-package flx-ido
:ensure t
:init (flx-ido-mode 1)
)
(use-package ido-completing-read+
:ensure t
)
(use-package smex
:ensure t
:init (smex-initialize)
:bind ("M-x" . smex)
)
)
)
(use-package smartparens
:ensure t
:init
(smartparens-global-mode t)
(add-hook 'prog-mode-hook #'smartparens-mode)
)
(use-package yasnippet
:ensure t
:init (yas-global-mode 1)
:config
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "<C-tab>") 'yas-expand)
)
(use-package auto-complete
:ensure t
:config (ac-config-default)
)
(use-package company
:init
(add-hook 'after-init-hook 'global-company-mode)
)
(use-package tex
:ensure auctex
:config
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq TeX-save-query nil)
(setq TeX-PDF-mode t)
(setq bibtex-dialect 'biblatex)
(setq LaTeX-always-use-Biber t)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'TeX-mode-hook
(lambda ()
(setq TeX-command-extra-options "-shell-escape")
)
)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
)
(use-package haskell-mode
:ensure t
:mode "\\.hs\\'"
:config
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
;; if not present, remove structured-haskell-mode hook
;; (add-hook 'haskell-mode-hook 'structured-haskell-mode)
)
(use-package elpy
:ensure t
:mode "\\.py\\'"
:config
(elpy-enable)
)
(use-package magit
:ensure t
:bind (("C-x g" . magit-status)
("C-x M-g" . magit-dispatch-popup))
:config
; This hook updates the magit status buffer every file save,
; disable in case of poor performance
(add-hook 'after-save-hook 'magit-after-save-refresh-status t)
)
(use-package multi-term
:ensure t
:config (setq multi-term-program "/bin/zsh")
:bind ("M-s t" . multi-term)
)
(use-package windmove
:ensure t
:bind (("C-c <up>" . windmove-up)
("C-c <left>" . windmove-left)
("C-c <right>" . windmove-right)
("C-c <down>" . windmove-down))
)
(use-package multiple-cursors
:ensure t
:bind ("C-S-c C-S-c" . mc/edit-lines)
)
(use-package avy
:ensure t
:bind (("C-:" . avy-goto-char)
("C-'" . avy-goto-char-2)
("M-s a" . avy-goto-char-timer)
("M-g M-g" . avy-goto-line))
)
(use-package expand-region
:ensure t
:bind ("C-=" . er/expand-region)
)
(use-package spaceline
:ensure t)
(use-package spaceline-config
:init
(spaceline-all-the-icons-theme)
(setq powerline-default-separator 'wave)
)
(use-package spaceline-all-the-icons
:ensure t
:after spaceline
:config (spaceline-all-the-icons-theme)
)
(use-package org
:mode (("\\.org$" . org-mode))
:config
(setq org-src-fontify-natively t
org-fontify-whole-heading-line t
org-fontify-done-headline t
org-fontify-quote-and-verse-blocks t)
(add-to-list 'org-structure-template-alist
(list "p" (concat ":PROPERTIES:\n"
"?\n"
":END:")))
)
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
)
;;;;;; Custom functions ;;;;;;
(defun cheatsheet()
"Opens a custom cheatsheet located in .emacs.d/cheatsheet"
(interactive)
(find-file-read-only "~/.emacs.d/cheatsheet.org")
)
(global-set-key (kbd "C-c C-s") 'cheatsheet)
;; These two functions were made by @Ironjanowar
(defun kill-buffers()
(let (buffer buffers)
(setq buffers (buffer-list))
(dotimes (i (length buffers))
(setq buffer (pop buffers))
(if (not (string-equal (buffer-name buffer) "*scratch*")) (kill-buffer buffer) nil))))
(defun clean-buffers()
(interactive)
(if (yes-or-no-p "Do you really want to clean all buffers? ")
(kill-buffers) nil))
(global-set-key (kbd "C-x C-S-k") 'clean-buffers)
(put 'set-goal-column 'disabled nil)
(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.
'(package-selected-packages
'(org-bullets spaceline-all-the-icons spaceline expand-region avy multiple-cursors multi-term magit elpy haskell-mode auctex auto-complete yasnippet smartparens smex ido-completing-read+ flx-ido ido-vertical-mode lua-mode visual-regexp-steroids wrap-region pretty-mode rainbow-mode rainbow-delimiters symon restart-emacs kaolin-themes random-splash-image hasklig-mode use-package all-the-icons)))
(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.
)