dotfiles/dot_config/emacs/early-init.el.tmpl

123 lines
4.1 KiB
Cheetah
Raw Normal View History

2023-08-10 00:59:36 -04:00
;;; early-init.el --- GNU Emacs Early Initialization File -*- lexical-binding: t; -*-
;; Copyright (c) 2023 Andrew Scott
;; Author: Andrew Scott <andy at andyscott dot me>
;; Keywords: convenience, tools
;; URL: https://codeberg.org/andyscott/dotfiles
;; This file is not part of GNU Emacs.
;;; Commentary:
;; My customizations for early Emacs initialization
;;; License:
;; MIT No Attribution
;; Permission is hereby granted, free of charge, to any person obtaining a copy of this
;; software and associated documentation files (the "Software"), to deal in the Software
;; without restriction, including without limitation the rights to use, copy, modify,
;; merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
;; permit persons to whom the Software is furnished to do so.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
;; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
;; PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;;; Code:
;; Disable `package.el'
(setq package-enable-at-startup nil)
;; Ensure other defaults are loaded
(setq inhibit-default-init nil)
;; Avoid `garbage-collect' during init
(setq gc-cons-percentage 1
gc-cons-threshold most-positive-fixnum)
;; Skip regexp checking by `find-file-name-handler' during init
(defvar default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
;; Restore `garbage-collect' and `file-name-handler-alist' settings
(add-hook 'elpaca-after-init-hook
(lambda ()
(setq file-name-handler-alist default-file-name-handler-alist
gc-cons-percentage 0.1
gc-cons-threshold (* 1024 1024 8))))
;; Relocate `emacs-user-directory' to XDG_DATA_HOME
2023-11-26 23:54:45 -05:00
(setq user-emacs-directory
(expand-file-name "emacs/" (or (getenv "XDG_DATA_HOME") "~/.local/share/")))
;; Set cache directory
(setq xdg_cache_home
(expand-file-name "emacs/" (or (getenv "XDG_CACHE_HOME") "~/.cache/")))
(unless (file-directory-p xdg_cache_home)
(make-directory xdg_cache_home))
;; Move `eln-cache' to XDG_CACHE_HOME
2023-11-26 23:54:45 -05:00
(when (fboundp 'startup-redirect-eln-cache)
(if (< emacs-major-version 29)
(push (expand-file-name "eln-cache/" xdg_cache_home) native-comp-eln-load-path)
(startup-redirect-eln-cache (expand-file-name "eln-cache/" xdg_cache_home))))
2023-11-26 23:54:45 -05:00
2023-08-10 00:59:36 -04:00
;; Load newest byte code
(setq load-prefer-newer t)
;; Enable async native compilation and suppress warnings
(when (featurep 'native-compile)
(setq native-comp-deferred-compilation t
native-comp-async-report-warnings-errors nil))
;; Don't advertise instructions for frame exit
(setq server-client-instructions nil)
;; Don't implicitly resize the frame
(setq frame-inhibit-implied-resize t)
;; Allow frames to increase/decrease by one pixel
(setq frame-resize-pixelwise t)
2023-08-10 00:59:36 -04:00
;; Disable startup screen
(setq inhibit-startup-screen t)
;; Start in `fundamental-mode' instead of `lisp-interaction-mode' to avoid
;; loading unnecessary packages via hooks
(setq initial-major-mode 'fundamental-mode)
2023-08-10 00:59:36 -04:00
;; Visible bell only
(setq visible-bell t)
;; Fonts
{{- if eq .chezmoi.hostname "helix" }}
2023-08-10 00:59:36 -04:00
(push '(font . "Hack-24") default-frame-alist)
(set-face-font 'default "Hack-24")
(set-face-font 'fixed-pitch "Hack-24")
(set-face-font 'variable-pitch "DejaVu Sans-24")
{{- else }}
(push '(font . "Hack-12") default-frame-alist)
(set-face-font 'default "Hack-12")
(set-face-font 'fixed-pitch "Hack-12")
(set-face-font 'variable-pitch "DejaVu Sans-12")
{{- end }}
2023-08-10 00:59:36 -04:00
2023-08-28 13:02:51 -04:00
;; Some GUI options
2023-08-10 00:59:36 -04:00
(push '(menu-bar-lines . 0) default-frame-alist)
2023-11-26 23:54:45 -05:00
(push '(tool-bar-lines . 0) default-frame-alist)
2023-08-10 00:59:36 -04:00
(push '(vertical-scroll-bars) default-frame-alist)
(push '(background-color . "#282828") default-frame-alist)
(push '(foreground-color . "#c6c6c6") default-frame-alist)
2023-08-10 00:59:36 -04:00
;; Make lsp-mode use plists
(setenv "LSP_USE_PLISTS" "true")
2023-08-10 00:59:36 -04:00
(provide 'early-init)
;;; early-init.el ends here