forked from seagle0128/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
168 lines (137 loc) · 5.26 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
;;; init.el --- A Fancy and Fast Emacs Configuration. -*- lexical-binding: t no-byte-compile: t -*-
;; Copyright (C) 2006-2020 Vincent Zhang
;; Author: Vincent Zhang <[email protected]>
;; URL: https://github.com/seagle0128/.emacs.d
;; Version: 5.9.0
;; Keywords: .emacs.d centaur
;;
;; `..`
;; ````+ `.`
;; /o:`` :+ ``
;; .+//dho......y/..`
;; `sdddddhysso+h` ``
;; /ddd+`..` +. .`
;; -hos+ `.:```
;; `./dddyo+//osso/:`
;; `/o++dddddddddddddod-
;; `// -y+:sdddddsddsy.dy
;; /o `..```h+`y+/h+`
;; .s `++``o: ``
;; `:- `:-
;;
;; CENTAUR EMACS - Enjoy Programming & Writing
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;; Commentary:
;;
;; Centaur Emacs - A Fancy and Fast Emacs Configuration.
;;
;;; Code:
(when (version< emacs-version "25.1")
(error "This requires Emacs 25.1 and above!"))
;; Speed up startup
(defvar centaur-gc-cons-threshold (if (display-graphic-p) 16000000 1600000)
"The default value to use for `gc-cons-threshold'. If you experience freezing,
decrease this. If you experience stuttering, increase this.")
(defvar centaur-gc-cons-upper-limit (if (display-graphic-p) 400000000 100000000)
"The temporary value for `gc-cons-threshold' to defer it.")
(defvar centaur-gc-timer (run-with-idle-timer 10 t #'garbage-collect)
"Run garbarge collection when idle 10s.")
(defvar default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(setq gc-cons-threshold centaur-gc-cons-upper-limit
gc-cons-percentage 0.5)
(add-hook 'emacs-startup-hook
(lambda ()
"Restore defalut values after startup."
(setq file-name-handler-alist default-file-name-handler-alist)
(setq gc-cons-threshold centaur-gc-cons-threshold
gc-cons-percentage 0.1)
;; GC automatically while unfocusing the frame
;; `focus-out-hook' is obsolete since 27.1
(if (boundp 'after-focus-change-function)
(add-function :after after-focus-change-function
(lambda ()
(unless (frame-focus-state)
(garbage-collect))))
(add-hook 'focus-out-hook 'garbage-collect))
;; Avoid GCs while using `ivy'/`counsel'/`swiper' and `helm', etc.
;; @see http://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/
(defun my-minibuffer-setup-hook ()
(setq gc-cons-threshold centaur-gc-cons-upper-limit))
(defun my-minibuffer-exit-hook ()
(setq gc-cons-threshold centaur-gc-cons-threshold))
(add-hook 'minibuffer-setup-hook #'my-minibuffer-setup-hook)
(add-hook 'minibuffer-exit-hook #'my-minibuffer-exit-hook)))
;; Load path
;; Optimize: Force "lisp"" and "site-lisp" at the head to reduce the startup time.
(defun update-load-path (&rest _)
"Update `load-path'."
(dolist (dir '("site-lisp" "lisp"))
(push (expand-file-name dir user-emacs-directory) load-path)))
(defun add-subdirs-to-load-path (&rest _)
"Add subdirectories to `load-path'."
(let ((default-directory (expand-file-name "site-lisp" user-emacs-directory)))
(normal-top-level-add-subdirs-to-load-path)))
(advice-add #'package-initialize :after #'update-load-path)
(advice-add #'package-initialize :after #'add-subdirs-to-load-path)
(update-load-path)
;; Packages
;; Without this comment Emacs25 adds (package-initialize) here
(require 'init-package)
;; Preferences
(require 'init-basic)
(require 'init-hydra)
(require 'init-ui)
(require 'init-edit)
(require 'init-ivy)
(require 'init-company)
(require 'init-yasnippet)
(require 'init-calendar)
(require 'init-dashboard)
(require 'init-dired)
(require 'init-highlight)
(require 'init-ibuffer)
(require 'init-kill-ring)
(require 'init-persp)
(require 'init-window)
(require 'init-treemacs)
(require 'init-eshell)
(require 'init-shell)
(require 'init-markdown)
(require 'init-org)
(require 'init-reader)
(require 'init-docker)
(require 'init-utils)
;; Programming
(require 'init-vcs)
(require 'init-flycheck)
(require 'init-projectile)
(require 'init-lsp)
(require 'init-prog)
(require 'init-elisp)
(require 'init-c)
(require 'init-go)
(require 'init-rust)
(require 'init-python)
(require 'init-ruby)
(require 'init-dart)
(require 'init-elixir)
(require 'init-web)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init.el ends here