;;; init.el --- Initalization -*- lexical-binding: t; -*- ;;; ;;; Commentary: ;;; Various resources were used to hack together this config: ;;; - https://sanemacs.com/ ;;; - https://rossabaker.com/configs/emacs/ ;;; ;;; Code: ;;;;;;;;;;;;;;;;;;;;;;; ;;; Startup ;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;; Startup - Use package ;;; ;; Most of this config is broken down into [[https://github.com/jwiegley/use-package][~use-package~]] stanzas. All ;; dependencies are managed by [[https://nixos.org/][Nix]]. Any package with a true ~:ensure~ ;; keyword is found by [[https://github.com/nix-community/emacs-overlay#extra-library-functionality][~emacsWithPackagesFromUsePackage~]] to generate ;; the set of Emacs packages to install with Nix. ;; ;; In the brutish non-Nix world, ~:ensure~ triggers Emacs' own package ;; manager with willy nilly downloads. To prevent this, we tell ;; ~use-package~ to assume the package is there and merely look for its ;; autoloads. (defun ross/use-package-ensure-already-installed (name _ensure state &optional _context) "Value for `use-package-ensure-function` that assumes the package is already installed. This is true in our Nix environment." (let ((autoloads-file-name (format "%s-autoloads" name))) (with-demoted-errors "Error loading autoloads: %s" (load autoloads-file-name t t)))) (setq use-package-ensure-function #'ross/use-package-ensure-already-installed) ;; ~use-package~ also by default appends ~"-hook"~ to all its hooks. ;; This impairs ripgreppability. Let's be explicit: (setq use-package-hook-name-suffix nil) ;; use-package doesn't use itself. (Well, I think it could, but this ;; is the recommended approach...) (eval-when-compile (require 'use-package)) ;; some packages complain if I don't have this (use-package bind-key :demand t :bind (:prefix-map rab/files-map :prefix "C-c f") :bind (:prefix-map rab/toggles-map :prefix "C-c t")) ;;; Startup - Benchmarking ;;; (use-package benchmark-init :ensure t :demand t :hook (after-init . benchmark-init/deactivate) :config (benchmark-init/activate)) ;;; Startup - Garbage collection ;;; (use-package gcmh :ensure t :diminish :init (setq gc-cons-threshold (* 80 1024 1024)) :hook (emacs-startup . gcmh-mode)) ;;; Startup - Better cache location ;;; (use-package no-littering :ensure t :init (setq no-littering-etc-directory "~/.cache/emacs/etc/" no-littering-var-directory "~/.cache/emacs/var/") (when (fboundp 'startup-redirect-eln-cache) (startup-redirect-eln-cache (convert-standard-filename (expand-file-name "eln-cache/" no-littering-var-directory))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Customization ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Customization - Scrolling ;;; ;; TODO: Smooth scroll ;;; Customization - Theme ;;; (use-package doom-themes :ensure t :config ;; Global settings (defaults) (setq doom-themes-enable-bold t ; if nil, bold is universally disabled doom-themes-enable-italic t) ; if nil, italics is universally disabled (load-theme 'doom-one t) ;; Enable flashing mode-line on errors (doom-themes-visual-bell-config) ;; Corrects (and improves) org-mode's native fontification. (doom-themes-org-config)) ;;; Customization - General settings ;;; ;; Disable menu-bar, tool-bar, and scroll-bar. (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ;; Useful Defaults (setq-default cursor-type 'bar) ; Line-style cursor similar to other text editors (setq inhibit-startup-screen t) ; Disable startup screen (setq initial-scratch-message "") ; Make *scratch* buffer blank (setq-default frame-title-format '("%b")) ; Make window title the buffer name (setq ring-bell-function 'ignore) ; Disable bell sound (fset 'yes-or-no-p 'y-or-n-p) ; y-or-n-p makes answering questions faster (show-paren-mode 1) ; Show closing parens by default (global-auto-revert-mode t) ; Auto-update buffer if file has changed on disk (setopt create-lockfiles nil) ; Don't create lockfiles (electric-pair-mode 1) ; Autopairs ;;; Customization - Highlight current line ;;; (use-package hl-line :hook (on-first-buffer . global-hl-line-mode)) ;;; Customization - Evil ;;; ;; Set up vi keybinds (use-package evil :config (evil-mode 1)) ;;; Customization - Direnv support ;;; (use-package envrc :ensure t :hook (on-first-file . envrc-global-mode)) ;;; Customziation - Completion framework ;;; (use-package helm :init (helm-mode 1) :config (setq helm-completion-style 'emacs)) (use-package fussy :config (push 'fussy completion-styles) (setq ;; For example, project-find-file uses 'project-files which uses ;; substring completion by default. Set to nil to make sure it's using ;; flx. completion-category-defaults nil completion-category-overrides nil)) ;;; Customization - Project management ;;; (use-package projectile :bind-keymap ("C-c p" . projectile-command-map) :config (projectile-mode +1)) ;;; Customization - Completions ;;; (use-package company :init (global-company-mode)) ;;; Customization - Syntax checking ;;; (use-package flycheck :init (global-flycheck-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Languages ;;; ;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Langauges - Emacs lisp ;;; ;; Preserve indentation in org mode source blocks (dolist (pair '((org-src-preserve-indentation . t) (org-src-tab-acts-natively . t))) (add-to-list 'safe-local-variable-values pair)) ;;; Languages - Nix ;;; (use-package nix-mode :mode "\\.nix\\'") ;;; Languages - Coq ;;; (use-package proof-general :mode ("\\.v\\'" . coq-mode)) ;; ----------------------------------------------------------------------- ;; ;; (use-package display-line-numbers ;; :custom ;; (display-line-numbers-widen t) ;; :hook ;; ((prog-mode conf-mode) . display-line-numbers-mode)) ;;; emacs.el ends here