emacs-personal/init.el
2019-05-14 12:57:26 -05:00

142 lines
4.6 KiB
EmacsLisp

;;; init.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;; Emacs!!!
;;; Code:
;; Without this comment emacs25 adds (package-initialize) here
;; (package-initialize)
(let* ((minver "24.4"))
(when (version< emacs-version minver)
(error "Emacs v%s or higher is required" minver)))
;;; Welcome message
(setq-default initial-scratch-message
(concat ";; Happy hacking, " user-login-name " - Emacs loves you!\n\n"))
;;; Modules directory
(push (concat user-emacs-directory "modules") load-path)
;;; Raise garbage collection threshold after init
(defvar best-gc-cons-threshold
4000000
"Best default gc threshold value. Should NOT be too big!")
;; don't GC during startup to save time
(setq gc-cons-threshold most-positive-fixnum)
(setq emacs-load-start-time (current-time))
;;----------------------------------------------------------------------------
;; Which functionality to enable (use t or nil for true and false)
;;----------------------------------------------------------------------------
(setq *is-a-mac* (eq system-type 'darwin))
(setq *win64* (eq system-type 'windows-nt))
(setq *cygwin* (eq system-type 'cygwin) )
(setq *linux* (or (eq system-type 'gnu/linux) (eq system-type 'linux)) )
(setq *unix* (or *linux* (eq system-type 'usg-unix-v) (eq system-type 'berkeley-unix)) )
(setq *emacs24* (>= emacs-major-version 24))
(setq *emacs25* (>= emacs-major-version 25))
(setq *emacs26* (>= emacs-major-version 26))
(setq *no-memory* (cond
(*is-a-mac*
(< (string-to-number (nth 1 (split-string (shell-command-to-string "sysctl hw.physmem")))) 4000000000))
(*linux* nil)
(t nil)))
;; @see https://www.reddit.com/r/emacs/comments/55ork0/is_emacs_251_noticeably_slower_than_245_on_windows/
;; Emacs 25 does gc too frequently
(when *emacs25*
;; (setq garbage-collection-messages t) ; for debug
(setq best-gc-cons-threshold (* 64 1024 1024))
(setq gc-cons-percentage 0.5)
(run-with-idle-timer 5 t #'garbage-collect))
;;; Custom variables
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
;;; Custom settings
(setq settings-file (expand-file-name "settings.el" user-emacs-directory))
;;; Loads settings file
(when (file-exists-p custom-file)
(load settings-file))
;;;------------------------------
;;; 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-diminish)
(require 'init-ecb)
(require 'init-modeline)
(require 'init-indent-guides)
(require 'init-icons)
(require 'init-neotree)
;; 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-git)
;;(require 'init-editorconfig nil 'noerror)
;; Languages
(require 'init-ccc)
(require 'init-crystal)
(require 'init-html)
(require 'init-markdown)
(require 'init-php)
(require 'init-python)
(require 'init-pkgbuild)
(require 'init-less)
(require 'init-sass)
(require 'init-scss)
(require 'init-yaml)
;; Plus
(require 'init-rainbow)
(require 'init-web-mode)
(require 'init-dokuwiki))
;;; Loads custom file
(when (file-exists-p custom-file)
(load custom-file))
(setq gc-cons-threshold best-gc-cons-threshold)
(when window-system
(let ((elapsed (float-time (time-subtract (current-time)
emacs-load-start-time))))
(message "[STARTUP] Loading %s ... done (%.3fs)" load-file-name elapsed)))
;; enable erase-buffer command
(put 'erase-buffer 'disabled nil)
(provide 'init)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init.el ends here