aboutsummaryrefslogtreecommitdiffstats
path: root/init.el
blob: 13c3b64c0b71b16b9936b300071131aaa68ffb06 (plain)
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
;;; init.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;; Emacs!!!

;;; Code:
;; Without this comment emacs25 adds (package-initialize) here
;; (package-initialize)

;;; Time Mark
(setq emacs-load-start-time (current-time))

(setq package-check-signature 'allow-unsigned)

;;; Fix TLS emacs 26.x
(if (version<= emacs-version "26.2")
    (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))

;;; Welcome message
(setq-default initial-scratch-message
              (concat ";; Happy hacking, " user-login-name " - Emacs loves you!\n\n"))

(defvar before-user-init-time (current-time)
  "Value of `current-time' when Emacs begins loading `user-init-file'.")

;;; Garbage Collector
(progn
  ;; Set this to true to find GC issues.
  (setq garbage-collection-messages nil)

  ;; Increase the gc-cons-threshold to a very high number to decrease
  ;; the load and compile time. The value will be decreased
  ;; significantly after initialization to avoid long GC pauses during
  ;; normal usage.
  (setq gc-cons-threshold 402653184
        gc-cons-percentage 0.6)

  (setq read-process-output-max (* 1024 1024)) ;; 1mb

  ;; Reset GC to normal values.
  (add-hook 'emacs-startup-hook
            (lambda ()
              (message
               "[STARTUP] Loading %s...done (%.3fs)" user-init-file
               (float-time (time-subtract (current-time)
                                          before-user-init-time)))

              (when init-file-debug
                (message "Rolling back GC settings to sane values."))
              (setq gc-cons-threshold 16777216
                    gc-cons-percentage 0.1))))

;;; Modules directory
(push (concat user-emacs-directory "lisp") load-path)

;;;------------------------------
;;; Features
;;;------------------------------
;;; https://stackoverflow.com/questions/2816019/in-lisp-avoid-cannot-open-load-file-when-using-require

;; @see https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/
;; Normally file-name-handler-alist is set to
;; (("\\`/[^/]*\\'" . tramp-completion-file-name-handler)
;; ("\\`/[^/|:][^/|]*:" . tramp-file-name-handler)
;; ("\\`/:" . file-name-non-special))
;; Which means on every .el and .elc file loaded during start up, it has to runs those regexps against the filename.
(let* ((file-name-handler-alist nil))
  ;; package-initialize' takes 35% of startup time
  ;; need check https://github.com/hlissner/doom-emacs/wiki/FAQ#how-is-dooms-startup-so-fast for solution
  (require 'init-security)
  (require 'init-elpa)
  ;; theme
  (require 'init-theme)
  ;; Utils
  (require 'init-utils)
  ;; GUI
  (require 'init-nlinum)
  (require 'init-gui)
  (require 'init-editing-utils)
  (require 'init-modeline)
  ;; Tools
  (require 'init-flycheck)
  ;; Languages
  (require 'init-markdown)
  (require 'init-python)
  (require 'init-pkgbuild)
  (require 'init-php)
  (require 'init-less)
  (require 'init-sass)
  (require 'init-scss)
  ;; Plus
  (require 'init-rainbow)
  )

;;; Custom variables
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
;;; Loads custom file
(when (file-exists-p custom-file)
  (load custom-file))

;;; Settings
(setq settings-file (expand-file-name "settings.el" user-emacs-directory))
;;; Loads settings file
(when (file-exists-p custom-file)
  (load settings-file))

;; enable erase-buffer command
(put 'erase-buffer 'disabled nil)

(provide 'init)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init.el ends here