From 927e41991bfc08a9e3eb03b4f12df31eb50d8e19 Mon Sep 17 00:00:00 2001 From: Joe Frikker Date: Mon, 16 Feb 2026 18:24:50 -0500 Subject: [PATCH] Modularizing emacs config --- home.org | 311 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 204 insertions(+), 107 deletions(-) diff --git a/home.org b/home.org index a787934..cecd612 100644 --- a/home.org +++ b/home.org @@ -645,35 +645,14 @@ Actually, nix *really* requires ~bash~. This is a plugin that allows using zsh f #+END_SRC * Emacs -:PROPERTIES: -:header-args:elisp: :tangle target/emacs.el -:header-args:nix: :noweb no-export :noweb-ref emacs_packages -:END: - Emacs is a huge portion of this configuration, so although it's a home-manager "program", I'm breaking it out into its own top-level section. Many of the sections here have two code blocks: a nix code block listing the emacs packages to include, and an elisp code block to configure them in emacs. -#+BEGIN_SRC nix :tangle target/emacs.nix :noweb-ref - { - programs.emacs = { - enable = true; - extraPackages = epkgs: with epkgs; [ - <> - ]; - extraConfig = builtins.readFile ./emacs.el; - }; - } -#+END_SRC - -We'll put the actual emacs config into a separate file, rather than into a nix string literal. This +We'll put the actual emacs configs into separate files, rather than into nix string literals. This helps with a few places where nix's string interpolation was causing problems. -#+begin_src elisp - ;;; -*- lexical-binding: t -*- -#+end_src - ** Keybindings These keybindings are scattered throughout this file, I'm collecting them all here to make it easier to track them. @@ -697,18 +676,30 @@ to track them. | C-c M-g | | [[id:4F426E77-CE03-4BF8-8D1B-7791C7C02B28][Magit file dispatch]] | | ** Global Settings +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-global.el +:END: These are just some general settings that apply everywhere. First, a few packages: -#+BEGIN_SRC nix :noweb-ref emacs_packages - doom-modeline - ligature - mixed-pitch - ace-window +#+BEGIN_SRC nix :tangle target/emacs-global.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + doom-modeline + ligature + mixed-pitch + ace-window + ]; + extraConfig = builtins.readFile ./emacs-global.el; + }; + } #+END_SRC Turn off some default settings that I don't find useful. #+BEGIN_SRC elisp + ;;; -*- lexical-binding: t -*- (setq inhibit-startup-screen t) (setq initial-scratch-message nil) (menu-bar-mode -1) @@ -892,7 +883,7 @@ move backward / forward through history. "" #'tab-bar-history-forward)) #+END_SRC -** Window Placement +*** Window Placement This section contains rules about where ~display-buffer~ should place windows. I guess I'm currently going for an IDE-style layout, with one main editor window, and auxiliary bottom and right side windows. I place windows in the bottom or on the right mostly depending on how wide I expect their @@ -947,16 +938,27 @@ content to be. window-persistent-parameters)) #+END_SRC ** Editing +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-editing.el +:END: This configuration affects general text editing, across all modes. First, some packages: -#+BEGIN_SRC nix - avy - devil - edit-indirect - embark - god-mode - string-inflection +#+BEGIN_SRC nix :tangle target/emacs-editing.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + avy + devil + edit-indirect + embark + god-mode + string-inflection + ]; + extraConfig = builtins.readFile ./emacs-editing.el; + }; + } #+END_SRC I find Emacs to be almost unusable on a normal keyboard unless there's some way to avoid all the @@ -1072,22 +1074,33 @@ Just "silently" wrap when searching at the bottom of a document. #+END_SRC ** Language Support +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-languages.el +:END: #+BEGIN_SRC nix - consult-eglot - haskell-ts-mode - jenkinsfile-mode - lispy - lua-mode - nix-mode - rust-mode - smartparens - sly - sly-macrostep - sql-indent - tree-sitter - treesit-grammars.with-all-grammars - yaml-pro + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + consult-eglot + haskell-ts-mode + jenkinsfile-mode + lispy + lua-mode + nix-mode + rust-mode + smartparens + sly + sly-macrostep + sql-indent + tree-sitter + treesit-grammars.with-all-grammars + yaml-pro + ]; + extraConfig = builtins.readFile ./emacs-languages.el; + }; + } #+END_SRC I had some weird problems with jsx code where the default M-q would just do a text fill rather than @@ -1296,9 +1309,20 @@ available? It seems to work for now anyway... #+END_SRC ** Envrc +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-envrc.el +:END: -#+BEGIN_SRC nix - envrc +#+BEGIN_SRC nix :tangle target/emacs-envrc.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + envrc + ]; + extraConfig = builtins.readFile ./emacs-envrc.el; + }; + } #+END_SRC #+BEGIN_SRC elisp @@ -1309,13 +1333,24 @@ available? It seems to work for now anyway... #+END_SRC ** Magit +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-magit.el +:END: -#+BEGIN_SRC nix - consult-gh - diff-hl - forge - git-timemachine - magit +#+BEGIN_SRC nix :tangle target/emacs-magit.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + consult-gh + diff-hl + forge + git-timemachine + magit + ]; + extraConfig = builtins.readFile ./emacs-magit.el; + }; + } #+END_SRC #+BEGIN_SRC elisp @@ -1350,15 +1385,26 @@ available? It seems to work for now anyway... #+END_SRC ** Vertico +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-vertico.el +:END: -#+BEGIN_SRC nix - cape - consult - corfu - embark-consult - marginalia - orderless - vertico +#+BEGIN_SRC nix :tangle target/emacs-vertico.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + cape + consult + corfu + embark-consult + marginalia + orderless + vertico + ]; + extraConfig = builtins.readFile ./emacs-vertico.el; + }; + } #+END_SRC #+BEGIN_SRC elisp @@ -1464,14 +1510,25 @@ available? It seems to work for now anyway... #+END_SRC ** Org +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-org.el +:END: -#+BEGIN_SRC nix - org-modern - org-present - org-roam - ox-slack - verb - visual-fill-column +#+BEGIN_SRC nix :tangle target/emacs-org.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + org-modern + org-present + org-roam + ox-slack + verb + visual-fill-column + ]; + extraConfig = builtins.readFile ./emacs-org.el; + }; + } #+END_SRC #+BEGIN_SRC elisp @@ -1602,9 +1659,20 @@ available? It seems to work for now anyway... #+END_SRC ** Terminal +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-terminal.el +:END: -#+BEGIN_SRC nix - eat +#+BEGIN_SRC nix :tangle target/emacs-terminal.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + eat + ]; + extraConfig = builtins.readFile ./emacs-terminal.el; + }; + } #+END_SRC #+BEGIN_SRC elisp @@ -1614,9 +1682,20 @@ available? It seems to work for now anyway... #+END_SRC ** Slack +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-slack.el +:END: #+BEGIN_SRC nix - slack + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + slack + ]; + extraConfig = builtins.readFile ./emacs-slack.el; + } + } #+END_SRC #+BEGIN_SRC elisp @@ -1634,9 +1713,20 @@ available? It seems to work for now anyway... #+END_SRC ** Kubernetes +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-kubernetes.el +:END: -#+BEGIN_SRC nix - kubed +#+BEGIN_SRC nix :tangle target/emacs-kubernetes.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + kubed + ]; + extraConfig = builtins.readFile ./emacs-kubernetes.el; + }; + } #+END_SRC #+BEGIN_SRC elisp @@ -1647,14 +1737,32 @@ available? It seems to work for now anyway... ** Ledger -#+BEGIN_SRC nix - ledger-mode +#+BEGIN_SRC nix :tangle target/emacs-ledger.el + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + ledger-mode + ]; + }; + } #+END_SRC ** Age +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-age.el +:END: -#+BEGIN_SRC nix -age +#+BEGIN_SRC nix :tangle target/emacs-age.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + age + ]; + extraConfig = builtins.readFile ./emacs-age.el; + }; + } #+END_SRC #+BEGIN_SRC elisp @@ -1667,29 +1775,6 @@ age (age-file-enable)) #+END_SRC -** Snippets - -#+BEGIN_SRC nix - yasnippet -#+END_SRC - -#+BEGIN_SRC elisp - (yas-global-mode) -#+END_SRC - -*** Org Mode - -#+BEGIN_SRC snippet :tangle target/snippets/org-mode/src - # name: SRC block - # key: src - # expand-env: ((yas-indent-line 'fixed)) - # -- - - ,#+BEGIN_SRC ${1:elisp} - $0 - ,#+END_SRC -#+END_SRC - * Theme I like Catppuccin Frappe as my theme. Let's use it in as many places as we can. @@ -1780,11 +1865,23 @@ I like Catppuccin Frappe as my theme. Let's use it in as many places as we can. #+END_SRC ** Emacs -#+BEGIN_SRC nix :noweb-ref "emacs_packages" - catppuccin-theme +:PROPERTIES: +:header-args:elisp: :tangle target/emacs-theme.el +:END: + +#+BEGIN_SRC nix :tangle target/emacs-theme.nix + { + programs.emacs = { + enable = true; + extraPackages = epkgs: with epkgs; [ + catppuccin-theme + ]; + extraConfig = builtins.readFile ./emacs-theme.el; + }; + } #+END_SRC -#+BEGIN_SRC elisp :tangle target/emacs.el +#+BEGIN_SRC elisp (use-package catppuccin-theme :custom (catppuccin-flavor 'frappe)