chore(emacs): refactor emacs config
This commit is contained in:
parent
1a6469420d
commit
9012a765a8
5 changed files with 1263 additions and 13 deletions
1
config/emacs/.gitignore
vendored
1
config/emacs/.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
var
|
||||
undo
|
||||
elpa
|
||||
|
|
|
|||
159
config/emacs/early-init.el
Normal file
159
config/emacs/early-init.el
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
;;; early-init.el --- Early Init -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Startup time
|
||||
(defvar rs/show-startup-time t
|
||||
"If non-nil, display startup time after Emacs loads.")
|
||||
|
||||
(defun rs/display-startup-time ()
|
||||
"Display startup time in milliseconds and seconds."
|
||||
(when rs/show-startup-time
|
||||
(let* ((time (float-time (time-subtract after-init-time before-init-time)))
|
||||
(ms (* time 1000)))
|
||||
(message "Emacs loaded in %.0fms (%.2fs) with %d garbage collections."
|
||||
ms time gcs-done))))
|
||||
|
||||
(add-hook 'emacs-startup-hook #'rs/display-startup-time 110)
|
||||
|
||||
;;; GC optimization
|
||||
(defvar rs/backup-gc-cons-threshold gc-cons-threshold)
|
||||
(defvar rs/backup-gc-cons-percentage gc-cons-percentage)
|
||||
(setq gc-cons-threshold most-positive-fixnum)
|
||||
(setq gc-cons-percentage 1.0)
|
||||
|
||||
;;; Directories
|
||||
(defvar rs/emacs-dir user-emacs-directory)
|
||||
(defvar rs/lib-dir (expand-file-name "lib/" rs/emacs-dir))
|
||||
(defvar rs/var-dir (expand-file-name "var/" rs/emacs-dir))
|
||||
|
||||
(setq package-user-dir (expand-file-name "elpa/" rs/var-dir))
|
||||
(setq user-emacs-directory rs/var-dir)
|
||||
(setq custom-file null-device)
|
||||
(setq custom-theme-directory (expand-file-name "themes/" rs/emacs-dir))
|
||||
|
||||
;;; Restore GC after startup
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(setq gc-cons-threshold (* 64 1024 1024))
|
||||
(setq gc-cons-percentage 0.1)) 105)
|
||||
|
||||
;;; Native compilation
|
||||
(when (and (featurep 'native-compile)
|
||||
(fboundp 'native-comp-available-p)
|
||||
(native-comp-available-p))
|
||||
(setq package-native-compile t)
|
||||
(setq native-comp-async-report-warnings-errors 'silent)
|
||||
(setq native-compile-prune-cache t)
|
||||
(startup-redirect-eln-cache (expand-file-name "eln-cache/" rs/var-dir)))
|
||||
|
||||
(setq native-comp-warning-on-missing-source nil)
|
||||
(setq jka-compr-verbose nil)
|
||||
(setq byte-compile-warnings nil)
|
||||
(setq byte-compile-verbose nil)
|
||||
|
||||
;;; GCC paths for macOS
|
||||
(when-let* ((gcc-base "/opt/homebrew/opt/gcc/lib/gcc/current")
|
||||
((file-directory-p gcc-base)))
|
||||
(setenv "LIBRARY_PATH"
|
||||
(string-join
|
||||
(delq nil
|
||||
(list gcc-base
|
||||
(let ((jit-path "/opt/homebrew/opt/libgccjit/lib/gcc/current"))
|
||||
(when (file-directory-p jit-path) jit-path))
|
||||
(car (last (file-expand-wildcards
|
||||
(concat gcc-base "/gcc/aarch64-apple-darwin*/*"))))))
|
||||
":")))
|
||||
|
||||
;;; Misc performance
|
||||
(setq load-prefer-newer t)
|
||||
(setq read-process-output-max (* 2 1024 1024))
|
||||
(setq process-adaptive-read-buffering nil)
|
||||
(setq ffap-machine-p-known 'reject)
|
||||
(setq ad-redefinition-action 'accept)
|
||||
(setq warning-suppress-types '((lexical-binding)))
|
||||
(setq inhibit-compacting-font-caches t)
|
||||
|
||||
(when (boundp 'pgtk-wait-for-event-timeout)
|
||||
(setq pgtk-wait-for-event-timeout 0.001))
|
||||
|
||||
;;; File name handler optimization
|
||||
(defvar rs/old-file-name-handler-alist (default-toplevel-value 'file-name-handler-alist))
|
||||
|
||||
(defun rs/restore-file-name-handler-alist ()
|
||||
(set-default-toplevel-value
|
||||
'file-name-handler-alist
|
||||
(delete-dups (append file-name-handler-alist rs/old-file-name-handler-alist))))
|
||||
|
||||
(unless (daemonp)
|
||||
(set-default-toplevel-value
|
||||
'file-name-handler-alist
|
||||
(if (locate-file-internal "calc-loaddefs.el" load-path)
|
||||
nil
|
||||
(list (rassq 'jka-compr-handler rs/old-file-name-handler-alist))))
|
||||
(put 'file-name-handler-alist 'initial-value rs/old-file-name-handler-alist)
|
||||
(add-hook 'emacs-startup-hook #'rs/restore-file-name-handler-alist 101))
|
||||
|
||||
;;; UI - disable before frame creation
|
||||
(setq default-frame-alist '((background-color . "#072626")
|
||||
(ns-appearance . dark)
|
||||
(ns-transparent-titlebar . t)
|
||||
(menu-bar-lines . 0)
|
||||
(tool-bar-lines . 0)
|
||||
(vertical-scroll-bars . nil)
|
||||
(horizontal-scroll-bars . nil)
|
||||
(frame-resize-pixelwise . t)))
|
||||
|
||||
(setq frame-resize-pixelwise t)
|
||||
(setq frame-inhibit-implied-resize t)
|
||||
(setq auto-mode-case-fold nil)
|
||||
|
||||
(setq inhibit-splash-screen t)
|
||||
(setq inhibit-startup-screen t)
|
||||
(setq inhibit-startup-echo-area-message user-login-name)
|
||||
(setq inhibit-startup-buffer-menu t)
|
||||
(setq inhibit-x-resources t)
|
||||
(setq initial-buffer-choice nil)
|
||||
(setq initial-scratch-message nil)
|
||||
(setq initial-major-mode 'fundamental-mode)
|
||||
|
||||
(setq menu-bar-mode nil)
|
||||
(setq tool-bar-mode nil)
|
||||
(setq scroll-bar-mode nil)
|
||||
|
||||
(setq frame-title-format "%b – Emacs")
|
||||
(setq icon-title-format frame-title-format)
|
||||
|
||||
;; Bidirectional text optimization
|
||||
(setq-default bidi-display-reordering 'left-to-right)
|
||||
(setq-default bidi-paragraph-direction 'left-to-right)
|
||||
(setq bidi-inhibit-bpa t)
|
||||
|
||||
;; Suppress startup messages
|
||||
(advice-add 'display-startup-echo-area-message :override #'ignore)
|
||||
(advice-add 'display-startup-screen :override #'ignore)
|
||||
|
||||
;; Unset irrelevant command line options
|
||||
(unless (eq system-type 'darwin)
|
||||
(setq command-line-ns-option-alist nil))
|
||||
(unless (memq initial-window-system '(x pgtk))
|
||||
(setq command-line-x-option-alist nil))
|
||||
|
||||
;;; Security
|
||||
(setq gnutls-verify-error t)
|
||||
(setq tls-checktrust t)
|
||||
(setq gnutls-min-prime-bits 3072)
|
||||
|
||||
;;; Package archives
|
||||
(setq package-enable-at-startup nil)
|
||||
(setq use-package-always-ensure t)
|
||||
(setq use-package-enable-imenu-support t)
|
||||
(setq use-package-expand-minimally t)
|
||||
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
||||
("gnu" . "https://elpa.gnu.org/packages/")
|
||||
("nongnu" . "https://elpa.nongnu.org/nongnu/")
|
||||
("melpa-stable" . "https://stable.melpa.org/packages/")))
|
||||
(setq package-archive-priorities '(("gnu" . 99)
|
||||
("nongnu" . 80)
|
||||
("melpa" . 70)
|
||||
("melpa-stable" . 50)))
|
||||
|
||||
;;; early-init.el ends here
|
||||
1087
config/emacs/init.el
Normal file
1087
config/emacs/init.el
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
;;; naysayer-theme.el --- The naysayer color theme
|
||||
;;; naysayer-theme.el --- The naysayer color theme -*- lexical-binding: t; -*-
|
||||
|
||||
;; Author: Nick Aversano <nickav@users.noreply.github.com>
|
||||
;; Version: 0.33
|
||||
|
|
@ -58,11 +58,11 @@
|
|||
;; *****************************************************************************
|
||||
|
||||
`(default ((t (:foreground ,text :background ,background, :weight normal))))
|
||||
`(region ((t (:foreground nil :background ,selection))))
|
||||
`(region ((t (:foreground unspecified :background ,selection))))
|
||||
`(cursor ((t (:background ,white ))))
|
||||
`(fringe ((t (:background ,background :foreground ,white))))
|
||||
`(linum ((t (:background ,background :foreground ,gutter-fg))))
|
||||
`(highlight ((t (:foreground nil :background ,selection))))
|
||||
`(highlight ((t (:foreground unspecified :background ,selection))))
|
||||
|
||||
;; Font lock faces
|
||||
;; *****************************************************************************
|
||||
|
|
@ -83,8 +83,8 @@
|
|||
|
||||
;; Plugins
|
||||
;; *****************************************************************************
|
||||
`(trailing-whitespace ((t (:foreground nil :background ,warning))))
|
||||
`(whitespace-trailing ((t (:background nil :foreground ,warning :inverse-video t))))
|
||||
`(trailing-whitespace ((t (:foreground unspecified :background ,warning))))
|
||||
`(whitespace-trailing ((t (:background unspecified :foreground ,warning :inverse-video t))))
|
||||
|
||||
`(linum ((t (:foreground ,line-fg :background ,background))))
|
||||
`(linum-relative-current-face ((t (:foreground ,white :background ,background))))
|
||||
|
|
@ -135,8 +135,8 @@
|
|||
`(powerline-inactive2 ((t (:background ,background :foreground ,text))))
|
||||
|
||||
;; better compatibility with default DOOM mode-line
|
||||
`(error ((t (:foreground nil :weight normal))))
|
||||
`(doom-modeline-project-dir ((t (:foreground nil :weight bold))))
|
||||
`(error ((t (:foreground unspecified :weight normal))))
|
||||
`(doom-modeline-project-dir ((t (:foreground unspecified :weight bold))))
|
||||
|
||||
;; js2-mode
|
||||
`(js2-function-call ((t (:inherit (font-lock-function-name-face)))))
|
||||
|
|
|
|||
|
|
@ -13,16 +13,19 @@
|
|||
};
|
||||
|
||||
config = lib.mkIf config.custom.emacs.enable {
|
||||
home.packages = lib.mkIf pkgs.stdenv.isLinux (
|
||||
home.packages =
|
||||
with pkgs;
|
||||
[
|
||||
emacs
|
||||
aspell
|
||||
ispell
|
||||
]
|
||||
);
|
||||
++ lib.optionals pkgs.stdenv.isLinux [
|
||||
emacs
|
||||
];
|
||||
|
||||
home.file.".emacs.d" = {
|
||||
source = "${pkgs.custom.minimal-emacs-d}";
|
||||
};
|
||||
# home.file.".emacs.d" = {
|
||||
# source = "${pkgs.custom.minimal-emacs-d}";
|
||||
# };
|
||||
|
||||
xdg.configFile."emacs".source = config.lib.file.mkOutOfStoreSymlink "${dots}/config/emacs";
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue