-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
254 lines (215 loc) · 6.84 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
;; do not make audible ding, emacs will now flash the screen instead
(setq visible-bell 1)
;; do not flash the screen
(setq ring-bell-function 'ignore)
;; maxmise emacs frame on startup
(custom-set-variables
'(initial-frame-alist '((fullscreen . maximized))))
;; do not show the startup screen
(setq inhibit-startup-message t)
(setq frame-title-format "emacs")
;; (defalias 'yes-or-no-p 'y-or-no-p)
;; disable tool bar, menu bar, scroll bar
(tool-bar-mode 0)
(menu-bar-mode 0)
(scroll-bar-mode 0)
;; cursor: vertical bar
(setq-default cursor-type 'bar)
;; highlight current line
(global-hl-line-mode t)
;; display line numbers
(global-display-line-numbers-mode)
;; use relative line numbering
(setq display-line-numbers-type 'relative)
;; use column numbers instead of alphabets in mode line
(setq column-number-mode t)
;; set font face and size
(set-face-attribute 'default nil :font "Hasklug Nerd Font" :height 210)
;; delete trailing whitespaces before saving a file
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; load `package`
(require 'package)
;; tells emacs not to load any packages before starting up
(setq package-enable-at-startup nil)
;; add `melpa`, `org`, `elpa` to `package-archives`
(setq package-archives '(("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")))
;; initialize `package`
(package-initialize)
;; install `use-package` if not installed
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;; load `use-package`
(require 'use-package)
;; "ensure" packages by default
(setq use-package-always-ensure t)
(use-package all-the-icons)
;; run (all-the-icons-install-fonts) to install the fonts
(use-package neotree
:config
(global-set-key (kbd "<f8>") 'neotree-toggle))
;; use theme
;; (load-theme 'tango-dark)
(use-package doom-themes
:config
(load-theme 'doom-one t)
(doom-themes-neotree-config))
(use-package doom-modeline
:disabled
:hook
(after-init . doom-modeline-mode)
:custom
(doom-modeline-height 10))
(use-package command-log-mode
:config
(global-command-log-mode))
;; (clm/toggle-command-log-buffer))
;; company uses backends to provide completions and a frontend to visualise the list of completions suggestions
(use-package company
:init
(setq company-selection-wrap-around t
company-tooltip-align-annotations t)
:config
;; Zero delay when pressing tab
(setq company-idle-delay 0)
(add-hook 'after-init-hook 'global-company-mode))
(use-package which-key
:init
(which-key-mode)
:config
(setq which-key-idle-delay 0))
(use-package ivy
:config
;; add recent files and bookmarks to the ivy-switch-buffer
(setq ivy-use-virtual-buffers t
;; wrap around completions provided by ivy as part of swiper/counsel
ivy-wrap t
;; use M-<number> to select completion at <number>
company-show-numbers t)
;; displays the current and total number in the collection in the prompt
(setq ivy-count-format "%d/%d ")
(ivy-mode 1))
(use-package counsel
:bind (("M-x" . counsel-M-x)
("C-x b" . counsel-switch-buffer)
("C-x C-f" . counsel-find-file))
:config
;; Don't start searches with ^
(setq ivy-initial-inputs-alist nil))
(use-package swiper
:bind (("C-s" . swiper)))
(use-package ivy-rich
:config
(ivy-rich-mode 1))
(use-package prescient)
(use-package ivy-prescient
:config
(ivy-prescient-mode 1))
(use-package helpful
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
:bind
([remap describe-function] . counsel-describe-function)
([remap describe-command] . helpful-command)
([remap describe-variable] . counsel-describe-variable)
([remap describe-key] . helpful-key))
(use-package evil
:config
(evil-mode 1))
(use-package evil-collection
:disabled
:after evil
:config
(evil-collection-init))
(use-package undo-tree
:defer 5
:config
(global-undo-tree-mode 1))
(use-package projectile
:config
(projectile-mode)
:bind-keymap
("C-c p" . projectile-command-map)
:init
(when (file-directory-p "~/cventcode")
(setq projectile-project-search-path '("~/cventcode")))
(setq projectile-switch-project-action #'projectile-dired))
(use-package counsel-projectile
:after projectile
:config (counsel-projectile-mode))
(use-package magit)
(use-package evil-magit
:disabled
:after magit)
(use-package forge
:disabled)
(use-package magit-todos
:disabled)
(defun org-mode-setup ()
(org-indent-mode)
;; use visual-line-mode for soft-wrap instead of using auto-fill-mode for hard-wrap
(auto-fill-mode 0)
(visual-line-mode 1))
(use-package org
:hook (org-mode . org-mode-setup)
:config
(setq org-capture-templates
`(("f" "Fleeting Note" item (file+olp+datetree "~/Dropbox/org/fleeting.org")
"%?" :prepend :kill-buffer)))
(setq org-modules
`(org-tempo))
(add-to-list 'org-structure-template-alist '("sh" . "src sh"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")))
;; highlight matching parenthesis, bracket and brace
(show-paren-mode 1)
(setq show-paren-delay 0)
(use-package paredit
:config
;; use paredit with emacs' lisp modes
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
(add-hook 'ielm-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
(add-hook 'scheme-mode-hook #'enable-paredit-mode))
;; Ensure paredit is used EVERYWHERE!
(use-package paredit-everywhere
:config
(add-hook 'list-mode-hook #'paredit-everywhere-mode))
(use-package highlight-parentheses
:config
(global-highlight-parentheses-mode))
(use-package rainbow-delimiters
:config
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(add-hook 'lisp-mode-hook 'rainbow-delimiters-mode))
(use-package flycheck
:init (global-flycheck-mode))
(use-package yasnippet
:config
(add-to-list 'yas-snippet-dirs "~/.emacs.d/snippets")
(yas-global-mode 1))
(use-package ledger-mode
:mode ("\\.ledger\\'"))
(use-package string-inflection
:bind ("C-c C-u" . string-inflection-all-cycle))
(defun find-config ()
"Edit config.org"
(interactive)
(find-file "~/.emacs.d/init.el"))
(global-set-key (kbd "C-c i") 'find-config)
;; use env variables same as user's shell
(use-package exec-path-from-shell
:ensure t
:if (memq window-system '(mac ns x))
:config
(exec-path-from-shell-initialize))
;; use prettier to format current buffer
(use-package prettier-js
:hook (js-mode . prettier-js-mode))