diff options
| -rw-r--r-- | share/home/emacs/default.nix | 7 | ||||
| -rw-r--r-- | share/home/emacs/early-init.el | 7 | ||||
| -rw-r--r-- | share/home/emacs/emacs.el | 144 |
3 files changed, 82 insertions, 76 deletions
diff --git a/share/home/emacs/default.nix b/share/home/emacs/default.nix index 6c40b78..37ec96b 100644 --- a/share/home/emacs/default.nix +++ b/share/home/emacs/default.nix @@ -5,9 +5,14 @@ let defaultInitFile = true; package = pkgs.emacs-pgtk; alwaysEnsure = true; - alwaysTangle = true; }; in { home.packages = [ my-emacs ]; + + xdg.configFile.emacs-early-init = { + enable = true; + target = "emacs/early-init.el"; + source = ./early-init.el; + }; } diff --git a/share/home/emacs/early-init.el b/share/home/emacs/early-init.el index bbfc354..bc32deb 100644 --- a/share/home/emacs/early-init.el +++ b/share/home/emacs/early-init.el @@ -1,4 +1,11 @@ ;;; early-init.el --- Early Initalization -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + +(push '(menu-bar-mode . 0) default-frame-alist) +(push '(tool-bar-lines . 0) default-frame-alist) +(push '(vertical-scroll-bars) default-frame-alist) + ;; All our packages come from Nix (setq package-enable-at-startup nil package-archives nil) diff --git a/share/home/emacs/emacs.el b/share/home/emacs/emacs.el index 7959f6d..6cf9652 100644 --- a/share/home/emacs/emacs.el +++ b/share/home/emacs/emacs.el @@ -13,38 +13,6 @@ ;;; 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) - "Assumes the package is already installed. -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 @@ -90,57 +58,88 @@ is already installed. This is true in our Nix environment." ;;; Customization ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Customization - General settings ;;; + +(use-package emacs + :init + (setq inhibit-startup-screen t + initial-scratch-message nil + initial-major-mode 'text-mode + ring-bell-function 'ignore + use-file-dialog nil) + + (tool-bar-mode -1) + (scroll-bar-mode -1) + + (setq-default cursor-type 'bar + frame-title-format '("%b") + ;; Use spaces, but configure tab-width for modes that use tabs + indent-tabs-mode nil + tab-width 2) + + (fset 'yes-or-no-p 'y-or-n-p) + (show-paren-mode 1) ; Show closing parens + (global-auto-revert-mode t) ; Auto-update buffer on file change + (setopt create-lockfiles nil) + (electric-pair-mode 1) ; Autopairs + (global-hl-line-mode) + + (defun mb/enable-line-numbers () + "Enable relative line numbers" + (interactive) + (display-line-numbers-mode) + (setq display-line-numbers 'relative)) + + (defun mb/enable-fill-column () + "Enable vertical ruler" + (interactive) + (setq fill-column 80) + (display-fill-column-indicator-mode)) + + (defun display-startup-echo-area-message () + (message "")) + + :hook ((prog-mode . mb/enable-line-numbers) + (prog-mode . mb/enable-fill-column)) + + :bind (("C-z" . undo) + ("C-S-z" . undo-redo) + ("C-x h" . previous-buffer) + ("C-x l" . next-buffer))) + ;;; Customization - Scrolling ;;; ;; TODO: Smooth scroll ;;; Customization - Theme ;;; (use-package doom-themes - :ensure t + :demand :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 ;;; + (load-theme 'doom-laserwave t)) -;; 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 - Modeline ;;; +(use-package doom-modeline + :ensure t + :config (doom-modeline-mode 1)) -;;; Customization - Highlight current line ;;; +(use-package nerd-icons + :custom + (nerd-icons-font-family "FiraCode Nerd Font Mono")) -(use-package hl-line - :hook (on-first-buffer . global-hl-line-mode)) +(use-package nyan-mode + :config (nyan-mode)) ;;; Customization - Evil ;;; ;; Set up vi keybinds (use-package evil - :config - (evil-mode 1)) + :demand + :hook ((prog-mode . evil-local-mode) + (text-mode . evil-local-mode))) ;;; Customization - Direnv support ;;; @@ -151,10 +150,11 @@ is already installed. This is true in our Nix environment." ;;; Customziation - Completion framework ;;; (use-package helm - :init - (helm-mode 1) :config (setq helm-completion-style 'emacs)) +(use-package helm-mode + :config + (helm-mode 1)) (use-package fussy :config @@ -176,12 +176,12 @@ is already installed. This is true in our Nix environment." ;;; Customization - Completions ;;; (use-package company - :init (global-company-mode)) + :hook (prog-mode . company-mode)) ;;; Customization - Syntax checking ;;; (use-package flycheck - :init (global-flycheck-mode)) + :hook (prog-mode . flycheck-mode)) ;;; Customization - Line numbers ;;; @@ -191,18 +191,12 @@ is already installed. This is true in our Nix environment." ;;; Customization - Which key ;;; (use-package which-key - :init (which-key-mode +1)) + :config (which-key-mode +1)) ;;;;;;;;;;;;;;;;;;;;;;;;; ;;; 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 |
