-
Notifications
You must be signed in to change notification settings - Fork 37
/
init.el
164 lines (117 loc) · 5.09 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
;;; init.el --- Emfy 0.4.0 <https://github.com/susam/emfy>
;;; Commentary:
;; A very basic dark and sleek Emacs setup for general purpose
;; editing and programming.
;;; Code:
;;; Look and Feel ====================================================
;; Tweak UI.
(when (display-graphic-p)
(tool-bar-mode 0)
(scroll-bar-mode 0))
(setq inhibit-startup-screen t)
(column-number-mode)
;; Dark theme.
(load-theme 'wombat)
(with-eval-after-load 'wombat-theme
(set-face-background 'default "#111")
(set-face-background 'cursor "#c96")
(set-face-foreground 'font-lock-comment-face "#fc0")
(set-face-background 'isearch "#ff0")
(set-face-foreground 'isearch "#000")
(set-face-background 'lazy-highlight "#990")
(set-face-foreground 'lazy-highlight "#000"))
;; Enable line numbers while writing config, code, or text.
(dolist (hook '(prog-mode-hook conf-mode-hook text-mode-hook))
(add-hook hook 'display-line-numbers-mode))
;; Highlight matching pairs of parentheses.
(setq show-paren-delay 0)
(show-paren-mode)
;; Auto-complete inputs in the minibuffer.
(fido-vertical-mode)
;;; Whitespace =======================================================
;; Show trailing whitespace while writing config, code, or text.
(dolist (hook '(conf-mode-hook prog-mode-hook text-mode-hook))
(add-hook hook (lambda () (setq show-trailing-whitespace t))))
;; Show stray blank lines.
(setq-default indicate-empty-lines t)
(setq-default indicate-buffer-boundaries 'left)
;; Add a newline automatically at the end of a file while saving.
(setq require-final-newline t)
;; Consider a period followed by a single space to be end of sentence.
(setq sentence-end-double-space nil)
;; Use spaces, not tabs, for indentation.
(setq-default indent-tabs-mode nil)
;; Display the distance between two tab stops as 4 characters wide.
(setq-default tab-width 4)
;; Indentation setting for various languages.
(setq c-basic-offset 4)
(setq js-indent-level 2)
(setq css-indent-offset 2)
;;; Clean Working Directories ========================================
;; Write auto-saves and backups to separate directory.
(make-directory "~/.tmp/emacs/auto-save/" t)
(setq auto-save-file-name-transforms '((".*" "~/.tmp/emacs/auto-save/" t)))
(setq backup-directory-alist '(("." . "~/.tmp/emacs/backup/")))
;; Do not move the current file while creating backup.
(setq backup-by-copying t)
;; Disable lockfiles.
(setq create-lockfiles nil)
;; Write customizations to a separate file instead of this file.
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file t)
;;; Custom Command and Key Sequences =================================
;; Custom command.
(defun show-current-time ()
"Show current time."
(interactive)
(message (current-time-string)))
;; Custom key sequences.
(global-set-key (kbd "C-c t") 'show-current-time)
(global-set-key (kbd "C-c d") 'delete-trailing-whitespace)
;;; Emacs Server =====================================================
(require 'server)
(unless (server-running-p)
(server-start))
;;; Package Setup ====================================================
(defun install-packages ()
"Install and set up packages for the first time."
(interactive)
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-refresh-contents)
(dolist (package '(markdown-mode paredit rainbow-delimiters))
(unless (package-installed-p package)
(package-install package))))
;;; Paredit Configuration ============================================
;; Enable Paredit on various Lisp modes.
(when (fboundp 'paredit-mode)
(dolist (hook '(emacs-lisp-mode-hook
eval-expression-minibuffer-setup-hook
ielm-mode-hook
lisp-interaction-mode-hook
lisp-mode-hook))
(add-hook hook 'enable-paredit-mode)))
;; Do not bind RET to paredit-RET which prevents input from being
;; evaluated on RET in M-:, ielm, etc.
(with-eval-after-load 'paredit
(define-key paredit-mode-map (kbd "RET") nil))
;;; Rainbow Delimiters Configuration =================================
(when (fboundp 'rainbow-delimiters-mode)
(dolist (hook '(emacs-lisp-mode-hook
ielm-mode-hook
lisp-interaction-mode-hook
lisp-mode-hook))
(add-hook hook 'rainbow-delimiters-mode)))
(with-eval-after-load 'rainbow-delimiters
(set-face-foreground 'rainbow-delimiters-depth-1-face "#c66") ; red
(set-face-foreground 'rainbow-delimiters-depth-2-face "#6c6") ; green
(set-face-foreground 'rainbow-delimiters-depth-3-face "#69f") ; blue
(set-face-foreground 'rainbow-delimiters-depth-4-face "#cc6") ; yellow
(set-face-foreground 'rainbow-delimiters-depth-5-face "#6cc") ; cyan
(set-face-foreground 'rainbow-delimiters-depth-6-face "#c6c") ; magenta
(set-face-foreground 'rainbow-delimiters-depth-7-face "#ccc") ; light gray
(set-face-foreground 'rainbow-delimiters-depth-8-face "#999") ; medium gray
(set-face-foreground 'rainbow-delimiters-depth-9-face "#666")) ; dark gray
;;; The End ==========================================================
(provide 'init)
;;; init.el ends here