From 55ae93f63342fb7c5a0028c597437d3994816d88 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 23 Oct 2023 17:28:05 +0100 Subject: [PATCH] Big emacs re-write to use crafted-emacs emacs/default.nix now links new init.el and modules directories (mine and crafted-emacs) to ~/.config/emacs/ emacs/default.nix installs emacs29-pgtk with packages as needed in module *-config.el definitions Add tree-sitter with required parsers Remove doom-emacs and places it was set --- .gitignore | 1 + flake.lock | 34 ++++---- flake.nix | 6 +- home/emacs/config/early-init.el | 10 --- home/emacs/default.nix | 82 +++++++++++++------ home/emacs/{config => }/init.el | 34 ++++++-- home/emacs/lsp_servers.nix | 1 + home/emacs/modules/custom-ligatures-config.el | 58 +++++++++++++ home/emacs/tree-sitter.nix | 38 +++++++++ home/hyprland/config.nix | 2 - 10 files changed, 200 insertions(+), 66 deletions(-) delete mode 100644 home/emacs/config/early-init.el rename home/emacs/{config => }/init.el (54%) create mode 100644 home/emacs/modules/custom-ligatures-config.el create mode 100644 home/emacs/tree-sitter.nix diff --git a/.gitignore b/.gitignore index 6ab41ba4..7c02ade1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*~ *.swp .python-version .DS_Store diff --git a/flake.lock b/flake.lock index 58a6393b..70bda20b 100644 --- a/flake.lock +++ b/flake.lock @@ -166,6 +166,22 @@ "type": "github" } }, + "crafted-emacs": { + "flake": false, + "locked": { + "lastModified": 1697837545, + "narHash": "sha256-Sucimd2VjeUZ3GZ7kC1W+ix9t30npaHuZgjdvhHuTCU=", + "owner": "SystemCrafters", + "repo": "crafted-emacs", + "rev": "bc6618a2950e354cc6b1bc24c63f3b2c6d71141b", + "type": "github" + }, + "original": { + "owner": "SystemCrafters", + "repo": "crafted-emacs", + "type": "github" + } + }, "crane": { "inputs": { "flake-compat": "flake-compat_2", @@ -246,22 +262,6 @@ "type": "github" } }, - "doom-emacs": { - "flake": false, - "locked": { - "lastModified": 1696638825, - "narHash": "sha256-vrdwIu6F11OOSaS5SfgT/jx0Kvu7KaigthVGBENKR5k=", - "owner": "doomemacs", - "repo": "doomemacs", - "rev": "986398504d09e585c7d1a8d73a6394024fe6f164", - "type": "github" - }, - "original": { - "owner": "doomemacs", - "repo": "doomemacs", - "type": "github" - } - }, "fenix": { "inputs": { "nixpkgs": "nixpkgs_2", @@ -659,7 +659,7 @@ "root": { "inputs": { "anyrun": "anyrun", - "doom-emacs": "doom-emacs", + "crafted-emacs": "crafted-emacs", "home-manager": "home-manager", "nixpkgs": "nixpkgs", "stylix": "stylix", diff --git a/flake.nix b/flake.nix index 9f2e7ee8..1fa58072 100644 --- a/flake.nix +++ b/flake.nix @@ -21,10 +21,6 @@ }; # Non-flake inputs - doom-emacs = { - url = "github:doomemacs/doomemacs"; - flake = false; - }; crafted-emacs = { url = "github:SystemCrafters/crafted-emacs"; flake = false; @@ -72,7 +68,7 @@ inherit (inputs) anyrun watershot; }; extraSpecialArgs = specialArgs // { - inherit (inputs) doom-emacs crafted-emacs tokyonight-folke; + inherit (inputs) crafted-emacs tokyonight-folke; }; in nixpkgs.lib.nixosSystem { inherit system specialArgs; diff --git a/home/emacs/config/early-init.el b/home/emacs/config/early-init.el deleted file mode 100644 index 61a4a1c9..00000000 --- a/home/emacs/config/early-init.el +++ /dev/null @@ -1,10 +0,0 @@ -;;; early-init.el --- Emacs early initialization for Crafted Emacs (optional) -*- lexical-binding: t; -*- -;;; Commentary: -;; -;;; Code: - -;; Configures `package.el' -(load "~/Projects/crafted-emacs/modules/crafted-early-init-config") -(provide 'early-init) - -;;; early-init.el ends here diff --git a/home/emacs/default.nix b/home/emacs/default.nix index dccce53a..89a58566 100644 --- a/home/emacs/default.nix +++ b/home/emacs/default.nix @@ -1,16 +1,13 @@ -{ config, pkgs, doom-emacs, ... }: -let - sessionVariables = rec { - DOOMLOCALDIR = "${config.home.homeDirectory}/.local/share/doomemacs"; - DOOMPROFILELOADFILE = "${DOOMLOCALDIR}/load.el"; - }; -in { - imports = [ ./formatters.nix ./lsp_servers.nix ]; +{ config, pkgs, crafted-emacs, ... }: + +{ + imports = [ ./formatters.nix ./lsp_servers.nix ./tree-sitter.nix ]; + stylix.targets.emacs.enable = false; xdg.configFile = { - emacs.source = doom-emacs; - doom.source = ./doom; + "emacs/init.el".source = ./init.el; + "emacs/modules".source = ./modules; + "emacs/crafted-emacs".source = crafted-emacs; }; - systemd.user = { inherit sessionVariables; }; services.git-sync = { enable = true; repositories.org = { @@ -20,18 +17,55 @@ in { }; programs.emacs = { enable = true; - package = pkgs.emacs29-pgtk; - }; - stylix.targets.emacs.enable = false; - home = { - inherit sessionVariables; - sessionPath = [ "${config.xdg.configHome}/emacs/bin" ]; - packages = with pkgs; [ - # Additional/Compiled Emacs packages - emacsPackages.mu4e - emacsPackages.vterm - emacsPackages.pdf-tools + package = with pkgs; + ((emacsPackagesFor emacs29-pgtk).emacsWithPackages (epkgs: + with epkgs; [ + # Theme + doom-themes + # crafted-completion-packages + cape + consult + corfu + corfu-terminal + embark + embark-consult + marginalia + orderless + vertico + + # crafted-ide-packages + treesit-auto + editorconfig + aggressive-indent + ibuffer-project + + # crafted-org-packages + denote + org-appear + + # crafted-ui-packages + all-the-icons + elisp-demos + helpful + + # crafted-workspaces-packages + tabspaces + + # crafted-writing-packages + markdown-mode + pandoc-mode + auctex + auctex-latexmk + + # Additional packages + magit + vterm + nix-mode + ])); + }; + home = { + packages = with pkgs; [ # Emacs dependencies coreutils gnutls @@ -55,10 +89,6 @@ in { rustup texlive.combined.scheme-medium python3 - python3Packages.cython - python3Packages.pyflakes - python3Packages.nose - python3Packages.pytest nodePackages.stylelint ]; }; diff --git a/home/emacs/config/init.el b/home/emacs/init.el similarity index 54% rename from home/emacs/config/init.el rename to home/emacs/init.el index 201fc4f4..d92c0760 100644 --- a/home/emacs/config/init.el +++ b/home/emacs/init.el @@ -9,22 +9,36 @@ ;; This can be done here, or in the early-init.el file. (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) (when (and custom-file (file-exists-p custom-file)) - (load custom-file nil :nomessage)) + (load custom-file nil 'nomessage)) -;; Adds crafted-emacs modules to the `load-path', sets up a module -;; writing template, sets the `crafted-emacs-home' variable. -(load "~/Projects/crafted-emacs/modules/crafted-init-config") +;; Add custom modules to the `load-path' +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) + +;; Adds crafted-emacs modules to the `load-path' +(setq crafted-emacs-home (expand-file-name "crafted-emacs" user-emacs-directory)) +(add-to-list 'load-path (expand-file-name "modules" crafted-emacs-home)) ;;; Configuration phase ;; Some example modules to configure Emacs. Don't blindly copy these, ;; they are here for example purposes. Find the modules which work ;; for you and add them here. -;; (require 'crafted-defaults-config) -;; (require 'crafted-startup-config) +(require 'crafted-completion-config) +(require 'crafted-defaults-config) +(require 'crafted-ide-config) +(require 'crafted-org-config) +(require 'crafted-startup-config) +(require 'crafted-ui-config) +(require 'crafted-workspaces-packages) +(require 'crafted-writing-packages) ;;; Optional configuration +;; Set theme to Tokyo Night from doom-themes +(load-theme 'doom-tokyo-night t) +(add-to-list 'default-frame-alist '(font . "FiraCode Nerd Font-12")) +(global-prettify-symbols-mode) + ;; Profile emacs startup (defun crafted-startup-example/display-startup-time () "Display the startup time after Emacs is fully initialized." @@ -34,4 +48,12 @@ ;; Set default coding system (especially for Windows) (set-default-coding-systems 'utf-8) +(set-terminal-coding-system 'utf-8) +(set-keyboard-coding-system 'utf-8) + +;; Set org directory +(setq org-directory "~/Org") + + + diff --git a/home/emacs/lsp_servers.nix b/home/emacs/lsp_servers.nix index f0a51a5a..c05be723 100644 --- a/home/emacs/lsp_servers.nix +++ b/home/emacs/lsp_servers.nix @@ -11,6 +11,7 @@ nodePackages.pyright nodePackages.yaml-language-server nodePackages.bash-language-server + nodePackages.javascript-typescript-langserver nodePackages.vscode-html-languageserver-bin nodePackages.vscode-css-languageserver-bin nodePackages.vscode-json-languageserver-bin diff --git a/home/emacs/modules/custom-ligatures-config.el b/home/emacs/modules/custom-ligatures-config.el new file mode 100644 index 00000000..b5ba19d7 --- /dev/null +++ b/home/emacs/modules/custom-ligatures-config.el @@ -0,0 +1,58 @@ +(defun fira-code-mode--make-alist (list) + "Generate prettify-symbols alist from LIST." + (let ((idx -1)) + (mapcar + (lambda (s) + (setq idx (1+ idx)) + (let* ((code (+ #Xe100 idx)) + (width (string-width s)) + (prefix ()) + (suffix '(?\s (Br . Br))) + (n 1)) + (while (< n width) + (setq prefix (append prefix '(?\s (Br . Bl)))) + (setq n (1+ n))) + (cons s (append prefix suffix (list (decode-char 'ucs code)))))) + list))) + +(defconst fira-code-mode--ligatures + '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" + "{-" "[]" "::" ":::" ":=" "!!" "!=" "!==" "-}" + "--" "---" "-->" "->" "->>" "-<" "-<<" "-~" + "#{" "#[" "##" "###" "####" "#(" "#?" "#_" "#_(" + ".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" + "/**" "/=" "/==" "/>" "//" "///" "&&" "||" "||=" + "|=" "|>" "^=" "$>" "++" "+++" "+>" "=:=" "==" + "===" "==>" "=>" "=>>" "<=" "=<<" "=/=" ">-" ">=" + ">=>" ">>" ">>-" ">>=" ">>>" "<*" "<*>" "<|" "<|>" + "<$" "<$>" "