-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
293 lines (257 loc) · 10.8 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
;;
;; Core behaviorial changes
;;
;; Avoid constant errors on Windows about the coding system by setting the default to UTF-8.
(set-default-coding-systems 'utf-8)
;; Enable line numbers
(column-number-mode)
(global-display-line-numbers-mode t)
(global-hl-line-mode +1)
;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; Always can type Y or N
(defalias 'yes-or-no-p 'y-or-n-p)
;; Ability to delete selections
(delete-selection-mode t)
;; Ability to move between panes/windows with Shift+arrows
(windmove-default-keybindings)
;
;; TRAMP
(setq tramp-default-method "sshx")
(setq tramp-verbose 10)
;; from Andrew Tropin's RDE. This fixes the bug where you can't open files with sudo
(eval-when-compile (require 'tramp))
(with-eval-after-load 'tramp (add-to-list 'tramp-remote-path 'tramp-own-remote-path))
;; "If I edit a file outside of Emacs, the default setting is for Emacs to ask you to reload the file manually. I task Emacs to reload the file automatically."
(global-auto-revert-mode t)
;;
;; Basic visual settings
;;
(if (window-system) (set-frame-size (selected-frame) 124 40)) ; Set a default window size
(setq inhibit-startup-message t)
(setq inhibit-startup-screen t)
(scroll-bar-mode -1) ; Disable visible scrollbar
(tool-bar-mode -1) ; Disable the toolbar
(tooltip-mode -1) ; Disable tooltips
(set-fringe-mode 10) ; Give some breathing room
(menu-bar-mode -1) ; Disable the menu bar
(setq visible-bell t) ; Set up the visible bell
(size-indication-mode t) ; Show filesize
(setq frame-title-format ; Use the titlebar to show full filename
'((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
;; Initial theme
(set-face-attribute 'default nil :font "Iosevka SS05 Slab" :height 128)
;;
;; Initialize package sources
;;
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("org" . "http://orgmode.org/elpa/")))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
;; Initialize use-package on non-Linux platforms
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(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
'(magit minions abbrev modus-themes centaur-tabs general evil-tutor evil-collection evil counsel ivy-rich ivy helpful emojify which-key rainbow-delimiters doom-modeline no-littering use-package)))
(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.
)
;;
;; No Littering
;;
;; Load the feature no-littering as early as possible in your init file.
;; Make sure you load it at least before you change any path variables using some other method.
(use-package no-littering
:ensure t
:config
;; One of the most common types of files that Emacs creates automatically is auto-save files.
;; By default, these appear in the current directory of a visited file.
;; No-littering does not change this, but you can add the following code to your init.el file to store these files in the var directory:
(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t))))
;; "Emacs likes to strew its backup and temporary files everywhere. Lets give them a home in the temporary file directory."
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;;
;; Makes startup faster by reducing the frequency of garbage collection
;;
;; Using garbage magic hack.
(use-package gcmh :config (gcmh-mode 1)) ;; Setting garbage collection threshold
(setq gc-cons-threshold 402653184
gc-cons-percentage 0.6)
;; Profile emacs startup
(add-hook 'emacs-startup-hook
(lambda ()
(message "*** Emacs loaded in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
;;
;; Packages
;;
;; Evil is an extensible ‘vi’ layer for Emacs. It emulates the main features of Vim, and provides facilities for writing custom extensions.
(use-package evil
:init ;; tweak evil's configuration before loading it
(setq evil-undo-system 'undo-fu)
(setq evil-want-C-i-jump nil) ;; be able to use tab
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
(setq evil-want-keybinding nil)
(setq evil-vsplit-window-right t)
(setq evil-split-window-below t)
(evil-mode))
;; Evil Collection is also installed since it adds ‘evil’ bindings to parts of Emacs that the standard Evil package does not cover, such as: calenda, help-mode and ibuffer.
(use-package evil-collection
:after evil
:config
(setq evil-collection-mode-list '(dashboard dired ibuffer))
(evil-collection-init))
(use-package evil-tutor)
(use-package undo-fu)
(use-package smartparens :config (smartparens-global-mode t) (setq sp-highlight-pair-overlay nil))
(use-package aggressive-indent
:diminish aggressive-indent-mode
:config
(add-hook 'prog-mode-hook #'aggressive-indent-global-mode))
(setq tab-always-indent nil)
(setq-default tab-width 2
indent-tabs-mode nil)
(use-package company :ensure t :hook (after-init . global-company-mode))
;;
;; General keybindings
;;
;; General.el allows us to set keybindings.
;; SPC as the prefix key. General makes setting keybindings (especially with SPC) much easier.
;; All of the keybindings we set later in the config depend on general being loaded.
(use-package general :config (general-evil-setup t))
;; zoom in/out like we do everywhere else.
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
;; General keybindings
(nvmap :keymaps 'override :prefix "SPC"
"SPC" '(counsel-M-x :which-key "M-x")
"c c" '(compile :which-key "Compile")
"c C" '(recompile :which-key "Recompile")
"h r r" '((lambda () (interactive) (load-file "~/.emacs.d/init.el")) :which-key "Reload emacs config")
"t t" '(toggle-truncate-lines :which-key "Toggle truncate lines"))
;; (nvmap :keymaps 'override :prefix "SPC"
; "m *" '(org-ctrl-c-star :which-key "Org-ctrl-c-star")
; "m +" '(org-ctrl-c-minus :which-key "Org-ctrl-c-minus")
; "m ." '(counsel-org-goto :which-key "Counsel org goto")
; "m e" '(org-export-dispatch :which-key "Org export dispatch")
; "m f" '(org-footnote-new :which-key "Org footnote new")
; "m h" '(org-toggle-heading :which-key "Org toggle heading")
; "m i" '(org-toggle-item :which-key "Org toggle item")
; "m n" '(org-store-link :which-key "Org store link")
; "m o" '(org-set-property :which-key "Org set property")
; "m t" '(org-todo :which-key "Org todo")
; "m x" '(org-toggle-checkbox :which-key "Org toggle checkbox")
; "m B" '(org-babel-tangle :which-key "Org babel tangle")
; "m I" '(org-toggle-inline-images :which-key "Org toggle inline imager")
; "m T" '(org-todo-list :which-key "Org todo list")
; "o a" '(org-agenda :which-key "Org agenda")
; )
;; File-related keybindings
(nvmap :states '(normal visual) :keymaps 'override :prefix "SPC"
"." '(find-file :which-key "Find file")
"f f" '(find-file :which-key "Find file")
"f r" '(counsel-recentf :which-key "Recent files")
"f s" '(save-buffer :which-key "Save file")
"f u" '(sudo-edit-find-file :which-key "Sudo find file")
"f y" '(dt/show-and-copy-buffer-path :which-key "Yank file path")
"f C" '(copy-file :which-key "Copy file")
"f D" '(delete-file :which-key "Delete file")
"f R" '(rename-file :which-key "Rename file")
"f S" '(write-file :which-key "Save file as...")
"f U" '(sudo-edit :which-key "Sudo edit file"))
;; Eval keybindings
(nvmap :states '(normal visual) :keymaps 'override :prefix "SPC"
"e b" '(eval-buffer :which-key "Eval elisp in buffer")
"e d" '(eval-defun :which-key "Eval defun")
"e e" '(eval-expression :which-key "Eval elisp expression")
"e l" '(eval-last-sexp :which-key "Eval last sexression")
"e r" '(eval-region :which-key "Eval region"))
;;
;; Interactions
;;
(use-package counsel :after ivy :config (counsel-mode))
(use-package ivy
:defer 0.1
:diminish
:bind
(("C-c C-r" . ivy-resume)
("C-x B" . ivy-switch-buffer-other-window))
:custom
(setq ivy-count-format "(%d/%d) ")
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
:config
(ivy-mode))
(use-package ivy-rich
:after ivy
:custom
(ivy-virtual-abbreviate 'full
ivy-rich-switch-buffer-align-virtual-buffer t
ivy-rich-path-style 'abbrev)
:config
(ivy-set-display-transformer 'ivy-switch-buffer
'ivy-rich-switch-buffer-transformer)
(ivy-rich-mode 1)) ;; this gets us descriptions in M-x.
(use-package swiper :after ivy :bind (("C-s" . swiper)("C-r" . swiper)))
;; (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 which-key
:init (which-key-mode)
:diminish which-key-mode
:config
(setq which-key-idle-delay 1))
;;
;; Pretty graphics
;;
(use-package modus-themes
:ensure
:init
;; Load the theme files before enabling a theme
(modus-themes-load-themes)
:config
;; Load the theme of your choice:
(modus-themes-load-operandi))
(use-package smart-mode-line
:ensure t
:config
(add-hook 'after-init-hook 'sml/setup))
(use-package highlight-parentheses :ensure t)
(add-hook 'prog-mode-hook #'highlight-parentheses-mode)
(add-hook 'minibuffer-setup-hook #'highlight-parentheses-minibuffer-setup)
(use-package magit
:bind ("C-M-;" . magit-status)
:commands (magit-status magit-get-current-branch)
;; :custom
;; (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
)