;;; init.el -*- lexical-binding: t; -*- (defun chris/display-startup-time () (message "Emacs loaded in %s with %d garbage collections." (format "%.2f seconds" (float-time (time-subtract after-init-time before-init-time))) gcs-done)) (add-hook 'emacs-startup-hook #'chris/display-startup-time) (setq inhibit-startup-message t) (setq default-frame-alist '((undecorated . t))) (tool-bar-mode -1) (tooltip-mode -1) (set-fringe-mode +1) (scroll-bar-mode -1) (menu-bar-mode -1) (blink-cursor-mode -1) (column-number-mode +1) (setq-default indent-tabs-mode nil) (setq comp-deferred-compilation-deny-list nil) (setq frame-resize-pixelwise t) (set-frame-parameter nil 'undecorated t) (if (string-equal (system-name) "syl") (defvar chris/default-font-size 120) (defvar chris/default-font-size 120)) (defun chris/set-font-faces () "Set the faces for our fonts" (interactive) (message "Setting faces!") (set-face-attribute 'default nil :font "VictorMono Nerd Font Propo" :height chris/default-font-size) (set-face-attribute 'fixed-pitch nil :font "VictorMono Nerd Font Propo" :height chris/default-font-size) (set-face-attribute 'variable-pitch nil :font "Noto Sans" :height (+ chris/default-font-size (/ chris/default-font-size 12)) :weight 'regular)) (defun chris/set-transparency () "Set the frame to be transparent but not the text" (set-frame-parameter (selected-frame) 'alpha-background 85) (add-to-list 'default-frame-alist '(alpha-background . 85)) (add-to-list 'initial-frame-alist '(alpha-background . 85))) (if (daemonp) (add-hook 'after-make-frame-functions (lambda (frame) (with-selected-frame frame (chris/set-font-faces) (chris/set-transparency) (tool-bar-mode -1))) (chris/set-font-faces))) (setq display-line-numbers-type t) (global-display-line-numbers-mode +1) (add-hook 'prog-mode-hook (display-line-numbers-mode +1)) (global-visual-line-mode +1) (defun on-frame-open (frame) (if (not (display-graphic-p frame)) (set-face-background 'default "unspecified-bg" frame))) (add-hook 'after-make-frame-functions 'on-frame-open) ;; always avoid GUI (setq use-dialog-box nil) ;; Don't display floating tooltips; display their contents in the echo-area, ;; because native tooltips are ugly. (when (bound-and-true-p tooltip-mode) (tooltip-mode -1)) ;; ...especially on linux (setq x-gtk-use-system-tooltips nil) ;; Favor vertical splits over horizontal ones. Screens are usually wide. (setq split-width-threshold 160 split-height-threshold nil) (setq doc-view-resolution 192) (fset 'evil-redirect-digit-argument 'ignore) (global-set-key (kbd "") 'keyboard-escape-quit) (recentf-mode +1) ;; (savehist-mode +1) ;; (add-to-list 'savehist-additional-variables 'register-alist) ;; (add-to-list 'savehist-additional-variables kill-ring) (add-to-list 'exec-path "/home/chris/bin") (add-to-list 'exec-path "/home/chris/.cargo/bin") (setq initial-major-mode 'org-mode) (setq initial-scratch-message "#+TITLE: SCRATCH\n#+DESCRIPTION: This buffer is for temporary things\n") (setq require-final-newline nil) (dolist (path load-path) (when (string-match-p "/nix/store/[a-z0-9]\\{32\\}-emacs-packages-deps.*" path) (dolist (autoload-file (directory-files path t "-autoloads.el")) (with-demoted-errors "init.el error: %s" (load autoload-file nil t))))) (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) (eval-when-compile (require 'use-package)) (setq use-package-verbose t) (defalias 'yes-or-no-p 'y-or-n-p) (use-package command-log-mode :commands command-log-mode) (defun chris/home-manager-reload () (interactive) (let* ((which-emacs (shell-command-to-string "nix-store --query $(which emacs)")) (pattern (rx "newLoadPath+=(/nix/store/" (group (* any)) "-emacs-packages-deps/share/emacs/site-lisp)")) (current-deps (when (string-match pattern which-emacs) (match-string 1 which-emacs))) (subdirs (concat "/nix/store/" current-deps "-emacs-packages-deps/share/emacs/site-lisp/subdirs.el")) (native (concat "/nix/store/" current-deps "-emacs-packages-deps/share/emacs/native-lisp/"))) (load-file subdirs) (when (boundp 'native-comp-eln-load-path) (add-to-list 'native-comp-eln-load-path native)))) (use-package all-the-icons) (use-package doom-modeline :init (doom-modeline-mode 0) (setq doom-modeline-height 25 doom-modeline-bar-width 3 all-the-icons-scale-factor 0.9 doom-modeline-hud nil doom-modeline-buffer-file-name-style 'file-name doom-modeline-buffer-encoding nil doom-modeline-mu4e t doom-modeline-enable-word-count nil) (if (daemonp) (add-hook 'after-make-frame-functions (lambda (frame) (with-selected-frame frame (setq doom-modeline-icon t)))))) (use-package doom-themes :ensure t :init (load-theme 'doom-snazzy t)) (use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode)) (use-package aggressive-indent :config (aggressive-indent-mode -1)) (use-package adaptive-wrap) (use-package which-key :config (setq which-key-idle-delay 0.3) (which-key-mode)) (use-package mini-echo :init (mini-echo-mode 1) (setq mini-echo-default-segments '(:long ("evil" "major-mode" "buffer-name" "vcs" "buffer-position" "buffer-size" "flymake" "process" "selection-info" "narrow" "macro" "profiler") :short ("buffer-name-short" "buffer-position" "process" "profiler" "selection-info" "narrow" "macro")) mini-echo-rules '((org-mode :long (("evil" . 1) ("major-mode" . 2) ("buffer-name" . 3) ("word-count" . 4)))) mini-echo-right-padding 2 mini-echo-buffer-status-style 'both mini-echo-update-interval 0.2) (set-face-foreground 'mini-echo-blue "#57c7ff") (set-face-foreground 'mini-echo-red "#ff5c57") (set-face-foreground 'mini-echo-magenta "#ff6ac1") (set-face-foreground 'mini-echo-green "#5af78e") (set-face-foreground 'mini-echo-gray "#848688") (set-face-foreground 'mini-echo-yellow "#f3f99d") (set-face-foreground 'mini-echo-cyan "#9aedfe") (defun chris/mini-echo-minibuffer-width-lessp () "Return non-nil if current minibuffer window width less than 120." (< (mini-echo-minibuffer-width) 100)) (setq mini-echo-short-style-predicate 'chris/mini-echo-minibuffer-width-lessp) :config (defun chris/toggle-mode-lines () "Switch between doom and mini-echo" (interactive) (if mini-echo-mode (eval (mini-echo-mode 0) (doom-modeline-mode 1)) (eval (doom-modeline-mode 0) (mini-echo-mode 1))))) (setq xref-search-program 'ripgrep) (add-to-list 'exec-path "/usr/bin") (add-to-list 'exec-path "~/.cargo/bin") (setenv "NIX_CONF_DIR" "/etc/nix") (setenv "NIX_REMOTE" "daemon") (setenv "XCURSOR_THEME" "phinger-cursors-light") (setenv "QT_SCALE_FACTOR" "1") (setenv "QT_QPA_PLATFORM" "wayland;xcb") (setenv "CLUTTER_BACKEND" "wayland") (setenv "GDK_BACKEND" "wayland,x11") (setenv "SDL_VIDEODRIVER" "wayland") (setenv "XDG_SESSION_TYPE" "wayland") (defun chris/nix-reload () (interactive) (let* ((query (shell-command-to-string "nix-store --query $(which emacs)")) (store-path (expand-file-name "share/emacs" (string-trim query)))) (load-file (expand-file-name "site-lisp/subdirs.el" store-path)) (when (boundp 'native-comp-eln-load-path) (add-to-list 'native-comp-eln-load-path (expand-file-name "native-lisp/" store-path))))) (setenv "WAYLAND_DISPLAY" "wayland-1") (executable-find "ssh") (setq ispell-program-name "hunspell" ispell-local-dictionary "en_US" ispell-local-dictionary-alist ;; Please note the list `("-d" "en_US")` contains ACTUAL parameters passed to hunspell ;; You could use `("-d" "en_US,en_US-med")` to check with multiple dictionaries '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8))) (add-hook 'org-mode-hook 'chris/org-mode-setup) (setq proced-auto-update-flag t) (use-package no-littering) ;; no-littering doesn't set this by default so we must place ;; auto save files in the same path as it uses for sessions (setq auto-save-file-name-transforms `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))) (setq backup-directory-alist '(("." . "~/.emacs.d/backup")) backup-by-copying t ; Don't delink hardlinks version-control t ; Use version numbers on backups delete-old-versions t ; Automatically delete excess backups kept-new-versions 20 ; how many of the newest versions to keep kept-old-versions 5 ; and how many of the old ) (use-package ligature :load-path "path-to-ligature-repo" :config ;; Enable the "www" ligature in every possible major mode (ligature-set-ligatures 't '("www")) ;; Enable traditional ligature support in eww-mode, if the ;; `variable-pitch' face supports it (ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi")) ;; Enable all Cascadia and Fira Code ligatures in programming modes (ligature-set-ligatures 'prog-mode '(;; == === ==== => =| =>>=>=|=>==>> ==< =/=//=// =~ ;; =:= =!= ("=" (rx (+ (or ">" "<" "|" "/" "~" ":" "!" "=")))) ;; ;; ;;; (";" (rx (+ ";"))) ;; && &&& ("&" (rx (+ "&"))) ;; !! !!! !. !: !!. != !== !~ ("!" (rx (+ (or "=" "!" "\." ":" "~")))) ;; ?? ??? ?: ?= ?. ("?" (rx (or ":" "=" "\." (+ "?")))) ;; %% %%% ("%" (rx (+ "%"))) ;; |> ||> |||> ||||> |] |} || ||| |-> ||-|| ;; |->>-||-<<-| |- |== ||=|| ;; |==>>==<<==<=>==//==/=!==:===> ("|" (rx (+ (or ">" "<" "|" "/" ":" "!" "}" "\]" "-" "=" )))) ;; \\ \\\ \/ ("\\" (rx (or "/" (+ "\\")))) ;; ++ +++ ++++ +> ("+" (rx (or ">" (+ "+")))) ;; :: ::: :::: :> :< := :// ::= (":" (rx (or ">" "<" "=" "//" ":=" (+ ":")))) ;; // /// //// /\ /* /> /===:===!=//===>>==>==/ ("/" (rx (+ (or ">" "<" "|" "/" "\\" "\*" ":" "!" "=")))) ;; .. ... .... .= .- .? ..= ..< ("\." (rx (or "=" "-" "\?" "\.=" "\.<" (+ "\.")))) ;; -- --- ---- -~ -> ->> -| -|->-->>->--<<-| ("-" (rx (+ (or ">" "<" "|" "~" "-")))) ;; *> */ *) ** *** **** ("*" (rx (or ">" "/" ")" (+ "*")))) ;; www wwww ("w" (rx (+ "w"))) ;; <>