-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
379 lines (307 loc) · 9.92 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
;;; package --- Summary
;;; Commentary:
;;; Code:
;; Disable startup screen
(setq inhibit-startup-message t)
;; default settings
(setq initial-scratch-message nil)
(setq mark-even-if-inactive nil)
(setq kill-whole-line t)
(setq use-short-answers t)
(setq completions-detailed t)
(setq next-error-message-highlight t)
(delete-selection-mode t)
(savehist-mode)
(setq load-prefer-newer t)
(defun server-shutdown()
(interactive)
(save-some-buffers)
(kill-emacs))
(global-set-key (kbd "C-x #") 'server-shutdown)
;; (add-hook 'emacs-startup-hook (lambda ()
;; (when (get-buffer "*scratch*")
;; (delete-other-windows))))
;; font
(add-to-list 'default-frame-alist
'(font . "FiraCode Nerd Font Mono-10"))
;; get startup times
(defun efs/display-startup-time ()
"Get startup time."
(message "Emacs loaded in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done))
(add-hook 'emacs-startup-hook #'efs/display-startup-time)
;; set size of startup screen
(setq initial-frame-alist
(append initial-frame-alist
'((left . 0)
(width . 0)
(fullscreen . fullboth))))
(setq frame-resize-pixelwise t)
;; (toggle-frame-fullscreen)
;; disable toolbar, menubar and scroll bar
(tool-bar-mode -1)
(scroll-bar-mode -1)
(menu-bar-mode -1)
(tooltip-mode -1)
;; scrolling
(use-package ultra-scroll
;:load-path "~/code/emacs/ultra-scroll" ; if you git clone'd instead of package-vc-install
:init
(setq scroll-conservatively 101 ; important!
scroll-margin 0)
:config
(ultra-scroll-mode 1))
;; pixel scroll
;; (pixel-scroll-mode t)
;; (pixel-scroll-precision-mode t)
;; highlight links
(global-goto-address-mode)
;; pretty symbols
(global-prettify-symbols-mode t)
;; copy filename to clipboard
(defun copy-file-name-to-clipboard (do-not-strip-prefix)
"Copy the current buffer file name to the clipboard using DO-NOT-STRIP-PREFIX."
(interactive "P")
(let
((filename (file-relative-name do-not-strip-prefix)))
(kill-new filename)
(message "Copied buffer file name '%s' to the clipboard." filename)))
(bind-key "C-c p" #'copy-file-name-to-clipboard)
;; set line numbers
(global-display-line-numbers-mode t)
(column-number-mode)
(setq-default display-line-numbers-type 'relative)
;; highlight current line
(global-hl-line-mode t)
;; remove backup and autosave files
(setq
make-backup-files nil
auto-save-default nil
create-lockfiles nil)
;; add melpa
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Uncomment and comment the previous one to have melpa stable
;; most users won't need this
;; (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
;; checking for use-package and installing if not done yet
(when (not (package-installed-p 'use-package))
(package-refresh-contents)
(package-install 'use-package))
;; gcmh
(use-package gcmh
:ensure t
:config
(gcmh-mode t))
;; themeing
(load-file "~/.emacs.d/themes.el")
;; company-mode
(with-eval-after-load 'doom-themes
(load-file "~/.emacs.d/company.el"))
;; (use-package eglot
;; :ensure t
;; :config
;; (add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd")))
;; pdf view
(pdf-loader-install)
(defun turn-off-line-numbers ()
"It turn of line number mode when in pdf-tools mode."
(display-line-numbers-mode -1))
(add-hook 'pdf-view-mode-hook #'turn-off-line-numbers)
(add-to-list 'default-frame-alist '(font . "FiraCode Nerd Font-12"))
;; (use-package nov
;; :ensure t
;; :config
;; (add-hook 'nov-mode-hook 'visual-fill-column-mode)
;; (add-hook 'nov-mode-hook 'turn-off-line-numbers))
;; nov.el
;; (defun nov-display ()
;; (face-remap-add-relative 'variable-pitch :family "FiraCode Nerd Font"
;; :height 100)
;; (toggle-scroll-bar -1)
;; (setq mode-line-format nil
;; nov-header-line-format ""
;; cursor-type nil))
;; (setq-default visual-fill-column-center-text t)
;; (setq-default visual-fill-column-width 120)
;; (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
;;(setq nov-text-width 80)
;;(setq nov-text-width t)
;;(setq nov-text-width 120)
;; aggressive indentation bad so I use electric indent mode
(electric-indent-mode 1)
;; git integration
(use-package magit
:ensure t
:commands (magit-status magit-get-current-branch)
:bind ("C-x g" . magit-status)
:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
;; flychecker
(use-package flymake
:hook (prog-mode)
:config
(remove-hook 'flymake-diagnostic-functions #'flymake-proc-legacy-flymake))
;; mood line
(load-file "~/.emacs.d/mood-line.el")
;; god-mode
(load-file "~/.emacs.d/god-mode.el")
;; golden ratio to handle the buffers
(use-package golden-ratio
:ensure t
:hook (after-init . golden-ratio-mode)
:custom
(golden-ratio-exclude-modes '(occur-mode)))
;; org-mode
(load-file "~/.emacs.d/org-mode-config.el")
(defun lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(use-package lsp-mode
:init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(c-mode . lsp)
(c++-mode . lsp)
(rust-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration))
:commands (lsp lsp-deferred))
;; erc
(load-file "~/.emacs.d/erc.el")
;; dimmer.el
(use-package dimmer
:defer t
:config
(dimmer-configure-which-key)
(dimmer-mode t)
(setq dimmer-fraction 0.4)
(setq dimmer-watch-frame-focus-events nil))
;; solaire-mode
(use-package solaire-mode
:defer t
:config
(solaire-global-mode +1))
;; ;; dart-mode
;; (use-package dart-mode
;; :ensure t)
;; ;; flutter-mode
;; (use-package flutter
;; :after dart-mode
;; :config
;; (flutter-sdk-path "~/development/flutter"))
;; electric-pair
(electric-pair-mode t)
;; electric indent
(electric-indent-mode t)
;; dirvish
(use-package dirvish
:after (dired)
:init
(dirvish-override-dired-mode)
:config
(add-hook 'dirvish-directory-view-mode-hook #'turn-off-line-numbers)
(setq dirvish-use-mode-line 'global)
(setq dirvish-mode-line-format
'(:left (sort symlink) :right (omit yank index)))
(setq dirvish-attributes
'(file-time file-size collapse subtree-state vc-state git-msg))
(setq delete-by-moving-to-trash t)
(bind-key "C-c x" 'dirvish-side))
;; elfeed
(use-package elfeed
:bind ("C-x w" . elfeed)
:config
(add-hook 'elfeed-new-entry-hook (elfeed-make-tagger :before "2 weeks ago" :remove 'unread))
;; feeds
(setq elfeed-feeds
'(("https://reddit.com/r/linux.rss" reddit linux)
("https://www.reddit.com/r/emacs.rss" reddit emacs)
("https://systemcrafters.net/rss/news.xml" emacs)
("https://www.thehindu.com/feeder/default.rss" india news)
("https://timesofindia.indiatimes.com/rssfeedstopstories.cms" india news)
("https://okmij.org/ftp/rss.xml" programming)
("https://www.stallman.org/rss/rss.xml" stallman)
("https://www.reddit.com/r/programming/.rss" programming reddit)
("https://news.ycombinator.com/rss" news tech)
("https://www.nature.com/nature.rss" science)
("https://phys.org/rss-feed/" science)
("https://variety.com/feed/" film))))
;; elfeed-score
(use-package elfeed-score
:after (elfeed)
:config
(progn
(elfeed-score-enable)
(define-key elfeed-search-mode-map "=" elfeed-score-map)))
;; elfeed-dashboard
(use-package elfeed-dashboard
:after (elfeed)
:config
(setq elfeed-dashboard-file "~/elfeed-dashboard.org")
;; update feed counts on elfeed-quit
(advice-add 'elfeed-search-quit-window :after #'elfeed-dashboard-update-links))
;; elfeed-goodies
(use-package elfeed-goodies
:after (elfeed)
:init
(elfeed-goodies/setup))
;; visual-replace
(use-package visual-replace
:defer t
:bind (("C-c r" . visual-replace)
:map isearch-mode-map
("C-c r" . visual-replace-from-isearch))
:config
(visual-replace-global-mode))
;; discord
;; (load-file "./elcord.el")
;; (require 'elcord)
;; (elcord-mode)
;; rainbow-mode
(use-package rainbow-mode
:ensure t
:config
(rainbow-mode t))
;; ement (matrix)
(use-package ement
:ensure t)
;; remember the last place in a file
(save-place-mode t)
;; use-package with package.el:
(use-package dashboard
:ensure t
:init
(setq initial-buffer-choice 'dashboard-open)
:config
(dashboard-setup-startup-hook)
(setq dashboard-banner-logo-title "Welcome to Emacs")
(setq dashboard-startup-banner 'logo)
(setq dashboard-center-content t)
(setq dashboard-vertically-center-content t))
;; 0x0.st
(use-package 0x0
:commands (0x0-upload-file 0x0-upload-text))
(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
'(rainbow-mode visual-replace ement elfeed-goodies elfeed-dashboard elfeed-score elfeed ultra-scroll 0x0 solaire-mode gcmh dimmer org-autolist doom-themes zenburn-theme gruvbox-theme emojify erc-image erc-hl-nicks emacsql-sqlite org-roam dired-sidebar elcord lsp-mode nov visual-fill-column golden-ratio org-bullets all-the-icons treemacs god-mode ## smartparens-global-mode smartparens-mode magit company-manually auto-complete aggressive-indent))
'(package-vc-selected-packages
'((ultra-scroll :vc-backend Git :url "https://github.com/jdtsmith/ultra-scroll")))
'(send-mail-function 'mailclient-send-it))
(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.
)
(provide 'init)
;;; init.el ends here