From 22c029b2f44186797fcdb88d86745140c2132601 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 25 May 2025 17:25:41 +0200 Subject: [PATCH 01/19] Remove old eldoc/jsonrpc workarounds and just use built-in packages --- config.org | 59 +++++++++--------------------------------------------- 1 file changed, 9 insertions(+), 50 deletions(-) diff --git a/config.org b/config.org index 88e0e25..6424b85 100644 --- a/config.org +++ b/config.org @@ -61,57 +61,7 @@ (elpaca-wait) #+end_src -* Built-in packages -** Eldoc - -I got the following error message when loading eglot: -#+BEGIN_SRC -eglot failed eldoc installed version (1 13 0) lower than min required 1.14.0 00.239351 -#+END_SRC - -So install the eldoc package to be sure we have the latest version. -But after installing it, we get a new warning: - -#+BEGIN_SRC -⛔ Warning (emacs): eldoc loaded before Elpaca activation -#+END_SRC - -This seemed tricker than expected, but found a solution in the github issues of elpaca: -https://github.com/progfolio/elpaca/issues/236 - -#+BEGIN_SRC emacs-lisp -(use-package eldoc - :preface - ;; avoid loading of built-in eldoc, see https://github.com/progfolio/elpaca/issues/236#issuecomment-1879838229 - (unload-feature 'eldoc t) - (setq custom-delayed-init-variables '()) - (defvar global-eldoc-mode nil) - :demand t - :config - (global-eldoc-mode)) - -#+END_SRC - -** Jsonrpc -After eldoc was taken care of, a new error was reported: -#+BEGIN_SRC -eglot failed jsonrpc installed version (1 0 16) lower than min required 1.0.24 00.280828 -#+END_SRC - -So let's install the latest one: -#+BEGIN_SRC emacs-lisp -(use-package jsonrpc) -#+END_SRC - -** Wait for loading updated packages - -Wait until updated built-in packages are fully loaded: -#+BEGIN_SRC emacs-lisp -(elpaca-wait) -#+END_SRC - * General config - ** Bell The audible bell is annoying AF. @@ -206,6 +156,15 @@ Use list-buffers bigger brother. (global-set-key (kbd "M-SPC") 'mark-word) #+end_src +** Eldoc + +#+BEGIN_SRC emacs-lisp +(use-package eldoc + :ensure nil + :init + (global-eldoc-mode)) +#+END_SRC + ** Isearch Display number of matches: From 49a5164f45a90c369482b6aef1a1a2ee7194b280 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 25 May 2025 17:26:06 +0200 Subject: [PATCH 02/19] Rework isearch configuration using emacs-solo inspiration --- config.org | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/config.org b/config.org index 6424b85..faed9e1 100644 --- a/config.org +++ b/config.org @@ -167,10 +167,26 @@ Use list-buffers bigger brother. ** Isearch -Display number of matches: -#+begin_src emacs-lisp -(setq-default isearch-lazy-count t) -#+end_src +Inspired by [[https://github.com/LionyxML/emacs-solo][emacs-solo]]: + +#+BEGIN_SRC emacs-lisp +(use-package isearch + :ensure nil + :config + (setq isearch-lazy-count t) ; Display number of matches + (setq lazy-count-prefix-format "(%s/%s) ") ; eye-candy to add braces + (defun isearch-copy-selected-word () + "Copy the current `isearch` selection to the kill ring." + (interactive) + (when isearch-other-end + (let ((selection (buffer-substring-no-properties isearch-other-end (point)))) + (kill-new selection) + (isearch-exit)))) + + ;; Bind `M-w` in isearch to copy the selected word, so M-s M-. M-w + ;; does a great job of 'copying the current word under cursor'. + (define-key isearch-mode-map (kbd "M-w") 'isearch-copy-selected-word)) +#+END_SRC Reference that might be interesting for later: https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html From f2dc1fe4961cb9dd54ca1212fa60ce6b2a8beec9 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 25 May 2025 17:26:30 +0200 Subject: [PATCH 03/19] Add flymake configuration --- config.org | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/config.org b/config.org index faed9e1..6d332c9 100644 --- a/config.org +++ b/config.org @@ -191,6 +191,25 @@ Inspired by [[https://github.com/LionyxML/emacs-solo][emacs-solo]]: Reference that might be interesting for later: https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html +** Flymake + +#+BEGIN_SRC emacs-lisp +(use-package flymake + :ensure nil + :defer t + :hook + (prog-mode-hook . flymake-mode) + :custom + (flymake-show-diagnostics-at-end-of-line 'short) + (flymake-indicator-type 'margins) + (flymake-margin-indicators-string + `((error "!" compilation-error) + (warning "?" compilation-warning) + (note "i" compilation-info)) + ) + ) +#+END_SRC + ** Abbrev #+begin_src emacs-lisp From 6c24da45031616936063f873284683a2fece8bac Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Sun, 25 May 2025 17:26:38 +0200 Subject: [PATCH 04/19] Rework eglot configuration to use built-in package --- config.org | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/config.org b/config.org index 6d332c9..3aa641e 100644 --- a/config.org +++ b/config.org @@ -731,15 +731,21 @@ https://github.com/victorhge/iedit ** Eglot #+BEGIN_SRC emacs-lisp - (use-package eglot) - +(use-package eglot + :ensure nil + :custom + (eglot-autoshutdown t) + :init (setq eglot-stay-out-of '(xref)) (add-hook 'prog-mode-hook 'eglot-ensure) (add-hook 'eglot-managed-mode-hook (lambda () (if (eglot-managed-p) (add-hook 'xref-backend-functions 'eglot-xref-backend) (remove-hook 'xref-backend-functions 'eglot-xref-backend) - ))) + ))) + + ) + #+END_SRC ** Markdown-mode From 2572e8c22199c5e173a020237f941290ddf5736a Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Mon, 26 May 2025 10:59:38 +0200 Subject: [PATCH 05/19] Fix linting warnings in early-init/init.el There should be no functional changes --- early-init.el | 19 +++++++++++++------ init.el | 6 ++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/early-init.el b/early-init.el index 0fe1b95..3a99e6d 100644 --- a/early-init.el +++ b/early-init.el @@ -1,9 +1,16 @@ +;;; early-init.el --- Early Init -*- lexical-binding: t; -*- + +;;; Commentary: +;; Early init configuration for Emacs Solo +;; + +;;; Code: + + + +;; Recommended by elpaca (setq package-enable-at-startup nil) +(provide 'early-init) -;; Local Variables: -;; no-byte-compile: t -;; no-native-compile: t -;; no-update-autoloads: t -;; End: - +;;; early-init.el ends here diff --git a/init.el b/init.el index 5b96eb9..a57c423 100644 --- a/init.el +++ b/init.el @@ -1,3 +1,9 @@ +;;; init.el --- Init -*- lexical-binding: t; -*- + + +;;; Commentary: +;;; Load init files + ;;; Increase garbage collection threshold during init but leave it to the default value after ;;; There are a LOT of articles/sites/... discussing this: ;;; https://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/ From a731bab651f9115b4026878ebadce3c62e404a43 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Mon, 26 May 2025 10:59:45 +0200 Subject: [PATCH 06/19] Only pop-up messages buffer if there is an error --- early-init.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/early-init.el b/early-init.el index 3a99e6d..e163e66 100644 --- a/early-init.el +++ b/early-init.el @@ -7,6 +7,8 @@ ;;; Code: +;; Only care about errors in *Messages* buffer +(setq warning-minimum-level :error) ;; Recommended by elpaca (setq package-enable-at-startup nil) From 7f901b23aec9fde3de5c085587e9e263aa7acdea Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 11:47:37 +0200 Subject: [PATCH 07/19] feat: Remove elpaca I'm not actually using it and it's just bloat at this point. This speeds up the startup significantly. Remove what you don't need. --- config.org | 168 +++++++++++++++++++------------------------------- early-init.el | 2 +- 2 files changed, 64 insertions(+), 106 deletions(-) diff --git a/config.org b/config.org index 3aa641e..63b47ad 100644 --- a/config.org +++ b/config.org @@ -3,65 +3,61 @@ #+CREATOR: Laurens Miers #+LANGUAGE: en -* Elpaca - -** Core +* General config #+BEGIN_SRC emacs-lisp -(defvar elpaca-installer-version 0.11) -(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) -(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) -(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) -(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) - (let ((load-source-file-function nil)) (load "./elpaca-autoloads")))) -(add-hook 'after-init-hook #'elpaca-process-queues) -(elpaca `(,@elpaca-order)) + (use-package emacs + :ensure nil + :custom + (inhibit-startup-message t) + :init + (with-current-buffer (get-buffer-create "*scratch*") + (insert (format ";; + ;; ██╗ ██╗███████╗██╗ ██╗ ██████╗ + ;; ██║ ██║██╔════╝██║ ██║ ██╔═══██╗ + ;; ███████║█████╗ ██║ ██║ ██║ ██║ + ;; ██╔══██║██╔══╝ ██║ ██║ ██║ ██║ + ;; ██║ ██║███████╗███████╗███████╗╚██████╔╝ + ;; ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═════╝ + ;; + ;; ███████╗███╗ ███╗ █████╗ ██████╗███████╗ + ;; ██╔════╝████╗ ████║██╔══██╗██╔════╝██╔════╝ + ;; █████╗ ██╔████╔██║███████║██║ ███████╗ + ;; ██╔══╝ ██║╚██╔╝██║██╔══██║██║ ╚════██║ + ;; ███████╗██║ ╚═╝ ██║██║ ██║╚██████╗███████║ + ;; ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚══════╝ + ;; + ;; Loading time : %s + ;; Packages : %s + ;; + " + (emacs-init-time) + (number-to-string (length package-activated-list))))) + + (message (emacs-init-time)) + ) #+END_SRC -** Use-package integration +** Package repos -#+begin_src emacs-lisp -;; Install use-package support -(elpaca elpaca-use-package - ;; Enable use-package :ensure support for Elpaca. - (elpaca-use-package-mode) - ) +#+BEGIN_SRC emacs-lisp +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities` +;; and `package-pinned-packages`. Most users will not need or want to do this. +;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) +(package-initialize) +#+END_SRC -;; wait to get elpaca use-package integration -(elpaca-wait) -#+end_src +** Use-package + +*** Always ensure + +#+BEGIN_SRC emacs-lisp +(require 'use-package-ensure) +(setq use-package-always-ensure t) +#+END_SRC -* General config ** Bell The audible bell is annoying AF. @@ -246,15 +242,6 @@ Narrow-region/page is a really handy feature, enable it: (put 'narrow-to-region 'disabled nil) #+END_SRC -** Use-package - -*** Always ensure - -#+BEGIN_SRC emacs-lisp -(require 'use-package-ensure) -(setq use-package-always-ensure t) -#+END_SRC - ** Adaptive cursor width Make cursor the width of the character it is under f.e. full width of a tab. @@ -650,29 +637,26 @@ For the keybindings, we have to defien them in both raw and line mode. From the #+begin_src emacs-lisp (use-package dashboard :config - (add-hook 'elpaca-after-init-hook #'dashboard-insert-startupify-lists) - (add-hook 'elpaca-after-init-hook #'dashboard-initialize) (dashboard-setup-startup-hook)) #+end_src * Hydra -Install and wait for hydra to be available since we are using it in this init.el : -#+begin_src emacs-lisp +https://github.com/abo-abo/hydra + +#+BEGIN_SRC emacs-lisp (use-package hydra - :ensure (:wait t) + :defer t + :config + ;; Zoom hydra + (defhydra hydra-zoom (global-map "") + "zoom" + ("g" text-scale-increase "in") + ("l" text-scale-decrease "out") + ) + ) -#+end_src - -** Text zoom - -#+begin_src emacs-lisp -(defhydra hydra-zoom (global-map "") - "zoom" - ("g" text-scale-increase "in") - ("l" text-scale-decrease "out") -) -#+end_src +#+END_SRC * Zygospore @@ -770,41 +754,15 @@ https://github.com/victorhge/iedit ** Magit -*** Transient - -Magit depends on this and it seems it's not installed as a dependency, so install it explicitly. - -#+BEGIN_SRC emacs-lisp -(use-package transient - :ensure (:wait t) -) -#+END_SRC - *** Core #+BEGIN_SRC emacs-lisp (use-package magit -:ensure (:wait t) -) + :defer t + ) #+END_SRC -**** Extra commands - -***** Update all submodules - -#+BEGIN_SRC emacs-lisp -(transient-define-suffix magit-submodule-update-all () - "Update all submodules" - :description "Update All git submodule update --init --recursive" - (interactive) - (magit-with-toplevel - (magit-run-git-async "submodule" "update" "--force"))) - -(transient-append-suffix 'magit-submodule "f" - '("U" magit-submodule-update-all)) -#+END_SRC - ** Dumb-jump #+BEGIN_SRC emacs-lisp diff --git a/early-init.el b/early-init.el index e163e66..5d83494 100644 --- a/early-init.el +++ b/early-init.el @@ -10,7 +10,7 @@ ;; Only care about errors in *Messages* buffer (setq warning-minimum-level :error) -;; Recommended by elpaca +;; We control when packages are enabled (setq package-enable-at-startup nil) (provide 'early-init) From adab1147e0da42c890d047d55b0f2dc5082db383 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 11:48:31 +0200 Subject: [PATCH 08/19] fix: Docs on keys to use when resizing --- config.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.org b/config.org index 63b47ad..d80c79b 100644 --- a/config.org +++ b/config.org @@ -301,8 +301,8 @@ C-c C-c to apply." :global t (if (<= (length (window-list)) 1) (progn (setq resize-frame nil) - (message "Only root frame exists, abort.")) - (message "Use arrow-keys or i/j/k/l to adjust frames."))) + (message "Only root frame exists, abort.")) + (message "Use arrow-keys or C-p/n/f/b to adjust frames."))) (defun resize-frame-done () (interactive) From 377a5cadff3a82543095840bf97255fde13eaf06 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 11:48:46 +0200 Subject: [PATCH 09/19] fix: whitespace has a separate built-in package It has a better hook (whitespace-cleanup) than the barebones delete-trailing-whitespace. --- config.org | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config.org b/config.org index d80c79b..cb19b82 100644 --- a/config.org +++ b/config.org @@ -72,10 +72,16 @@ The audible bell is annoying AF. (setq column-number-mode 1) #+END_SRC -** Delete trailing whitespaces +** Whitespace cleanup #+BEGIN_SRC emacs-lisp -(add-hook 'before-save-hook 'delete-trailing-whitespace) +(use-package whitespace + :ensure nil + :defer t + :hook (before-save-hook . whitespace-cleanup) + ;; if we wanna remove this hook at any time, eval: + ;; (remove-hook 'before-save-hook #'whitespace-cleanup) + ) #+END_SRC ** Save history and recent files From 80b3e4dbc16e0ed8b3fbc314366c733d1a208d3c Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 11:49:59 +0200 Subject: [PATCH 10/19] feat: enable vertico-cycle and call hook when appropriate --- config.org | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/config.org b/config.org index cb19b82..55f545b 100644 --- a/config.org +++ b/config.org @@ -322,15 +322,14 @@ C-c C-c to apply." ** Minibuffer #+BEGIN_SRC emacs-lisp -;; Enable vertico (use-package vertico - ;; :custom + :custom ;; (vertico-scroll-margin 0) ;; Different scroll margin ;; (vertico-count 20) ;; Show more candidates ;; (vertico-resize t) ;; Grow and shrink the Vertico minibuffer - ;; (vertico-cycle t) ;; Enable cycling for `vertico-next/previous' - :init - (vertico-mode)) + (vertico-cycle t) ;; Enable cycling for `vertico-next/previous' + :hook (after-init . vertico-mode) + ) #+END_SRC ** Consult From 3f93a19d4b92287ffc670adc74bd546e0b41853f Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 11:51:20 +0200 Subject: [PATCH 11/19] feat: enable corfu iso company-mode No issues so far when using melpa iso latest git repo (elpaca behaviour) --- config.org | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/config.org b/config.org index 55f545b..346c55e 100644 --- a/config.org +++ b/config.org @@ -457,7 +457,7 @@ C-c C-c to apply." *** Corfu -#+BEGIN_SRC +#+BEGIN_SRC emacs-lisp (use-package corfu ;; Optional customizations :bind (:map corfu-map ("" . corfu-complete)) @@ -486,19 +486,6 @@ C-c C-c to apply." (global-corfu-mode)) #+end_src -*** Company-mode - -#+BEGIN_SRC emacs-lisp -(use-package company - :config - (define-key prog-mode-map - (kbd "TAB") - #'company-indent-or-complete-common) - :init - (global-company-mode) - ) -#+END_SRC - ** Orderless #+begin_src emacs-lisp From a79987f30fba939724c39a7aaed91b541aebf82a Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 11:52:05 +0200 Subject: [PATCH 12/19] chore: stylefix --- config.org | 187 ++++++++++++++++++++++++++--------------------------- 1 file changed, 93 insertions(+), 94 deletions(-) diff --git a/config.org b/config.org index 346c55e..0390fca 100644 --- a/config.org +++ b/config.org @@ -182,8 +182,8 @@ Inspired by [[https://github.com/LionyxML/emacs-solo][emacs-solo]]: (interactive) (when isearch-other-end (let ((selection (buffer-substring-no-properties isearch-other-end (point)))) - (kill-new selection) - (isearch-exit)))) + (kill-new selection) + (isearch-exit)))) ;; Bind `M-w` in isearch to copy the selected word, so M-s M-. M-w ;; does a great job of 'copying the current word under cursor'. @@ -338,58 +338,58 @@ C-c C-c to apply." (use-package consult ;; Replace bindings. Lazily loaded by `use-package'. :bind (;; C-c bindings in `mode-specific-map' - ;; ("C-c M-x" . consult-mode-command) - ;; ("C-c h" . consult-history) - ;; ("C-c k" . consult-kmacro) - ;; ("C-c m" . consult-man) - ;; ("C-c i" . consult-info) - ([remap Info-search] . consult-info) - ;; C-x bindings in `ctl-x-map' - ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command - ("C-x b" . consult-buffer) ;; orig. switch-to-buffer - ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window - ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame - ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab - ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump - ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer - ;; Custom M-# bindings for fast register access - ;; ("M-#" . consult-register-load) - ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) - ;; ("C-M-#" . consult-register) - ;; Other custom bindings - ("M-y" . consult-yank-pop) ;; orig. yank-pop - ;; M-g bindings in `goto-map' - ("M-g e" . consult-compile-error) - ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck - ("M-g g" . consult-goto-line) ;; orig. goto-line - ("M-g M-g" . consult-goto-line) ;; orig. goto-line - ;; ("M-g o" . consult-outline) ;; Alternative: consult-org-heading - ;; ("M-g m" . consult-mark) - ;; ("M-g k" . consult-global-mark) - ("M-i" . consult-imenu) - ("M-I" . consult-imenu-multi) - ;; M-s bindings in `search-map' - ("M-s d" . consult-find) ;; Alternative: consult-fd - ;; ("M-s c" . consult-locate) - ("M-s g" . consult-grep) - ;; ("M-s G" . consult-git-grep) - ;; ("M-s r" . consult-ripgrep) - ("M-s l" . consult-line) - ;; ("M-s L" . consult-line-multi) - ;; ("M-s k" . consult-keep-lines) - ;; ("M-s u" . consult-focus-lines) - ;; Isearch integration - ("M-s e" . consult-isearch-history) - :map isearch-mode-map - ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string - ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string - ("M-s l" . consult-line) ;; needed by consult-line to detect isearch - ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch - ;; Minibuffer history - :map minibuffer-local-map - ("M-s" . consult-history) ;; orig. next-matching-history-element - ("M-r" . consult-history) ;; orig. previous-matching-history-element - ) + ;; ("C-c M-x" . consult-mode-command) + ;; ("C-c h" . consult-history) + ;; ("C-c k" . consult-kmacro) + ;; ("C-c m" . consult-man) + ;; ("C-c i" . consult-info) + ([remap Info-search] . consult-info) + ;; C-x bindings in `ctl-x-map' + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab + ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ;; Custom M-# bindings for fast register access + ;; ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ;; ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ;; M-g bindings in `goto-map' + ("M-g e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ;; ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ;; ("M-g m" . consult-mark) + ;; ("M-g k" . consult-global-mark) + ("M-i" . consult-imenu) + ("M-I" . consult-imenu-multi) + ;; M-s bindings in `search-map' + ("M-s d" . consult-find) ;; Alternative: consult-fd + ;; ("M-s c" . consult-locate) + ("M-s g" . consult-grep) + ;; ("M-s G" . consult-git-grep) + ;; ("M-s r" . consult-ripgrep) + ("M-s l" . consult-line) + ;; ("M-s L" . consult-line-multi) + ;; ("M-s k" . consult-keep-lines) + ;; ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ;; Minibuffer history + :map minibuffer-local-map + ("M-s" . consult-history) ;; orig. next-matching-history-element + ("M-r" . consult-history) ;; orig. previous-matching-history-element + ) ;; Enable automatic preview at point in the *Completions* buffer. This is ;; relevant when you use the default completion UI. @@ -402,7 +402,7 @@ C-c C-c to apply." ;; preview for `consult-register', `consult-register-load', ;; `consult-register-store' and the Emacs built-ins. ;; (setq register-preview-delay 0.5 - ;; register-preview-function #'consult-register-format) + ;; register-preview-function #'consult-register-format) ;; Optionally tweak the register preview window. ;; This adds thin lines, sorting and hides the mode line of the window. @@ -410,7 +410,7 @@ C-c C-c to apply." ;; Use Consult to select xref locations with preview (setq xref-show-xrefs-function #'consult-xref - xref-show-definitions-function #'consult-xref) + xref-show-definitions-function #'consult-xref) ;; Configure other variables and modes in the :config section, ;; after lazily loading the package. @@ -449,10 +449,10 @@ C-c C-c to apply." #+BEGIN_SRC emacs-lisp (setq completion-in-region-function (lambda (&rest args) - (apply (if vertico-mode - #'consult-completion-in-region - #'completion--in-region) - args))) + (apply (if vertico-mode + #'consult-completion-in-region + #'completion--in-region) + args))) #+END_SRC *** Corfu @@ -488,7 +488,7 @@ C-c C-c to apply." ** Orderless -#+begin_src emacs-lisp +#+BEGIN_SRC emacs-lisp (use-package orderless :demand t :custom @@ -508,18 +508,18 @@ C-c C-c to apply." ;; ) ;; ) ) -#+end_src +#+END_SRC ** Marginalia -#+begin_src emacs-lisp +#+BEGIN_SRC emacs-lisp ;; Enable rich annotations using the Marginalia package (use-package marginalia ;; Bind `marginalia-cycle' locally in the minibuffer. To make the binding ;; available in the *Completions* buffer, add it to the ;; `completion-list-mode-map'. :bind (:map minibuffer-local-map - ("M-A" . marginalia-cycle)) + ("M-A" . marginalia-cycle)) ;; The :init section is always executed. :init @@ -527,7 +527,7 @@ C-c C-c to apply." ;; the mode gets enabled right away. Note that this forces loading the ;; package. (marginalia-mode)) -#+end_src +#+END_SRC * Dired @@ -541,10 +541,10 @@ C-c C-c to apply." ) (add-hook 'dired-mode-hook - (lambda () - ;; Set dired-x buffer-local variables here. For example: - ;; (dired-omit-mode 1) - )) + (lambda () + ;; Set dired-x buffer-local variables here. For example: + ;; (dired-omit-mode 1) + )) #+end_src ** Guess target directory @@ -565,9 +565,8 @@ Operate on the current line if no region is active. #+begin_src emacs-lisp (use-package whole-line-or-region - - :config - (whole-line-or-region-global-mode 1) + :config + (whole-line-or-region-global-mode 1) ) #+end_src @@ -689,12 +688,12 @@ https://github.com/victorhge/iedit ) (mapc (lambda (mode) - (font-lock-add-keywords - mode - '( - ("\\<\\(FIXME\\)" 1 'highlight-angry-faces t) - ("\\<\\(TODO\\)" 1 'highlight-angry-faces t) - ))) + (font-lock-add-keywords + mode + '( + ("\\<\\(FIXME\\)" 1 'highlight-angry-faces t) + ("\\<\\(TODO\\)" 1 'highlight-angry-faces t) + ))) '(text-mode emacs-lisp-mode rust-mode zig-mode c-ts-mode c-mode prog-mode) ) #+END_SRC @@ -758,10 +757,10 @@ https://github.com/victorhge/iedit ** Dumb-jump #+BEGIN_SRC emacs-lisp - (use-package dumb-jump - :init - (add-hook 'xref-backend-functions #'dumb-jump-xref-activate) - ) +(use-package dumb-jump + :init + (add-hook 'xref-backend-functions #'dumb-jump-xref-activate) +) #+END_SRC ** C-programming @@ -841,8 +840,8 @@ https://github.com/remyferre/comment-dwim-2 #+BEGIN_SRC emacs-lisp (use-package comment-dwim-2 - :config - (global-set-key (kbd "M-;") 'comment-dwim-2) + :bind + ("M-;" . comment-dwim-2) ) #+END_SRC @@ -1006,11 +1005,11 @@ Inspired by https://github.com/org-roam/org-roam/wiki/User-contributed-Tricks#fi "Select a single tag from list and filter `org-roam-node' by it." (interactive) (let ((tag (car (completing-read-multiple "Tag: " - (org-roam-tag-completions))))) + (org-roam-tag-completions))))) (org-roam-node-find nil nil - (lambda (node) - (member tag - (org-roam-node-tags node)))))) + (lambda (node) + (member tag + (org-roam-node-tags node)))))) #+END_SRC ** Font @@ -1061,7 +1060,7 @@ in a local directory (on Linux this is ~/.local/share/fonts). (when buffer-file-name (find-alternate-file (concat "/sudo:root@localhost:" - buffer-file-name) + buffer-file-name) ) ) ) @@ -1089,9 +1088,9 @@ in a local directory (on Linux this is ~/.local/share/fonts). (defun myrmi/run-ceedling-tests (&optional file-name) (interactive) (let* ( - (file-path (or file-name buffer-file-name)) - (root-path (or (locate-dominating-file file-path ceedling-project-file-name) ceedling-project-root)) - ) + (file-path (or file-name buffer-file-name)) + (root-path (or (locate-dominating-file file-path ceedling-project-file-name) ceedling-project-root)) + ) (compile (concat "cd " root-path " && " ceedling-cmd) ) @@ -1128,8 +1127,8 @@ in a local directory (on Linux this is ~/.local/share/fonts). (let ((dir default-directory)) (dolist (buffer (buffer-list)) (with-current-buffer buffer - (when (equal default-directory dir) - (myrmi/reload-dir-locals-for-current-buffer)))))) + (when (equal default-directory dir) + (myrmi/reload-dir-locals-for-current-buffer)))))) #+END_SRC ** Visit/reload config From e6e5b5e4613ef26e5b7ca1378aa5ecbaa7218e26 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 11:52:38 +0200 Subject: [PATCH 13/19] feat: Remove org-roam-ui Not using it, so don't have it. --- config.org | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/config.org b/config.org index 0390fca..ea4587d 100644 --- a/config.org +++ b/config.org @@ -917,27 +917,6 @@ Preserve indentation in SRC blocks ) #+END_SRC -*** UI - -#+BEGIN_SRC emacs-lisp -(use-package org-roam-ui - :ensure - (:host github :repo "org-roam/org-roam-ui" :branch "main" :files ("*.el" "out")) - :after org-roam -;; normally we'd recommend hooking orui after org-roam, but since org-roam does not have -;; a hookable mode anymore, you're advised to pick something yourself -;; if you don't care about startup time, use -;; :hook (after-init . org-roam-ui-mode) - :config - (setq org-roam-ui-sync-theme t - org-roam-ui-follow t - org-roam-ui-update-on-save t - org-roam-ui-open-on-start t) - ;; Start UI - ;; (org-roam-ui-mode) - ) -#+END_SRC - *** Consult #+BEGIN_SRC emacs-lisp From 3591e5704e7f4b4645d0f4d5369325dd80ac7368 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 12:01:17 +0200 Subject: [PATCH 14/19] fix: remove/apply defer only where it makes sense :defer is to defer loading because some other action (hook/config/...) will load it when appropriate. --- config.org | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/config.org b/config.org index ea4587d..cecb401 100644 --- a/config.org +++ b/config.org @@ -77,7 +77,6 @@ The audible bell is annoying AF. #+BEGIN_SRC emacs-lisp (use-package whitespace :ensure nil - :defer t :hook (before-save-hook . whitespace-cleanup) ;; if we wanna remove this hook at any time, eval: ;; (remove-hook 'before-save-hook #'whitespace-cleanup) @@ -637,7 +636,6 @@ https://github.com/abo-abo/hydra #+BEGIN_SRC emacs-lisp (use-package hydra - :defer t :config ;; Zoom hydra (defhydra hydra-zoom (global-map "") @@ -726,7 +724,9 @@ https://github.com/victorhge/iedit ** Markdown-mode #+BEGIN_SRC emacs-lisp -(use-package markdown-mode) +(use-package markdown-mode + :defer t +) #+END_SRC @@ -790,6 +790,7 @@ Move to the end if the compilation finishes. #+BEGIN_SRC emacs-lisp (use-package rust-mode + :defer t :init (setq rust-mode-treesitter-derive t)) #+END_SRC @@ -797,13 +798,17 @@ Move to the end if the compilation finishes. ** Zig #+BEGIN_SRC emacs-lisp -(use-package zig-mode) +(use-package zig-mode + :defer t + ) #+END_SRC ** Python #+BEGIN_SRC emacs-lisp -(use-package python-mode) +(use-package python-mode + :defer t + ) #+END_SRC * Multiple cursors @@ -896,6 +901,8 @@ Preserve indentation in SRC blocks #+BEGIN_SRC emacs-lisp (use-package org-bullets + :defer t + :after org :config (add-hook 'org-mode-hook (lambda () (org-bullets-mode)))) #+END_SRC @@ -904,6 +911,8 @@ Preserve indentation in SRC blocks #+BEGIN_SRC emacs-lisp (use-package org-roam + :defer t + :after org :custom (org-roam-directory "~/projects/notes") (org-roam-completion-everywhere t) @@ -957,6 +966,8 @@ Preserve indentation in SRC blocks #+BEGIN_SRC emacs-lisp (use-package org-download + :defer t + :after org :config (add-hook 'dired-mode-hook 'org-download-enable) ) From c809f480bd08d05413ac8f36d817f7e20d7ce536 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 12:02:27 +0200 Subject: [PATCH 15/19] fix: load theme after it is actually loaded, not at init time --- config.org | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config.org b/config.org index cecb401..d19c937 100644 --- a/config.org +++ b/config.org @@ -616,8 +616,7 @@ For the keybindings, we have to defien them in both raw and line mode. From the #+BEGIN_SRC emacs-lisp (use-package monokai-theme - - :init + :config (load-theme 'monokai t) ) #+END_SRC From 28b6168110e36e3b4122590d3cbb023c3a975e92 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 12:03:05 +0200 Subject: [PATCH 16/19] fix: refeactor electric pair It's a built-in package, so we can provide a proper configuration section using use-package. --- config.org | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config.org b/config.org index d19c937..7af261e 100644 --- a/config.org +++ b/config.org @@ -696,8 +696,12 @@ https://github.com/victorhge/iedit #+END_SRC ** Electric pair + #+BEGIN_SRC emacs-lisp -(add-hook 'prog-mode-hook 'electric-pair-mode) +(use-package elec-pair + :ensure nil + :defer t + :hook (prog-mode-hook . electric-pair-mode)) #+END_SRC ** Eglot From 980ce6750b0aceefba08c22a9203492d160bdabb Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 12:03:41 +0200 Subject: [PATCH 17/19] feat: Add paren package configuration show-paren-context-when-offscreen is handy to indicate when we are offscreen for a block of code --- config.org | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config.org b/config.org index 7af261e..994938c 100644 --- a/config.org +++ b/config.org @@ -704,6 +704,18 @@ https://github.com/victorhge/iedit :hook (prog-mode-hook . electric-pair-mode)) #+END_SRC +** Paren + +#+BEGIN_SRC emacs-lisp +(use-package paren + :ensure nil + :hook (after-init-hook . show-paren-mode) + :custom + (show-paren-delay 0) + (show-paren-style 'mixed) + (show-paren-context-when-offscreen t)) ;; show matches within window splits +#+END_SRC + ** Eglot #+BEGIN_SRC emacs-lisp From 015ed00b0f39fd2cad2abc440e7f4afc95050b70 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 12:04:47 +0200 Subject: [PATCH 18/19] feat: refactor org mode configuration Defer loading to speed up startup and combine all the configuration of org mode in the same block. org-ellipsis is newly added and gives some eye candy when org blocks are folded. --- config.org | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/config.org b/config.org index 994938c..eb1224f 100644 --- a/config.org +++ b/config.org @@ -877,26 +877,27 @@ https://github.com/remyferre/comment-dwim-2 (add-hook 'project-find-functions #'project-projectile) ) #+END_SRC - * Org ** General config -*** Super/Sub-scripts - -Use ={}= for subscripting: - -https://orgmode.org/manual/Subscripts-and-superscripts.html #+BEGIN_SRC emacs-lisp -(setq org-use-sub-superscripts '{}) -#+END_SRC - -*** Indentation - -Preserve indentation in SRC blocks - -#+BEGIN_SRC emacs-lisp -(setq org-src-preserve-indentation t) +(use-package org + :ensure nil + :defer t + :mode ("\\.org\\'" . org-mode) + :config + (setq + ;; Start collapsed for speed + org-startup-folded t + ;; Use ={}= for subscripting: https://orgmode.org/manual/Subscripts-and-superscripts.html + org-use-sub-superscripts '{} + ;; Preserve indentation in SRC blocks + org-src-preserve-indentation t + ) + ;; Ellipsis styling + (setq org-ellipsis " ▼ ") + (set-face-attribute 'org-ellipsis nil :inherit 'default :box nil)) #+END_SRC ** Org-todo From 6a57cbfd1f319404033ddd75311de56da4b35901 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 27 May 2025 12:46:43 +0200 Subject: [PATCH 19/19] feat: Add custom modeline --- config.org | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/config.org b/config.org index eb1224f..4a417e2 100644 --- a/config.org +++ b/config.org @@ -1002,6 +1002,36 @@ https://github.com/remyferre/comment-dwim-2 * Custom +** Modeline + +#+BEGIN_SRC emacs-lisp +(setq-default mode-line-format + '("%e" " " + ;; (:propertize " " display (raise +0.1)) ;; Top padding + ;; (:propertize " " display (raise -0.1)) ;; Bottom padding + (:propertize "𝝮 " face font-lock-keyword-face) + + (:propertize + ("" mode-line-mule-info mode-line-client mode-line-modified mode-line-remote mode-line-window-dedicated)) + + mode-line-frame-identification + mode-line-buffer-identification + " " + mode-line-position + mode-line-format-right-align + " " + (project-mode-line project-mode-line-format) + " " + (vc-mode vc-mode) + " " + mode-line-modes + mode-line-misc-info + mode-line-end-spaces) + project-mode-line t + mode-line-buffer-identification '(" %b") + mode-line-position-column-line-format '(" %l:%c")) +#+END_SRC + ** Org-roam Inspired by https://github.com/org-roam/org-roam/wiki/User-contributed-Tricks#filter-by-a-tag .