From 1a17d956b3ab69e12fb9dc320274efa27b45635f Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Mon, 10 Mar 2025 02:31:33 +0200 Subject: Switch from straight.el to elpaca --- init.el | 143 ++++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 98 insertions(+), 45 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index a16100c..f74af4a 100644 --- a/init.el +++ b/init.el @@ -93,7 +93,7 @@ (concat "SECURE128:+SECURE192:-VERS-ALL" (if (and (not +windows+) (>= libgnutls-version 30605)) - ":+VERS-TLS1.3" + ":+VERS-TLS1.3:+VERS-TLS1.2" ":+VERS-TLS1.2")))) (when +mac+ @@ -101,7 +101,7 @@ mac-command-modifier 'super)) (when (file-exists-p custom-file) - (load custom-file)) + (add-hook 'elpaca-after-init-hook (lambda () (load custom-file 'noerror)))) (use-package auth-source :defer t @@ -148,34 +148,86 @@ w32-pipe-read-delay 0 w32-pipe-buffer-size read-process-output-max)) -;; Install straight.el -(defvar bootstrap-version) -(let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) - (bootstrap-version 6)) - (unless (file-exists-p bootstrap-file) - (message "This might take a long time...") - (with-current-buffer - (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" - 'silent 'inhibit-cookies) - (goto-char (point-max)) - (eval-print-last-sexp))) - (load bootstrap-file)) +;; Install elpaca +(progn + (defvar elpaca-installer-version 0.10) + (defvar elpaca-directory (expand-file-name "elpaca/" local-dir)) + (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) + (defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) + (defvar elpaca-lock-file (expand-file-name "elpaca-lock.el" shared-dir)) + (defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" + :ref nil :depth 1 :inherit ignore + :files (:defaults "elpaca-test.el" (:exclude "extensions")) + :build (:not elpaca--activate-package))) + (let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) + (build (expand-file-name "elpaca/" elpaca-builds-directory)) + (order (cdr elpaca-order)) + (default-directory repo)) + (add-to-list 'load-path (if (file-exists-p build) build repo)) + (unless (file-exists-p repo) + (make-directory repo t) + (when (<= emacs-major-version 28) (require 'subr-x)) + (condition-case-unless-debug err + (if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (apply #'call-process `("git" nil ,buffer t "clone" + ,@(when-let* ((depth (plist-get order :depth))) + (list (format "--depth=%d" depth) "--no-single-branch")) + ,(plist-get order :repo) ,repo)))) + ((zerop (call-process "git" nil buffer t "checkout" + (or (plist-get order :ref) "--")))) + (emacs (concat invocation-directory invocation-name)) + ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" + "--eval" "(byte-recompile-directory \".\" 0 'force)"))) + ((require 'elpaca)) + ((elpaca-generate-autoloads "elpaca" repo))) + (progn (message "%s" (buffer-string)) (kill-buffer buffer)) + (error "%s" (with-current-buffer buffer (buffer-string)))) + ((error) (warn "%s" err) (delete-directory repo 'recursive)))) + (unless (require 'elpaca-autoloads nil t) + (require 'elpaca) + (elpaca-generate-autoloads "elpaca" repo) + (load "./elpaca-autoloads"))) + (add-hook 'after-init-hook #'elpaca-process-queues) + (elpaca `(,@elpaca-order)) + (when +windows+ + (elpaca-no-symlink-mode))) + +(progn + (elpaca elpaca-use-package + (elpaca-use-package-mode)) + (elpaca-wait)) + +;; Builtins that I update with elpaca. +;; Consider adding some to elpaca-ignored-dependencies if problems arise. +(progn + (defun arkta/elpaca-build-with-unload (pkg) + (append (butlast (if (file-exists-p (file-name-concat elpaca-builds-directory + (symbol-name pkg))) + elpaca--pre-built-steps + elpaca-build-steps)) + (list `(lambda (e) + (when (featurep ',pkg) + (unload-feature ',pkg t)) + (elpaca--continue-build e)) + 'elpaca--activate-package))) + (use-package seq + :ensure `(seq :build ,(arkta/elpaca-build-with-unload 'seq))) + (use-package transient + :ensure `(transient :build ,(arkta/elpaca-build-with-unload 'transient)))) (defun arkta/update-packages () (interactive) - (straight-pull-all) - (straight-freeze-versions)) + (elpaca-update-all) + (elpaca-write-lock-file elpaca-lock-file)) (defun arkta/fix-versions () (interactive) - ;; Thaw & freeze to make sure we also freeze new stuff - (straight-thaw-versions) - (straight-freeze-versions)) + (elpaca-write-lock-file elpaca-lock-file)) ;; compat (use-package compat-30 :if +emacs29+ - :straight 'compat) + :ensure 'compat) ;; Helper functions (defmacro defsetter (name &rest emacs-names) @@ -203,17 +255,17 @@ (require 'arkta-project) (use-package ace-window - :straight t + :ensure t :bind (([remap other-window] . ace-window) ("C-x o" . ace-window))) (use-package amx - :straight t + :ensure t :config (amx-mode +1)) (use-package company - :straight t + :ensure t :custom (company-format-margin-function #'company-text-icons-margin) (company-text-face-extra-attributes '(:weight bold)) @@ -226,11 +278,11 @@ (global-company-mode +1)) (use-package compile - :straight '(compile :type built-in) + :ensure nil :bind (("C-c k" . compile))) (use-package copyright - :straight '(copyright :type built-in) + :ensure nil :init (defun arkta/maybe-fix-copyright () (save-mark-and-excursion @@ -242,13 +294,13 @@ (copyright-year-ranges t)) (use-package counsel - :straight t + :ensure t :after amx :config (counsel-mode +1)) (use-package dashboard - :straight t + :ensure t :demand t :hook (server-after-make-frame . dashboard-open) :custom @@ -264,12 +316,12 @@ (dashboard-setup-startup-hook)) (use-package editorconfig - :straight t + :ensure t :config (editorconfig-mode +1)) (use-package eglot - :straight '(eglot :type built-in) + :ensure nil :hook ((gdscript-mode go-ts-mode) . eglot-ensure) :custom (eglot-ignored-server-capabilities '(:documentFormattingProvider @@ -278,17 +330,21 @@ (eglot-autoshutdown t)) (use-package elpher - :straight t + :ensure t :commands (elpher) :custom (elpher-default-url-type "gemini")) (use-package envrc - :straight t + :ensure t ;; This actually has to be hooked to after-init to be one of the first minor modes enabled - :hook (after-init . envrc-global-mode)) + :hook (elpaca-after-init . envrc-global-mode)) + +(use-package forge + :ensure t + :after magit) (use-package gcmh - :straight t + :ensure t :custom (gcmh-idle-delay 'auto) (gcmh-auto-idle-delay-factor 10) @@ -297,13 +353,13 @@ (gcmh-mode +1)) (use-package ibuffer - :straight '(ibuffer :type built-in) + :ensure nil :bind (("C-x C-b" . ibuffer) ([remap list-buffers] . ibuffer))) (use-package ivy + :ensure t :after (counsel swiper) - :straight t :demand t :bind (("C-c r" . ivy-resume) ("C-c v" . ivy-push-view) @@ -316,28 +372,24 @@ (use-package magit ;; TODO: Do some proper setup - :straight t - :config - (use-package forge - :straight t - :after magit)) + :ensure t) (use-package simple - :straight (simple :type built-in) + :ensure nil :hook ((text-mode . turn-on-auto-fill) (before-save . delete-trailing-whitespace)) :custom (backward-delete-char-untabify-method nil)) (use-package swiper - :straight t + :ensure t :bind (([remap isearch-forward] . swiper-isearch) ([remap isearch-backward] . swiper-isearch-backward) ("C-s" . swiper-isearch) ("C-r" . swiper-isearch-backward))) (use-package treemacs - :straight t + :ensure t :commands (treemacs treemacs-select-window) :custom (treemacs-select-when-already-in-treemacs 'next-or-back) @@ -345,7 +397,7 @@ ("C-c C-SPC" . treemacs-select-window))) (use-package treesit - :straight '(treesit :type built-in) + :ensure nil :config (setq treesit-extra-load-path (list (expand-file-name "tree-sitter" local-config-dir))) @@ -367,6 +419,7 @@ (toml "https://github.com/ikatyang/tree-sitter-toml.git") (tsx "https://github.com/tree-sitter/tree-sitter-typescript.git" nil "tsx/src") (typescript "https://github.com/tree-sitter/tree-sitter-typescript.git" nil "typescript/src") + (typst "https://github.com/uben0/tree-sitter-typst") (yaml "https://github.com/ikatyang/tree-sitter-yaml.git"))) (mapc (lambda (spec) (let ((name (car spec))) @@ -375,5 +428,5 @@ treesit-language-source-alist)) (use-package warnings - :straight '(warnings :type built-in) + :ensure nil :custom (warning-suppress-types '((comp)))) -- cgit v1.2.3