2024-05-19 11:33:49 +08:00

148 lines
4.3 KiB
EmacsLisp

;;; 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 "modules") 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-doom-theme)
(require 'init-vscode-theme)
;; Utils
(require 'init-utils)
;; GUI
(require 'init-gui)
(require 'init-editing-utils)
(require 'init-diminish)
(require 'init-modeline)
(require 'init-indent-guides)
(require 'init-icons)
(require 'init-neotree)
(require 'init-dashboard)
;; Tools
(require 'init-apache)
(require 'init-company)
(require 'init-flycheck)
(require 'init-ivy)
(require 'init-log4j)
(require 'init-whitespace)
(require 'init-emmet-mode)
(require 'init-nginx)
(require 'init-editorconfig)
;; Languages
(require 'init-ccc)
(require 'init-crystal)
(require 'init-html)
(require 'init-js-two)
(require 'init-markdown)
(require 'init-go)
(require 'init-php)
(require 'init-projectile)
(require 'init-python)
(require 'init-pkgbuild)
(require 'init-less)
(require 'init-lua)
(require 'init-smartparens)
(require 'init-sass)
(require 'init-scss)
(require 'init-typescript)
(require 'init-vue)
(require 'init-yaml)
;; Plus
(require 'init-rainbow)
(require 'init-web-mode)
(require 'init-dotenv)
(require 'init-dockerfile)
(require 'init-dokuwiki)
(require 'init-graphviz)
(require 'init-linter)
(require 'init-load-env-vars)
(require 'init-restclient)
(require 'init-terraform)
(require 'init-ox-reveal))
;;; 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