;;; init.el -- My emacs config -*- lexical-binding: t -*- ;;; Commentary: ;; Moving my Emacs config from separate directory ;; To install packages on non-NixOS systems run `install.el' ;;; Code: ;; Stop popups for warning messages, keep in log buffer (setopt warning-minimum-level :error) ;; Configure packages archives with priority (load-file (locate-user-emacs-file "lib/package-config.el")) (setq custom-file (locate-user-emacs-file "custom.el")) (when (and custom-file (file-exists-p custom-file)) (load custom-file nil 'nomessage)) (set-default-coding-systems 'utf-8) (setq user-full-name "Evie Litherland-Smith" user-mail-address "evie@xenia.me.uk" inhibit-splash-screen t use-short-answers t tab-always-indent 'complete completion-cycle-threshold nil completions-detailed t kill-do-not-save-duplicates t) (setq-default truncate-lines t truncate-partial-width-windows nil) (setopt indent-tabs-mode nil async-shell-command-display-buffer nil compilation-scroll-output t) (global-prettify-symbols-mode +1) (global-auto-revert-mode +1) (delete-selection-mode +1) (menu-bar-mode +1) (tab-bar-mode +1) (tool-bar-mode -1) (scroll-bar-mode -1) (use-package pixel-scroll :init (pixel-scroll-precision-mode +1)) (use-package mwheel :custom (mouse-wheel-scroll-amount '(1 ((shift) . 1))) (mouse-wheel-progressive-speed nil) (mouse-wheel-follow-mouse t)) ;; Bind normal forward/back buttons on mouse to next/previous buffer respectively (keymap-global-set "" #'previous-buffer) (keymap-global-set "" #'next-buffer) ;; Quick bind for calling `git-sync-all' (defun my/git-sync-all () "Run shell command `git-sync-all' asynchronously." (interactive) (async-shell-command "git-sync-all" "*git-sync-all*" "*git-sync-errors*")) (keymap-global-set "C-c g s" #'my/git-sync-all) ;; Make shebang (#!) file executable when saved (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) ;; Remap `upcase-word' and `downcase-word' to DWIM versions (keymap-global-set " " 'upcase-dwim) (keymap-global-set " " 'downcase-dwim) (setq backup-directory-alist '(("." . "~/.local/state/emacs/backups"))) (use-package savehist :demand :config (savehist-mode +1)) (use-package dired :custom (dired-auto-revert-buffer t) (dired-dwim-target t)) (use-package recentf :config (run-at-time nil (* 5 60) 'recentf-save-list) (recentf-mode +1) :custom (recentf-max-saved-items 2048)) (use-package auth-source :custom (auth-sources '("secrets:Login"))) (use-package auth-source-pass :requires auth-source :config (auth-source-pass-enable)) ;; Make `describe-*' screens more helpful (use-package helpful :defines helpful-mode-map :bind ((" " . helpful-command) (" " . helpful-callable) (" " . helpful-key) (" " . helpful-symbol) (" " . helpful-variable) ("C-h F" . helpful-function) :map helpful-mode-map (" " . helpful-update))) ;; Bind extra `describe-*' commands (keymap-global-set "C-h K" #'describe-keymap) ;; turn on spell checking, if available. (use-package ispell :custom (ispell-dictionary "en_GB") (ispell-personal-dictionary (locate-user-emacs-file "dictionary"))) (use-package flyspell :hook ((text-mode . flyspell-mode) (prog-mode . flyspell-prog-mode)) :init (require 'ispell) (require 'org) ; Fails without org-mode-map for some reason... :custom (flyspell-mode-line-string nil) (flyspell-use-meta-tab nil) :config (require 'flyspell-correct) (require 'consult-flyspell)) (use-package flyspell-correct :after flyspell :bind ( :map flyspell-mode-map ("C-;" . flyspell-correct-wrapper))) (use-package consult-flyspell :after (consult flyspell) :bind ( :map flyspell-mode-map ("C-c s ;" . consult-flyspell)) :custom (consult-flyspell-always-check-buffer t)) (use-package ibuffer :defines ibuffer-filter-groups :bind (("C-c b" . ibuffer))) (use-package ibuffer-project :after (ibuffer project) :functions ibuffer-project-generate-filter-groups :hook ((ibuffer . (lambda () (setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups)))))) (use-package ace-window :bind ((" " . ace-window)) :custom (aw-scope 'frame) (aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))) (use-package link-hint :bind (("C-c l o" . link-hint-open-link) ("C-c l c" . link-hint-copy-link) ("C-c l C-o" . link-hint-open-all-link) ("C-c l C-c" . link-hint-copy-all-link))) (use-package avy :bind ((" " . avy-goto-char))) (use-package comint :bind ( :map comint-mode-map (" " . consult-history))) (use-package shell :bind (("C-c t s" . shell))) (use-package eshell :bind (("C-c t e" . eshell)) :config (require 'esh-mode)) (use-package esh-mode :defines eshell-mode-map :bind ( :map eshell-mode-map (" " . consult-history))) (use-package calc :bind (("" . calc))) (use-package xref :custom (xref-show-definitions-function 'xref-show-definitions-completing-read)) (use-package calendar :bind (("C-c >" . calendar)) :custom (calendar-date-style 'iso) (calendar-mark-holidays-flag t) (calendar-mark-diary-entries-flag nil) (calendar-view-holidays-initially-flag nil) (calendar-view-diary-initially-flag nil) :config (add-to-list 'display-buffer-alist '("\\*Calendar\\*" (display-buffer-in-side-window) (side . bottom) (slot . 0) (window-height . 0.2) (window-parameters . ((no-delete-other-windows . t)))))) (use-package appt :custom (appt-display-diary nil) (appt-display-format 'echo) (appt-display-interval 5) (appt-message-warning-time 15) :init (appt-activate +1)) (add-hook 'prog-mode-hook #'(lambda () (display-line-numbers-mode +1))) (use-package which-key :functions which-key-mode :config (which-key-mode +1)) (use-package elec-pair :config (electric-pair-mode +1)) (use-package paren :config (show-paren-mode +1)) ;; add visual pulse when changing focus, like beacon but built-in ;; from from https://karthinks.com/software/batteries-included-with-emacs/ (defun pulse-line (&rest _) "Pulse the current line." (pulse-momentary-highlight-one-line (point))) (use-package base16-theme :demand :defines (base16-one-light-theme-colors my/load-theme-and-configure) :hook (server-after-make-frame . my/load-theme-and-configure) :custom (base16-theme-distinct-fringe-background nil) (base16-theme-highlight-mode-line 'contrast) :init (defun my/load-theme-and-configure () "Load theme and configure some faces." (load-theme 'base16-one-light t) ;; Change outline headers to follow rainbow order (require 'outline) (dolist (pairing '((outline-1 . :base08) (outline-2 . :base09) (outline-3 . :base0A) (outline-4 . :base0B) (outline-5 . :base0C) (outline-6 . :base0D) (outline-7 . :base0E) (outline-8 . :base0F))) (set-face-attribute (car pairing) nil :foreground (plist-get base16-one-light-theme-colors (cdr pairing))))) :config (if (display-graphic-p) (my/load-theme-and-configure))) (use-package nerd-icons :functions (nerd-icons-octicon)) (use-package nerd-icons-dired :diminish :requires nerd-icons :hook (dired-mode)) (use-package nerd-icons-ibuffer :diminish :requires nerd-icons :hook (ibuffer-mode)) (use-package nerd-icons-completion :diminish :functions nerd-icons-completion-mode :requires nerd-icons :hook (after-init . (lambda () (nerd-icons-completion-mode +1)))) (use-package ligature :functions (ligature-set-ligatures global-ligature-mode) :config (ligature-set-ligatures '(text-mode prog-mode org-mode) '("-<<" "-<" "-<-" "<--" "<---" "<<-" "<-" "->" "->>" "-->" "--->" "->-" ">-" ">>-" "=<<" "=<" "=<=" "<==" "<===" "<<=" "<=" "=>" "=>>" "==>" "===>" "=>=" ">=" ">>=" "<->" "<-->" "<--->" "<---->" "<=>" "<==>" "<===>" "<====>" "::" ":::" "__" "<~~" "" "/>" "~~>" "==" "!=" "/=" "~=" "<>" "===" "!==" "!===" "=/=" "=!=" "<:" ":=" "*=" "*+" "<*" "<*>" "*>" "<|" "<|>" "|>" "<." "<.>" ".>" "+*" "=*" "=:" ":>" "(*" "*)" "/*" "*/" "[|" "|]" "{|" "|}" "++" "+++" "\\/" "/\\" "|-" "-|" "