From 83290b46f7c67938d3f7563b552b738fdfe5ce5c Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Mon, 29 Jun 2026 16:17:26 +0100 Subject: [PATCH] emacs config --- flake.lock | 302 +++++------------------ flake.nix | 19 +- home/c/default.nix | 1 - hosts/artemis/configuration.nix | 1 - modules/aspects/emacs/default.nix | 95 ++++++++ modules/aspects/emacs/early-init.el | 11 + modules/aspects/emacs/init.org | 366 ++++++++++++++++++++++++++++ modules/profiles/graphical.nix | 7 +- packages/default.nix | 2 - 9 files changed, 538 insertions(+), 266 deletions(-) create mode 100644 modules/aspects/emacs/default.nix create mode 100644 modules/aspects/emacs/early-init.el create mode 100644 modules/aspects/emacs/init.org diff --git a/flake.lock b/flake.lock index 05bb0dc..c8c36d5 100644 --- a/flake.lock +++ b/flake.lock @@ -99,11 +99,11 @@ ] }, "locked": { - "lastModified": 1775866625, - "narHash": "sha256-NfzRZ5DZo8Mwb31ocimy3IMhr3kmYGQ3/ImfnEQkQLw=", + "lastModified": 1782492933, + "narHash": "sha256-v/BH1zfHaCFqP+4Ev9PWiGy15YrpmI9wzjxRtiFhgvA=", "owner": "9001", "repo": "copyparty", - "rev": "a5d859d2b18f53ccf236bc6229856f79139d531c", + "rev": "4c8203016f089b38281ed922a78255146f099e7b", "type": "github" }, "original": { @@ -128,26 +128,6 @@ "type": "github" } }, - "disko": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1773889306, - "narHash": "sha256-PAqwnsBSI9SVC2QugvQ3xeYCB0otOwCacB1ueQj2tgw=", - "owner": "nix-community", - "repo": "disko", - "rev": "5ad85c82cc52264f4beddc934ba57f3789f28347", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "disko", - "type": "github" - } - }, "firefox-addons": { "inputs": { "nixpkgs": [ @@ -156,11 +136,11 @@ }, "locked": { "dir": "pkgs/firefox-addons", - "lastModified": 1776139376, - "narHash": "sha256-rBykvCL5GRT6VmiY39XnxAR10cohBsLeAENP0+3JM/0=", + "lastModified": 1782619356, + "narHash": "sha256-sde3f0uM5mEUwl6Bxom69P+9KOdpJ9YnSj0umSB2qdQ=", "owner": "rycee", "repo": "nur-expressions", - "rev": "ccfaa2303117e22752bda4e1a1bb07d17f38ea2d", + "rev": "9ad2019bb522c7eeecd9e3e2d18dd681f697f4d0", "type": "gitlab" }, "original": { @@ -202,22 +182,6 @@ } }, "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1688025799, - "narHash": "sha256-ktpB4dRtnksm9F5WawoIkEneh1nrEvuxb5lJFt1iOyw=", - "owner": "nix-community", - "repo": "flake-compat", - "rev": "8bf105319d44f6b9f0d764efa4fdef9f1cc9ba1c", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_3": { "flake": false, "locked": { "lastModified": 1751685974, @@ -233,7 +197,7 @@ "url": "https://git.lix.systems/lix-project/flake-compat.git" } }, - "flake-compat_4": { + "flake-compat_3": { "flake": false, "locked": { "lastModified": 1747046372, @@ -256,11 +220,11 @@ ] }, "locked": { - "lastModified": 1775087534, - "narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=", + "lastModified": 1778716662, + "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b", + "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", "type": "github" }, "original": { @@ -270,24 +234,6 @@ } }, "flake-parts_2": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1698882062, - "narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "8c9fa2545007b49a5db5f650ae91f227672c3877", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "nvf", @@ -309,7 +255,7 @@ "type": "github" } }, - "flake-parts_4": { + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "stylix", @@ -330,21 +276,6 @@ "type": "github" } }, - "flake-root": { - "locked": { - "lastModified": 1692742795, - "narHash": "sha256-f+Y0YhVCIJ06LemO+3Xx00lIcqQxSKJHXT/yk1RTKxw=", - "owner": "srid", - "repo": "flake-root", - "rev": "d9a70d9c7a5fd7f3258ccf48da9335e9b47c3937", - "type": "github" - }, - "original": { - "owner": "srid", - "repo": "flake-root", - "type": "github" - } - }, "flake-utils": { "locked": { "lastModified": 1678901627, @@ -396,7 +327,7 @@ }, "git-hooks": { "inputs": { - "flake-compat": "flake-compat_4", + "flake-compat": "flake-compat_3", "gitignore": "gitignore_2", "nixpkgs": [ "scenics", @@ -507,11 +438,11 @@ ] }, "locked": { - "lastModified": 1775425411, - "narHash": "sha256-KY6HsebJHEe5nHOWP7ur09mb0drGxYSzE3rQxy62rJo=", + "lastModified": 1779506708, + "narHash": "sha256-QOD/CNm196nCJRheux/URi4/HE66fthdOMqCJoPP1Y0=", "owner": "nix-community", "repo": "home-manager", - "rev": "0d02ec1d0a05f88ef9e74b516842900c41f0f2fe", + "rev": "3ee51fbdac8c8bdfe1e7e1fcaba6520a563f394f", "type": "github" }, "original": { @@ -523,11 +454,11 @@ }, "import-tree": { "locked": { - "lastModified": 1773693634, - "narHash": "sha256-BtZ2dtkBdSUnFPPFc+n0kcMbgaTxzFNPv2iaO326Ffg=", + "lastModified": 1778781969, + "narHash": "sha256-Jjuz5CmSkur8KvLDoGa+vylEp+RkQtv4mt/qcMznpH0=", "owner": "vic", "repo": "import-tree", - "rev": "c41e7d58045f9057880b0d85e1152d6a4430dbf1", + "rev": "d321337efd0f23a9eb14a42adb7b2c29313ab274", "type": "github" }, "original": { @@ -607,19 +538,23 @@ "type": "github" } }, - "nix-visualize": { - "flake": false, + "nix-wrapper-modules": { + "inputs": { + "nixpkgs": [ + "unstable" + ] + }, "locked": { - "lastModified": 1687577587, - "narHash": "sha256-Z1r8XHszoUnQinl63yXvQG6Czp5HnYNG37AY+EEiT4w=", - "owner": "craigmbooth", - "repo": "nix-visualize", - "rev": "cafaba50cd63ba9c759c56af71fd0d22fd60a548", + "lastModified": 1782135443, + "narHash": "sha256-vAmbArdCyjqpVW+37aCy/PMBOLIqukUXLQuEKLwUhA4=", + "owner": "BirdeeHub", + "repo": "nix-wrapper-modules", + "rev": "6e7f66fa2cdf4d63162580b438f7fcf87c28a46f", "type": "github" }, "original": { - "owner": "craigmbooth", - "repo": "nix-visualize", + "owner": "BirdeeHub", + "repo": "nix-wrapper-modules", "type": "github" } }, @@ -645,11 +580,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1776067740, - "narHash": "sha256-B35lpsqnSZwn1Lmz06BpwF7atPgFmUgw1l8KAV3zpVQ=", + "lastModified": 1782498288, + "narHash": "sha256-8/X3yyTXiE82b38n32ItbOqfWOVBl+gKa8fILyZfR4Q=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7e495b747b51f95ae15e74377c5ce1fe69c1765f", + "rev": "3cac626ec5e3703e835f227687e88aa9e2f25701", "type": "github" }, "original": { @@ -659,24 +594,6 @@ "type": "github" } }, - "nixpkgs-lib": { - "locked": { - "dir": "lib", - "lastModified": 1698611440, - "narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735", - "type": "github" - }, - "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1737469691, @@ -694,22 +611,6 @@ } }, "nixpkgs_3": { - "locked": { - "lastModified": 1711163522, - "narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "44d0940ea560dee511026a53f0e2e2cde489b4d4", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_4": { "locked": { "lastModified": 1774386573, "narHash": "sha256-4hAV26quOxdC6iyG7kYaZcM3VOskcPUrdCQd/nx8obc=", @@ -744,36 +645,6 @@ "type": "github" } }, - "nsbm": { - "inputs": { - "flake-parts": [ - "flake-parts" - ], - "nixpkgs": [ - "unstable" - ], - "sbomnix": "sbomnix", - "systems": [ - "systems" - ], - "treefmt-nix": [ - "treefmt-nix" - ] - }, - "locked": { - "lastModified": 1725996481, - "narHash": "sha256-dDobRr906wky/lH4hKkKAEnxmrnUzOYL0IuuCPv7t6Y=", - "owner": "callumio", - "repo": "nsbm", - "rev": "6146544f3ca96c1d8d27711ee1278d1973031df8", - "type": "github" - }, - "original": { - "owner": "callumio", - "repo": "nsbm", - "type": "github" - } - }, "nur": { "inputs": { "flake-parts": [ @@ -807,11 +678,11 @@ "nvf": "nvf_2" }, "locked": { - "lastModified": 1776156947, - "narHash": "sha256-oE9GmZmFLdtbIA7vs+wgJfcKA/UAOL/H3pWY0hcSSbI=", + "lastModified": 1776183398, + "narHash": "sha256-LcvDdDvhNspLeO5hzywpo+g8O+hoMPpy/Tqtk9azELM=", "owner": "callumio", "repo": "nvf", - "rev": "a011f9fc050954789d9d501126204cdbd2d55b14", + "rev": "f39b69918059fecf09932fefacef8e3cd33e232d", "type": "github" }, "original": { @@ -822,11 +693,11 @@ }, "nvf_2": { "inputs": { - "flake-compat": "flake-compat_3", - "flake-parts": "flake-parts_3", + "flake-compat": "flake-compat_2", + "flake-parts": "flake-parts_2", "mnw": "mnw", "ndg": "ndg", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_3", "systems": "systems_2" }, "locked": { @@ -854,11 +725,11 @@ ] }, "locked": { - "lastModified": 1775585728, - "narHash": "sha256-8Psjt+TWvE4thRKktJsXfR6PA/fWWsZ04DVaY6PUhr4=", + "lastModified": 1781733627, + "narHash": "sha256-U3yTuGBnmXvXoQI3qkpfEDsn9RovQPAjN7ndRco+3u0=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "580633fa3fe5fc0379905986543fd7495481913d", + "rev": "3bbec39bc90eadfa031e6f3b77272f3f60803e39", "type": "github" }, "original": { @@ -872,23 +743,22 @@ "agenix": "agenix", "copyparty": "copyparty", "devour-flake": "devour-flake", - "disko": "disko", "firefox-addons": "firefox-addons", "flake-compat": "flake-compat", "flake-parts": "flake-parts", "home-manager": "home-manager_2", "import-tree": "import-tree", "nish": "nish", + "nix-wrapper-modules": "nix-wrapper-modules", "nixinate": "nixinate", "nixpkgs": "nixpkgs", "nocodb": "nocodb", - "nsbm": "nsbm", "nvf": "nvf", "pre-commit-hooks": "pre-commit-hooks", "scenics": "scenics", "stylix": "stylix", "systems": "systems_5", - "treefmt-nix": "treefmt-nix_2", + "treefmt-nix": "treefmt-nix", "unstable": "unstable" } }, @@ -913,30 +783,6 @@ "type": "github" } }, - "sbomnix": { - "inputs": { - "flake-compat": "flake-compat_2", - "flake-parts": "flake-parts_2", - "flake-root": "flake-root", - "nix-visualize": "nix-visualize", - "nixpkgs": "nixpkgs_3", - "treefmt-nix": "treefmt-nix", - "vulnix": "vulnix" - }, - "locked": { - "lastModified": 1724929558, - "narHash": "sha256-3CkgwrPws+7Z+mEJbq4f8SNo2b4hrta+vdCCGoNrpiU=", - "owner": "tiiuae", - "repo": "sbomnix", - "rev": "444ba45f30dad718e51b7043418cff5ef83583ea", - "type": "github" - }, - "original": { - "owner": "tiiuae", - "repo": "sbomnix", - "type": "github" - } - }, "scenics": { "inputs": { "flake-utils": "flake-utils_2", @@ -966,7 +812,7 @@ "base16-helix": "base16-helix", "base16-vim": "base16-vim", "firefox-gnome-theme": "firefox-gnome-theme", - "flake-parts": "flake-parts_4", + "flake-parts": "flake-parts_3", "gnome-shell": "gnome-shell", "nixpkgs": [ "nixpkgs" @@ -980,11 +826,11 @@ "tinted-zed": "tinted-zed" }, "locked": { - "lastModified": 1775935110, - "narHash": "sha256-twTHKUFXjNNsaAvX0KoaIClt+923jXDRbfCd9PC/f0o=", + "lastModified": 1780418491, + "narHash": "sha256-+eo3U9WHpCkaT/FBGf98kdQprKMUREdY/vmvkej5EiI=", "owner": "danth", "repo": "stylix", - "rev": "14f248ad1a7668e7858c6d9163608c208b7daf02", + "rev": "16689b1d3280604a16d29e249f6b5a1a688e3905", "type": "github" }, "original": { @@ -1153,37 +999,15 @@ "treefmt-nix": { "inputs": { "nixpkgs": [ - "nsbm", - "sbomnix", "nixpkgs" ] }, "locked": { - "lastModified": 1699786194, - "narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=", + "lastModified": 1780220602, + "narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } - }, - "treefmt-nix_2": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1775636079, - "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba", + "rev": "db947814a175b7ca6ded66e21383d938df01c227", "type": "github" }, "original": { @@ -1194,11 +1018,11 @@ }, "unstable": { "locked": { - "lastModified": 1775710090, - "narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=", + "lastModified": 1782467914, + "narHash": "sha256-pGvFkM8N0xEkIIXDe5YYfbEAvHrk4IxBrjB/x8OomhE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4c1018dae018162ec878d42fec712642d214fdfa", + "rev": "e73de5be04e0eff4190a1432b946d469c794e7b4", "type": "github" }, "original": { @@ -1207,22 +1031,6 @@ "repo": "nixpkgs", "type": "github" } - }, - "vulnix": { - "flake": false, - "locked": { - "lastModified": 1676379453, - "narHash": "sha256-KXvmnaMjv//zd4aSwu4qmbon1Iyzdod6CPms7LIxeVU=", - "owner": "henrirosten", - "repo": "vulnix", - "rev": "ad28b2924027a44a9b81493a0f9de1b0e8641005", - "type": "github" - }, - "original": { - "owner": "henrirosten", - "repo": "vulnix", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 96075f9..e69d7ae 100644 --- a/flake.nix +++ b/flake.nix @@ -113,11 +113,6 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - disko = { - url = "github:nix-community/disko"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - firefox-addons = { url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; inputs.nixpkgs.follows = "nixpkgs"; @@ -152,15 +147,6 @@ }; }; - nsbm = { - url = "github:callumio/nsbm"; - inputs = { - nixpkgs.follows = "unstable"; - treefmt-nix.follows = "treefmt-nix"; - flake-parts.follows = "flake-parts"; - systems.follows = "systems"; - }; - }; copyparty = { url = "github:9001/copyparty"; inputs.nixpkgs.follows = "unstable"; @@ -172,5 +158,10 @@ }; import-tree.url = "github:vic/import-tree"; + + nix-wrapper-modules = { + url = "github:BirdeeHub/nix-wrapper-modules"; + inputs.nixpkgs.follows = "unstable"; + }; }; } diff --git a/home/c/default.nix b/home/c/default.nix index 531e0f4..93ef6d1 100644 --- a/home/c/default.nix +++ b/home/c/default.nix @@ -28,7 +28,6 @@ adwaita-icon-theme networkmanagerapplet libsecret - bitwarden-desktop #betterbird wl-clipboard discord diff --git a/hosts/artemis/configuration.nix b/hosts/artemis/configuration.nix index 147449a..a428563 100644 --- a/hosts/artemis/configuration.nix +++ b/hosts/artemis/configuration.nix @@ -43,7 +43,6 @@ pkg-config sbctl nish - nsbm ]; environment = { diff --git a/modules/aspects/emacs/default.nix b/modules/aspects/emacs/default.nix new file mode 100644 index 0000000..1eb1a15 --- /dev/null +++ b/modules/aspects/emacs/default.nix @@ -0,0 +1,95 @@ +{ inputs, ... }: +{ + perSystem = + { inputs', ... }: + let + # pkgs' = pkgs.unstable; + pkgs' = inputs'.unstable.legacyPackages; + tangledConfig = pkgs'.runCommand "init.el" { buildInputs = [ pkgs'.emacs-nox ]; } '' + emacs --batch \ + --eval "(require 'ob-tangle)" \ + --eval "(org-babel-tangle-file \"${./init.org}\" \"$out\" \"emacs-lisp\")" + ''; + in + { + packages.emacs-c = inputs.nix-wrapper-modules.wrappers.emacs.wrap { + pkgs = pkgs'; + package = pkgs'.emacs-pgtk; + + emacsPackages = + epkgs: with epkgs; [ + evil + evil-collection + evil-surround + evil-commentary + activities + general + which-key + vertico + orderless + corfu + magit + consult + marginalia + nerd-icons-completion + dirvish + eglot + consult-eglot + eldoc-box + cape + + indent-bars + rainbow-delimiters + + rust-mode + go-mode + nix-mode + markdown-mode + + doom-themes + flyover + + diff-hl + mood-line + + org-modern + envrc + + eglot-booster + + ghostel # FIX: wait for https://github.com/melpa/melpa/pull/9949 AND https://github.com/dakra/ghostel/issues/76 + + (treesit-grammars.with-grammars ( + g: with g; [ + tree-sitter-rust + tree-sitter-yaml + tree-sitter-dockerfile + ] + )) + ]; + + extraPackages = with pkgs'; [ + fd + ripgrep + nixfmt + rust-analyzer + clang-tools + nil + pyright + gopls + emacs-lsp-booster + ]; + + earlyConfigFile = builtins.readFile ./early-init.el; + configFile = builtins.readFile tangledConfig; + userDirectory = "~/.emacs.d"; + }; + }; + + flake.homeManagerModules.emacs = + { pkgs, ... }: + { + home.packages = [ pkgs.emacs-c ]; + # TODO: service for emacs daemon + }; +} diff --git a/modules/aspects/emacs/early-init.el b/modules/aspects/emacs/early-init.el new file mode 100644 index 0000000..28ccaf5 --- /dev/null +++ b/modules/aspects/emacs/early-init.el @@ -0,0 +1,11 @@ +;; Defer GC during startup +(setq gc-cons-threshold most-positive-fixnum) +(add-hook 'emacs-startup-hook + (lambda () (setq gc-cons-threshold (* 16 1024 1024)))) + +;; Disable before frame init +(setq default-frame-alist + '((tool-bar-lines . 0) + (menu-bar-lines . 0) + (vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil))) diff --git a/modules/aspects/emacs/init.org b/modules/aspects/emacs/init.org new file mode 100644 index 0000000..1a08106 --- /dev/null +++ b/modules/aspects/emacs/init.org @@ -0,0 +1,366 @@ +#+TITLE: C's Emacs Config +#+PROPERTY: header-args:emacs-lisp :lexical t + +* Core +#+begin_src emacs-lisp +(setq inhibit-startup-message t + ring-bell-function 'ignore + make-backup-files nil + auto-save-default nil + display-line-numbers-type 'relative + sentence-end-double-space nil + require-final-newline t + truncate-lines t + use-short-answers t + jit-lock-defer-time 0 + fast-but-imprecise-scrolling nil + jit-lock-stealth-time 1 + jit-lock-stealth-nice 0.1 + scroll-margin 8 + scroll-conservatively 101) + +(setq-default tab-width 2 + indent-tabs-mode nil) + +(xterm-mouse-mode 1) +(global-display-line-numbers-mode) +(electric-pair-mode) +(use-package envrc + :hook (after-init . envrc-global-mode)) +#+end_src + +* Org +#+begin_src emacs-lisp +(use-package org + :custom + (org-src-fontify-natively t) + (org-src-tab-acts-natively t) + (org-edit-src-content-indentation 0) + (org-src-preserve-indentation t) + :hook (org-mode . (lambda () + (display-line-numbers-mode -1) + (variable-pitch-mode 1))) + :config + (custom-theme-set-faces 'user + '(org-block ((t (:inherit fixed-pitch)))) + '(org-code ((t (:inherit fixed-pitch)))) + '(org-table ((t (:inherit fixed-pitch)))) + '(org-verbatim ((t (:inherit fixed-pitch)))))) + +(use-package org-modern + :config (global-org-modern-mode)) +#+end_src + +* Evil +#+begin_src emacs-lisp +(use-package evil + :init + (setq evil-want-integration t + evil-want-keybinding nil + evil-want-C-u-scroll t + evil-want-C-i-jump t + evil-undo-system 'undo-redo + evil-vsplit-window-right t + evil-split-window-below t) + :config (evil-mode 1)) + +(use-package evil-collection + :after evil + :config (evil-collection-init)) + +(use-package evil-surround + :after evil + :config (global-evil-surround-mode 1)) + +(use-package evil-commentary + :after evil + :config (evil-commentary-mode)) +#+end_src + +* Completion +#+begin_src emacs-lisp +(use-package vertico + :config (vertico-mode)) + +(use-package orderless + :custom + (completion-styles '(orderless basic)) + (completion-category-overrides '((file (styles basic partial-completion)))) + (orderless-component-separator "[ /]") + (orderless-matching-styles + '(orderless-literal + orderless-regexp + orderless-initialism + orderless-flex))) + +(use-package marginalia + :config (marginalia-mode)) + +(use-package consult + :custom + (consult-project-function #'consult--default-project-function) + (consult-narrow-key "<")) + +(use-package nerd-icons-completion + :after marginalia + :config (nerd-icons-completion-mode)) + +(use-package corfu + :custom + (corfu-auto t) + (corfu-cycle t) + :config (global-corfu-mode)) + +(use-package cape + :init + (add-to-list 'completion-at-point-functions #'cape-file) + (add-to-list 'completion-at-point-functions #'cape-dabbrev)) +#+end_src + +* UI +#+begin_src emacs-lisp +(use-package which-key + :config (which-key-mode)) + +(use-package doom-themes + :config (load-theme 'doom-one t)) + +(use-package mood-line + :config (mood-line-mode)) + +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + +(use-package indent-bars + :hook (prog-mode . indent-bars-mode)) + +(use-package tab-bar + :custom + (tab-bar-mode) + (tab-bar-show 1) + (tab-bar-new-tab-choice "*scratch") + (tab-bar-close-button-show nil) + (tab-bar-new-button-show nil)) + +#+end_src + +* Files +#+begin_src emacs-lisp +(use-package dirvish + :custom + (dirvish-quick-access-entries + '(("h" "~/" "Home") + ("d" "~/Downloads" "Downloads"))) + :config (dirvish-override-dired-mode)) +(use-package project + :custom + (project-switch-commands + '((project-find-file "Find file" ?f) + (consult-ripgrep "Search" ?g) + (project-dired "Dired" ?d) + (magit-project-status "Magit" ?m) + (project-eshell "Eshell" ?e)))) +#+end_src + +* Activities +#+begin_src emacs-lisp +(use-package activities + :init (activities-mode) + :config (activities-tabs-mode) + :custom + (activities-bookmark-store t) + (activities-kill-buffers t) + (activities-anti-save-predicates + '(minibufferp + (lambda () (string-match-p "^\\*scratch\\*" (buffer-name))) + (lambda () (string-match-p "^\\*Messages\\*" (buffer-name))) + (lambda () (string-match-p "^\\*Help\\*" (buffer-name))) + (lambda () (string-match-p "^ " (buffer-name)))))) + +(defun my/project-switch-activity () + "Switch to a project, resuming its activity or creating one." + (interactive) + (let* ((project (project-prompt-project-dir)) + (path (expand-file-name project)) + (name (file-name-nondirectory (directory-file-name path))) + (existing (alist-get name activities-activities nil nil #'equal))) + (if existing + (activities-resume existing :resetp nil) + (let ((default-directory path)) + (activities-new name) + (project-switch-project path))))) +#+end_src + +* LSP +#+begin_src emacs-lisp +(use-package rust-mode + :init + (setq rust-mode-treesitter-derive t) + :custom + (rust-format-on-save nil) + (rust-format-show-buffer nil) + (rust-format-goto-problem nil)) +(use-package eglot + :custom + (eglot-autoshutdown t) + (eglot-confirm-server-edits nil) + :hook + ((rust-mode rust-ts-mode + c-mode c-ts-mode + c++-mode c++-ts-mode + python-mode python-ts-mode + go-mode go-ts-mode + nix-mode nix-ts-mode) . eglot-ensure) + (eglot-managed-mode . eglot-inlay-hints-mode) + (eglot-managed-mode . (lambda () + (add-hook 'before-save-hook #'eglot-format-buffer nil t)))) + +(use-package eglot-booster + :after eglot + :config (eglot-booster-mode)) + +(use-package eldoc-box + :after eglot + :custom + (eldoc-echo-area-prefer-doc-buffer 'maybe) + (eldoc-echo-area-use-multiline-p nil) + (eldoc-message-function #'ignore)) + +(eldoc-mode -1) +(add-hook 'prog-mode-hook + (lambda () + (add-hook 'before-save-hook #'delete-trailing-whitespace nil t))) + +(add-to-list 'auto-mode-alist '("\\.ya?ml\\'" . yaml-ts-mode)) +(add-to-list 'auto-mode-alist '("/\\(?:Docker\\|Container\\)file\\(?:\\..*\\)?\\'" . dockerfile-ts-mode)) +(add-to-list 'auto-mode-alist '("\\.dockerfile\\'" . dockerfile-ts-mode)) +(add-to-list 'auto-mode-alist '("\\.containerfile\\'" . dockerfile-ts-mode)) +#+end_src + +* Diagnostics +#+begin_src emacs-lisp +(use-package flyover + :hook (flymake-mode . flyover-mode) + :custom + (flyover-levels '(error warning info)) + (flyover-use-theme-colors t) + (flyover-background-lightness 45) + (flyover-checkers '(flymake)) + (flyover-wrap-messages t) + (flyover-max-line-length 80) + (flyover-info-icon "") + (flyover-warning-icon "") + (flyover-error-icon "") + (flyover-virtual-line-type 'straight-arrow) + (flyover-show-virtual-line t) + (flyover-hide-checker-name t)) +#+end_src + +* Git +#+begin_src emacs-lisp +(use-package magit) + +(use-package diff-hl + :config + (global-diff-hl-mode) + (diff-hl-flydiff-mode) + :hook + (magit-pre-refresh . diff-hl-magit-pre-refresh) + (magit-post-refresh . diff-hl-magit-post-refresh)) +#+end_src + +* Keybinds +#+begin_src emacs-lisp +(use-package general + :config + (general-create-definer leader + :states '(normal visual) + :keymaps 'override + :prefix "SPC") + + (general-define-key + :states 'normal + :keymaps 'override + "gd" 'xref-find-definitions + "gD" 'xref-find-declarations + "gr" 'xref-find-references + "K" (lambda () (interactive) (eldoc nil) (eldoc-box-help-at-point))) + + (leader + "SPC" '(project-find-file :which-key "find file in project") + "." '(find-file :which-key "find file") + ":" '(execute-extended-command :which-key "M-x") + + ;; buffers + "b" '(:ignore t :which-key "buffer") + "bb" '(consult-project-buffer :which-key "project buffers") + "bB" '(consult-buffer :which-key "all buffers") + "bd" '(kill-this-buffer :which-key "kill") + "bn" '(next-buffer :which-key "next") + "bp" '(previous-buffer :which-key "prev") + + ;; files + "f" '(:ignore t :which-key "file") + "ff" '(project-find-file :which-key "find file (project)") + "fF" '(find-file :which-key "find file") + "fr" '(consult-recent-file :which-key "recent") + "fs" '(save-buffer :which-key "save") + "-" '(dirvish-dwim :which-key "dirvish") + + ;; project + "p" '(:ignore t :which-key "project") + "pp" '(my/project-switch-activity :which-key "switch") + "pf" '(project-find-file :which-key "find file") + "pb" '(consult-project-buffer :which-key "buffers") + "pd" '(project-dired :which-key "dired") + "pe" '(project-eshell :which-key "eshell") + "pk" '(project-kill-buffers :which-key "kill buffers") + "pc" '(project-compile :which-key "compile") + + ;; activities + "a" '(:ignore t :which-key "activity") + "aa" '(activities-resume :which-key "resume") + "as" '(activities-suspend :which-key "suspend") + "ak" '(activities-kill :which-key "kill") + "al" '(activities-list :which-key "list") + "ar" '(activities-revert :which-key "revert") + "aS" '(activities-save :which-key "save") + + ;; tabs + "TAB" '(:ignore t :which-key "tab") + "TAB TAB" '(tab-switch :which-key "switch") + "TAB l" '(tab-next :which-key "next") + "TAB h" '(tab-previous :which-key "prev") + "TAB n" '(my/project-switch-activity :which-key "new") + "TAB d" '(activities-suspend :which-key "close") + + ;; search + "s" '(:ignore t :which-key "search") + "ss" '(consult-line :which-key "buffer") + "sp" '(consult-ripgrep :which-key "project") + "si" '(consult-imenu :which-key "symbol") + + ;; git + "g" '(:ignore t :which-key "git") + "gg" '(magit-status :which-key "status") + "gb" '(magit-blame :which-key "blame") + + ;; code (LSP) + "c" '(:ignore t :which-key "code") + "cf" '(eglot-format-buffer :which-key "format") + "cr" '(eglot-rename :which-key "rename") + "ca" '(eglot-code-actions :which-key "actions") + "cd" '(consult-flymake :which-key "diagnostics") + + ;; window + "w" '(:ignore t :which-key "window") + "wv" '(split-window-right :which-key "vsplit") + "ws" '(split-window-below :which-key "hsplit") + "wd" '(delete-window :which-key "close") + "wo" '(delete-other-windows :which-key "only") + + ;; quit + "q" '(:ignore t :which-key "quit") + "qq" '(save-buffers-kill-emacs :which-key "save and quit") + "qQ" '(kill-emacs :which-key "force quit"))) +#+end_src diff --git a/modules/profiles/graphical.nix b/modules/profiles/graphical.nix index f48a104..c6a2120 100644 --- a/modules/profiles/graphical.nix +++ b/modules/profiles/graphical.nix @@ -1,4 +1,8 @@ -{ config, inputs, ... }: +{ + config, + inputs, + ... +}: { flake.nixosModules.profile-graphical = { imports = [ @@ -6,5 +10,6 @@ config.flake.nixosModules.gpg-pinentry-wayland inputs.stylix.nixosModules.stylix ]; + home-manager.sharedModules = [ config.flake.homeManagerModules.emacs ]; }; } diff --git a/packages/default.nix b/packages/default.nix index 29150f1..25c62f8 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -5,13 +5,11 @@ }: { tmux-sessionizer-cl = pkgs.callPackage ./tmux-sessionizer { }; - om = inputs'.omnix.packages.default; nvf = inputs'.nvf.packages.default; agenix = inputs'.agenix.packages.default; vaapiIntel = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; }; devour-flake = pkgs.callPackage inputs.devour-flake { }; nish = inputs'.nish.packages.default; - nsbm = inputs'.nsbm.packages.default; jellyfin-ffmpeg = pkgs.jellyfin-ffmpeg.override { ffmpeg_7-full = pkgs.ffmpeg_7-full.override { withMfx = false;