forked from seagle0128/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
142 lines (115 loc) · 4.23 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
;;; init.el --- Centaur Emacs configurations. -*- lexical-binding: t no-byte-compile: t; -*-
;; Copyright (C) 2006-2019 Vincent Zhang
;; Author: Vincent Zhang <[email protected]>
;; URL: https://github.com/seagle0128/.emacs.d
;; Version: 5.4.0
;; Keywords: .emacs.d centaur
;; 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 configurations.
;;
;;; Code:
(when (version< emacs-version "25.1")
(error "This requires Emacs 25.1 and above!"))
;; Speed up startup
(defvar default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(setq gc-cons-threshold 40000000)
(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 800000)
;; 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 40000000))
(defun my-minibuffer-exit-hook ()
(garbage-collect)
(setq gc-cons-threshold 800000))
(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'."
(push (expand-file-name "site-lisp" user-emacs-directory) load-path)
(push (expand-file-name "lisp" 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)
;; Constants
(require 'init-const)
;; Customization
(require 'init-custom)
;; Packages
;; Without this comment Emacs25 adds (package-initialize) here
(require 'init-package)
;; Preferences
(require 'init-basic)
(require 'init-funcs)
(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-elfeed)
(require 'init-utils)
;; Programming
(require 'init-vcs)
(require 'init-flycheck)
(require 'init-projectile)
(require 'init-lsp)
(require 'init-emacs-lisp)
(require 'init-c)
(require 'init-go)
(require 'init-python)
(require 'init-ruby)
(require 'init-elixir)
(require 'init-web)
(require 'init-prog)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init.el ends here