Files
2026-08-17 13:53:05 +01:00

71 KiB

My Emacs Config

This is my Emacs config. There are many like it, but this one is mine. According to my archive, it has been rewritten 10+ times since I wrote the first iteration in 2022. My general philosophy for this config is to not use external packages where the built in functionality is enough and any external packages used should follow the Emacs philosophy and design style and not duplicate functionality as much as reasonably possible. In this vein I use Eglot and Corfu instead of LSP-Mode and Company as an example of this philosophy. Not all code written in this configuration is my own, though most of it is, with the rest being made up of other people's configs, stack overflow snippets and code from various blog sites from other Emacs users including Xenodium, Xah Lee and System Crafters.

Bootstrap

Package Manager

Setup use-package and Melpa, the community Emacs package repository.

  (require 'package)
  (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  (package-initialize)

Native Compilation

Setup Native Compilation if available.

  (if (native-comp-available-p)
      (setq package-native-compile t))

Garbage Collection

Improve Emacs' garbage collection by increasing the garbage size and collecting when idle. Packages: gcmh by Andrea Corallo

  (use-package gcmh
    :ensure t
    :hook (after-init . gcmh-mode)
    :config
    (setq gcmh-high-cons-threshold (* 128 1024 1024)  ; 128MB
          gcmh-idle-delay 10
          gcmh-verbose nil))

Shell Path

Append to the exec-path variable paths that are set in the zsh shell.

  (use-package exec-path-from-shell
    :ensure t
    :config
    (setq exec-path-from-shell-shell-name "/bin/zsh"
          exec-path-from-shell-arguments '("-l" "-i" "-c"))
    (when (memq window-system '(mac ns x))
      (exec-path-from-shell-initialize)))

Custom File

Use a custom.el file instead of the init.el to store uncommitable, device-local changes.

  (setq custom-file (expand-file-name "custom.el" user-emacs-directory))

  (when (file-exists-p custom-file)
    (load custom-file))

File Hygiene

Store backups, autosaves and lockfiles in the .emacs.d directory.

  (let* ((backup-dir (expand-file-name "backups/" user-emacs-directory))
         (autosave-dir (expand-file-name "autosaves/" user-emacs-directory))
         (lock-dir (expand-file-name "lock/" user-emacs-directory)))
    (make-directory backup-dir t)
    (make-directory autosave-dir t)
    (make-directory lock-dir t)

    (setq backup-directory-alist `((".*" . ,(directory-file-name backup-dir)))
          auto-save-file-name-transforms `((".*" ,(directory-file-name autosave-dir) t))
          lock-file-name-transforms `((".*" ,(directory-file-name lock-dir) t))))

Suppress Noise

Don't show *Warnings* and *Compile-Log* buffers in a window.

  (add-to-list 'display-buffer-alist
               '("\\`\\*\\(Warnings\\|Compile-Log\\)\\*\\'"
                 (display-buffer-no-window)
                 (allow-no-window . t)))

MacOS

Settings specific for use on MacOS.

Disable Command Key

Disable the command key on MacOS.

  (setq mac-command-modifier nil)

Matching Titlebar

Match the titlebar to the current theme on MacOS. Packages: ns-auto-titlebar by Steve Purcell

  (use-package ns-auto-titlebar
    :ensure t
    :config
    (when (eq system-type 'darwin) (ns-auto-titlebar-mode)))

Block Pop-Ups

Don't open files opened from an external source in a new frame on MacOS.

  (setq ns-pop-up-frames nil)

Appearance

Cursor

Set the cursor to be a 2-width bar.

  (setq-default cursor-type '(bar . 2))

Theme

Use the ef-dream for a comfortable readable experience . Packages: ef-themes by Protesilaos

  (use-package ef-themes
    :ensure t
    :config
    (ef-themes-take-over-modus-themes-mode 1))

  (setq modus-themes-italic-constructs t
        modus-themes-bold-constructs t)

  (load-theme 'ef-elea-dark t)
  ;; (load-theme 'ef-kassio t)

Font Configuration

Setup both monospace and variable-pitch fonts along with their sizes in org-mode.

  (defun font-setup (&optional frame)
    (with-selected-frame (or frame (selected-frame))

      (let* ((fontconf '((fixed-font     . "Aporetic Sans Mono")
                         (variable-font  . "Aporetic Serif")
                         (fixed-size     . 16)
                         (variable-size  . 16)))
             (fixed-font     (cdr (assoc 'fixed-font fontconf)))
             (variable-font  (cdr (assoc 'variable-font fontconf)))
             (fixed-pt       (cdr (assoc 'fixed-size fontconf)))
             (variable-pt    (cdr (assoc 'variable-size fontconf)))
             (fixed-height   (* fixed-pt 10))
             (variable-height (* variable-pt 10))
             (frame-font     (concat fixed-font "-" (number-to-string fixed-pt))))
        
        ; Fixed-width faces (Size: 18)
        (dolist (face '(default fixed-pitch))
          (set-face-attribute face nil
                              :font fixed-font
                              :height fixed-height
                              :weight 'regular))
        
        ; Variable-pitch face (Size: 16)
        (set-face-attribute 'variable-pitch nil
                            :font variable-font
                            :height variable-height
                            :weight 'regular)

        ; Syntax styling
        (set-face-attribute 'font-lock-comment-face nil :slant 'italic)
        (set-face-attribute 'font-lock-keyword-face nil :slant 'italic)

        ; Frame font
        (add-to-list 'default-frame-alist `(font . ,frame-font)))

      
      (let* ((variable-tuple
              (cond ((x-list-fonts "Google Sans")  '(:font "Google Sans"))
                    ((x-family-fonts "Sans Serif") '(:family "Sans Serif"))
                    (nil (warn "Cannot find a Sans Serif Font. Install Google Sans."))))
             (base-font-color (face-foreground 'default nil 'default))
             (headline `(:inherit default :weight bold :foreground ,base-font-color)))

        ; TODO: Split these up
        (custom-theme-set-faces
         'user
         `(org-level-8 ((t (,@headline ,@variable-tuple))))
         `(org-level-7 ((t (,@headline ,@variable-tuple))))
         `(org-level-6 ((t (,@headline ,@variable-tuple))))
         `(org-level-5 ((t (,@headline ,@variable-tuple))))
         `(org-level-4 ((t (,@headline ,@variable-tuple :height 1.0))))
         `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.2))))
         `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.4))))
         `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.6))))
         `(org-document-title ((t (,@headline ,@variable-tuple :height 1.8 :underline nil))))))))

  (if (daemonp)
      (add-hook 'after-make-frame-functions #'font-setup)
    (font-setup))

  ; Theme the fonts and styles for various org elements
  (custom-theme-set-faces
   'user
   '(org-block ((t (:inherit fixed-pitch))))
   '(org-code ((t (:inherit (shadow fixed-pitch)))))
   '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
   '(org-indent ((t (:inherit (org-hide fixed-pitch)))))
   '(org-link ((t (:foreground "#89b4fa" :underline t))))
   '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
   '(org-property-value ((t (:inherit fixed-pitch))) t)
   '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
   '(org-table ((t (:inherit fixed-pitch))))
   '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
   '(org-verbatim ((t (:inherit (shadow fixed-pitch))))))

Mode Line

Use a much more readable modeline compared to the default. Packages: doom-modeline from Centaur Emacs

  (use-package doom-modeline
    :ensure t
    :hook (after-init . doom-modeline-mode)
    :config
    (setq doom-modeline-icon t
          doom-modeline-height 0 ; minimum
          doom-modeline-bar-width 0 ; disabled
          doom-modeline-project-detection 'project ; use project.el
          doom-modeline-buffer-state-icon nil
          doom-modeline-highlight-modified-buffer-name nil
          doom-modeline-percent-position nil
          line-number-mode nil
          doom-modeline-buffer-encoding nil
          doom-modeline-time-live-icon nil
          doom-modeline-time-icon nil
          display-time-default-load-average nil
          display-time-format "%a %d %b | %R"
          helm-ag-show-status-function nil)) ;HACK: Doom Modeline checks for this even though I don't use helm

Icons

Make use of the Nerd Fonts to show icons in Emacs. Packages: nerd-icons, nerd-icons-dired and nerd-icons-completion by Daniel Ding and nerd-icons-ibuffer from Centaur Emacs

  (use-package nerd-icons
    :ensure t
    :if (display-graphic-p))

  (use-package nerd-icons-dired
    :ensure t
    :after nerd-icons
    :hook
    (dired-mode . nerd-icons-dired-mode))

  (use-package nerd-icons-completion
    :ensure t
    :after nerd-icons
    :hook
    (after-init . nerd-icons-completion-mode))

  (use-package nerd-icons-ibuffer
    :ensure t
    :after nerd-icons
    :hook (ibuffer-mode . nerd-icons-ibuffer-mode))

Padding and Spacing

Spacious user interface elements with custom widths and colours. Packages: spacious-padding by Protesilaos

  (use-package spacious-padding
    :ensure t
    :hook (after-init . spacious-padding-mode)
    :config
    (setq spacious-padding-widths
          '( :internal-border-width 8
             :header-line-width 4
             :mode-line-width 6
             :custom-button-width 3
             :tab-width 4
             :right-divider-width 30
             :scroll-bar-width 8
             :fringe-width 0))
    (setq spacious-padding-subtle-frame-lines
        '( :mode-line-active spacious-padding-line-active
           :mode-line-inactive spacious-padding-line-inactive
           :header-line-active spacious-padding-line-active
           :header-line-inactive spacious-padding-line-inactive)))

Highlight Changes

Temporarily highlight modified regions to help the visual transition when making large changes via undo or kill-region. Packages: goggles by Daniel Mendler

  (use-package goggles
    :ensure t
    :hook ((prog-mode text-mode) . goggles-mode)
    :config
    (setq-default goggles-pulse t))

Highlight Keywords

Highlight actionable keywords such as TODO, FIXME and ERROR. Packages: hl-todo by Jonas Bernoulli

  (use-package hl-todo
    :ensure t
    :hook ((org-mode . hl-todo-mode)
           (prog-mode . hl-todo-mode))
    :config
    (add-to-list 'hl-todo-keyword-faces '("ERROR" . "#8c5353")))

Highlight and Dim Parentheses

For lisp modes, highlight parentheses that are local to the current point with decreasing brightness the less local they are, and set all parentheses to be dim in these modes by default. Packages: highlight-parentheses by Tassilo Horn

  (use-package highlight-parentheses
    :ensure t
    :custom (hl-paren-background-colors '(nil nil nil nil nil))
    :config (set-face-attribute 'hl-paren-face nil :weight 'bold))

  (defface dim-parens-face '((t :foreground "gray50")) "Dimmed parens.")

  (defun dim-parens--lerp (frac)
    (cl-destructuring-bind (br bg bb) (color-name-to-rgb (face-attribute 'default :background nil t))
      (cl-destructuring-bind (fr fg fb) (color-name-to-rgb (face-attribute 'default :foreground nil t))
        (format "#%02x%02x%02x"
                (round (* 255 (+ br (* frac (- fr br)))))
                (round (* 255 (+ bg (* frac (- fg bg)))))
                  (round (* 255 (+ bb (* frac (- fb bb)))))))))

  (defun dim-parens--apply-colors ()
    (setq hl-paren-colors (mapcar #'dim-parens--lerp '(1.0 0.75 0.55 0.4 0.3)))
    (set-face-attribute 'dim-parens-face nil :foreground (dim-parens--lerp 0.25)))

  (defun dim-parens--enable ()
    (dim-parens--apply-colors)
    (font-lock-add-keywords nil '(("[()]" 0 'dim-parens-face t)) 'append)
    (font-lock-flush)
    (highlight-parentheses-mode 1))

  (defun dim-parens--disable ()
    (font-lock-remove-keywords nil '(("[()]" 0 'dim-parens-face t)))
    (font-lock-flush)
    (highlight-parentheses-mode -1))

  (define-minor-mode dim-parens-mode "Dim all parens, highlighting enclosing pair."
    :lighter " DimP"
    (if dim-parens-mode (dim-parens--enable) (dim-parens--disable)))

  (add-hook 'enable-theme-functions (lambda (_) (dim-parens--apply-colors)))

Pretty Symbols

Shorten symbols into their single character equivalent.

  (global-prettify-symbols-mode 1)

Window Focus Flash

Flash between windows when switching to make obvious which window is active. Packages: winpulse by Álvaro Ramírez (Xenodium)

  (use-package winpulse
    :vc (:url "https://github.com/xenodium/winpulse"
         :rev :newest)
    :config
    (winpulse-mode +1))

Startup

Startup screen for Emacs with helpful quick links. Packages: dashboard by The Emacs Dashboard Maintainers

  (use-package dashboard
    :ensure t
    :custom
    (dashboard-center-content t)
    (dashboard-show-shortcuts nil)
    (dashboard-display-icons-p t)
    (dashboard-icon-type 'nerd-icons)
    (dashboard-set-file-icons t)
    (dashboard-footer-icon "")
    (dashboard-recentf-show-base t)
    (dashboard-recentf-item-format "%s")
    (dashboard-projects-show-base t)
    (dashboard-projects-item-format "%s")
    (dashboard-startupify-list '(dashboard-insert-banner
                                 dashboard-insert-newline
                                 dashboard-insert-init-info
                                 dashboard-insert-items
                                 dashboard-insert-newline
                                 dashboard-insert-footer))
    (dashboard-items '((recents   . 5)
                       (projects  . 5)
                       (agenda    . 5)))
    :config
    (dashboard-setup-startup-hook))

  (defun dashboard-dynamic-title ()
    (let* ((day-num (string-to-number (format-time-string "%d")))
           (suffix (let ((mod10 (% day-num 10))
                         (mod100 (% day-num 100)))
                     (cond
                      ((memq mod100 '(11 12 13)) "th")
                      ((= mod10 1) "st")
                      ((= mod10 2) "nd")
                      ((= mod10 3) "rd")
                      (t "th"))))
           (month (format-time-string "%B"))
           (hour (string-to-number (format-time-string "%H")))
           (time-phrase (cond
                         ((and (>= hour 5)  (< hour 9))  "start your day with some")
                         ((and (>= hour 9)  (< hour 11)) "a long day ahead for")
                         ((and (>= hour 11) (< hour 19)) "it's a perfect time for")
                         ((and (>= hour 19) (< hour 22)) "end your day with some")
                         t                               "it's never too late for")))
      (format "Today is the %d%s of %s, %s Emacs!" day-num suffix month time-phrase)))

  ;(setq dashboard-banner-logo-title (dashboard-dynamic-title))
  (setq dashboard-init-info (dashboard-dynamic-title))


  (add-hook 'dashboard-mode-hook (lambda () (setq-local mode-line-format nil)))

UI Behaviour

Frame and Window

Resize GUI

Allow any size to be set for the Emacs GUI.

  (setq frame-resize-pixelwise t)

Focus Frames

Focus new frames when they're created.

  (add-hook 'after-make-frame-functions
            (lambda (f)
              (select-frame-set-input-focus f)))

Disable Default Annoyances

Disable the Bell and other unwanted GUI features.

  (setq ring-bell-function 'ignore)

  (tool-bar-mode -1)
  (scroll-bar-mode -1)
  ;(menu-bar-mode -1)

  ;(add-to-list 'default-frame-alist '(undecorated . t))

Line Numbers

Configure line numbers display width and resizing, and display them from startup unless in fundamental-mode or text-mode.

  (setq display-line-numbers-width-start t
        display-line-numbers-width 4
        display-line-numbers-grow-only t)

  (global-display-line-numbers-mode 1)

  (dolist (hk '(fundamental-mode-hook text-mode-hook Info-mode-hook))
    (add-hook hk (lambda () (display-line-numbers-mode -1))))

  (add-hook 'doc-view-mode-hook #'(lambda ()
                                    (display-line-numbers-mode -1)))

Scrolling

Add a scroll margin and improve scrolling.

  (setq scroll-margin 10
        scroll-conservatively 100
        scroll-step 1)

Line Wrapping

Set the default to not wrap long lines but truncate with spaces. Enable it explicitly in text-mode.

  (setq-default truncate-lines t)

  (set-display-table-slot standard-display-table 'truncation 32)

  (add-hook 'text-mode-hook 'visual-line-mode)

Keybinding Help

Enable which-key on startup.

  (add-hook 'emacs-startup-hook #'which-key-mode)

Compilation

Configure compile-mode by colourising it, having it scroll on compilation output and allow files and projects to set their own compile-commands.

  (require 'ansi-color)

  (defun colorize-compilation-buffer ()
    (ansi-color-apply-on-region compilation-filter-start (point)))
  (add-hook 'compilation-filter-hook 'colorize-compilation-buffer)

  (setq compilation-scroll-output t)

  (put 'compile-command 'safe-local-variable #'stringp)

Zen Mode

Centre the buffer and disable line numbers for a calmer writing experience. Packages: olivetti by Paul W. Rankin

  (use-package olivetti
    :ensure t
    :config
    ; TODO: Disable line numbers, probably in the line numbers section, but probably try and link the sections somehow
    (setq olivetti-minimum-body-width 100))

Editing Behaviour

Indentation

Indent code with 2 spaces by default.

  (setq-default indent-tabs-mode nil
                tab-width 2
                tab-stop-list (number-sequence 2 100 2)
                c-basic-offset 2)

Smart Line Beginning

Override the built-in beginning-of-line function to give respect to context when making the movement.

  (progn
    (defun smart-beginning-of-line ()
      "Move the cursor to the beginning of text on the line."
      (interactive)
      (let ((initial-point (point)))
        (back-to-indentation)
        (when (eq initial-point (point))
          (move-beginning-of-line 1))))
    (defun setup-prog-mode-c-a ()
      (local-set-key (kbd "C-a") 'smart-beginning-of-line))
    (add-hook 'prog-mode-hook 'setup-prog-mode-c-a)
    (add-hook 'conf-mode-hook 'setup-prog-mode-c-a))

Open Line

Functions to match vi's 'o' and 'O' motions, this helps to bypass whatever function is called on the Return key.

  (cl-labels
      ((vi-open-line-above ()
         "Open line above the current line."
         (interactive)
         (unless (bolp) (beginning-of-line))
         (newline)
         (forward-line -1)
         (indent-according-to-mode))
       (vi-open-line-below ()
         "Open line below the current line."
         (interactive)
         (unless (eolp) (end-of-line))
         (newline-and-indent)))
    ; TODO: Move to keybindings section
    (define-key (current-global-map) (kbd "C-c o") #'vi-open-line-above)
    (define-key (current-global-map) (kbd "C-c O") #'vi-open-line-below)
    (which-key-add-key-based-replacements "C-c o" "open-line-above")
    (which-key-add-key-based-replacements "C-c O" "open-line-below"))

Replace Selection

Overwrite selection when typing while a selection is active.

  (use-package delsel
      :hook (after-init . delete-selection-mode))

Trailing Whitespace

Clean up trailing whitespace on save.

  (progn
    (defun prog-nuke-trailing-whitespace ()
      "Removes trailing whitespace at the end of the line."
      (when (or (derived-mode-p 'prog-mode) (derived-mode-p 'conf-mode))
        (delete-trailing-whitespace)))
    (add-hook 'before-save-hook 'prog-nuke-trailing-whitespace))

Move Lines

Move text up and down with a single keybind. Packages: move-text by Jason Milkins at Emacs Fodder

  (use-package move-text
    :ensure t
    :config
    (defun indent-region-advice (&rest ignored)
      (let ((deactivate deactivate-mark))
        (if (region-active-p)
            (indent-region (region-beginning) (region-end))
          (indent-region (line-beginning-position) (line-end-position)))
        (setq deactivate-mark deactivate)))

    (advice-add 'move-text-up :after 'indent-region-advice)
    (advice-add 'move-text-down :after 'indent-region-advice))

Delimiter Pairing

Insert matching delimiters using the keybindings from paredit. Packages: smartparens by Matus Goljer

  (use-package smartparens
    :ensure t
    :hook (prog-mode text-mode markdown-mode comint-mode)
    :config
    (require 'smartparens-config)
    (sp-use-paredit-bindings))

Undo History

Make the undo history persistent between sessions and create multi-branch undo history. Packages: undo-tree by Tony 'qubit' Cubitt

  (use-package undo-tree
    :ensure t
    :init
    (global-undo-tree-mode 1)
    :config
    (setq undo-tree-auto-save-history t
          undo-tree-history-directory-alist `(("." . ,(expand-file-name ".cache" user-emacs-directory)))))

Short Answers

Use y / n and other similar shortenings for dialogue responses.

  (setopt use-short-answers t)

Quit Confirmation

Ask for confirmation on C-x C-c before quitting using custom quit messages from the DOOM games and DOOM Emacs.

  (setq quit-messages
          `(; from DOOM 1
            ,(format "I wouldn't leave if I were you. %s is much worse."
                     (if (featurep 'windows-nt) "DOS" "UNIX"))
            "Ya know, next time you come in here I'm gonna toast ya."
            "Go ahead and leave. See if I care."
            "Are you sure you want to quit this great editor?"
            ; from DOOM 2
            "Get outta here and go back to your boring programs."
            "Just leave. When you come back, I'll be waiting with a bat."
            "You're lucky I don't smack you for thinking about leaving. "
            ; from DOOM Emacs
            "(setq nothing t everything 'permitted)"
            "Emacs will remember that."
            "Emacs, Emacs never changes."
            "Hey! Hey, M-x listen!"
            "Wake up, Mr. Stallman. Wake up and smell the ashes."
            "You are *not* prepared!"
            "Please don't go. The drones need you. They look up to you."))

  (defun random-quit-message ()
    "Return a randomly chosen quit message from `quit-messages'."
    (nth (random (length quit-messages)) quit-messages))

  (defun message-confirm-kill-emacs (&rest _)
    "Prompt the user with a random message before quitting.
  Returns t to allow kill if the user answers yes; nil otherwise."
    (let* ((msg (random-quit-message))
           (prompt (format "%s  Really quit Emacs? " msg)))
      (yes-or-no-p (propertize prompt 'face '(italic default)))))

  (setq confirm-kill-emacs #'message-confirm-kill-emacs)

Session and Navigation

Recent Files

Keep track of recently accessed files with recentf.

  (add-hook 'emacs-startup-hook #'recentf-mode)

Save Position

Save the location of the cursor in files between sessions.

  (add-hook 'emacs-startup-hook #'save-place-mode)

Minibuffer History

Save the minibuffer history between sessions.

  (use-package savehist
    :hook (after-init . savehist-mode))

Dired

Configure dired-mode so that directories are always copied and deleted recursively, target's for functions are intuited and all files are listed and display human readable metadata. Allow recursive expansion with TAB to easily travel directories. Packages: dired-subtree by Matus Goljer

  (use-package dired
    :commands (dired)
    :hook
    ((dired-mode . dired-hide-details-mode)
     (dired-mode . hl-line-mode))
    :config
    (setq insert-directory-program "gls"
          dired-recursive-copies 'always
          dired-recursive-deletes 'always        
          dired-dwim-target t
          dired-listing-switches "-lah"))

  (use-package dired-subtree
    :ensure t
    :after dired
    :bind
    (:map dired-mode-map
          ("TAB" . (lambda () (interactive) (dired-subtree-toggle) (revert-buffer)))
          ("<backtab>" . dired-subtree-remove))
    :config
    (setq dired-subtree-use-backgrounds nil))

Buffer List

Group project.el projects together in the ibuffer. Packages: ibuffer-project by Andrii Kolomoiets

  (use-package ibuffer-project
    :ensure t
    :after project
    :config
    (add-hook
     'ibuffer-hook
     (lambda ()
       (setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups))
       (unless (eq ibuffer-sorting-mode 'project-file-relative)
         (ibuffer-do-sort-by-project-file-relative)))))

Project Management

A transient menu interface for project.el. Packages: disproject by aurtzy

  (use-package disproject
    :ensure t
    :after project)

EShell

Setup the eshell prompt to be both visually appealing and useful.

  (progn ; TODO: Fix this, as is likely completely broken (No Colour)
    (dolist (spec
           '((eshell-prompt-user-face        font-lock-keyword-face   "Face for the username in the eshell prompt.")
             (eshell-prompt-venv-face        font-lock-string-face    "Face for the virtualenv name in the eshell prompt.")
             (eshell-prompt-dir-face         dired-directory          "Face for the directory path in the eshell prompt.")
             (eshell-prompt-git-face         bookmark-face            "Face for the git branch in the eshell prompt.")
             (eshell-prompt-git-dirty-face   bookmark-face            "Face for the git dirty status in the eshell prompt.")
             (eshell-prompt-symbol-face      font-lock-builtin-face   "Face for the prompt symbol in the eshell prompt.")))
    (cl-destructuring-bind (name inherit doc) spec
      (custom-declare-face name
        `((t (:inherit ,inherit)))
        doc
        :group 'eshell-prompt)))

    (defun eshell-abbreviate-dir (dir)
      "Abbreviate directory to show only the first and the last two components."
      (let* ((abbrev (abbreviate-file-name dir))
             (components (split-string abbrev "/" t))
             (num-components (length components)))
        (if (>= num-components 4)
            (concat (car components) "/.../"
                    (mapconcat #'identity (last components 2) "/"))
          abbrev)))

    (defun eshell-prompt-git-branch ()
      "Return the current git branch or short commit hash, if available."
      (when (and (executable-find "git")
                 (locate-dominating-file default-directory ".git"))
        (with-temp-buffer
          (let ((ret (call-process "git" nil t nil "symbolic-ref" "--short" "HEAD")))
            (if (zerop ret)
                (string-trim (buffer-string))
              (when (zerop (call-process "git" nil t nil "rev-parse" "--short" "HEAD"))
                (string-trim (buffer-string))))))))

    (defun eshell-prompt-git-dirty ()
      "Return a dirty flag (✗ if dirty, ✓ if clean) for the git repository."
      (when (eshell-prompt-git-branch)
        (with-temp-buffer
          (call-process "git" nil t nil "status" "--porcelain")
          (if (> (buffer-size) 0) "✗" "✓"))))

    (defun eshell-prompt ()
      "Custom eshell prompt."
      (let* ((user (propertize (user-login-name) 'face 'eshell-prompt-user-face))
             (venv (when-let ((venv (getenv "VIRTUAL_ENV")))
                     (concat (propertize "(" 'face 'eshell-prompt-venv-face)
                             (propertize (file-name-nondirectory venv) 'face 'eshell-prompt-venv-face)
                             (propertize ")" 'face 'eshell-prompt-venv-face))))
             (path (propertize (eshell-abbreviate-dir (eshell/pwd)) 'face 'eshell-prompt-dir-face))
             (git-branch (eshell-prompt-git-branch))
             (git-info (when git-branch
                         (concat " " (propertize "on" 'face 'font-lock-number-face) " "
                                 (propertize git-branch 'face 'eshell-prompt-git-face)
                                 (propertize (eshell-prompt-git-dirty) 'face 'eshell-prompt-git-dirty-face))))
             (prompt (concat user " " (propertize "in" 'face 'font-lock-number-face) " "
                             (if venv (concat venv " ") "")
                             path git-info "\n"
                             (propertize "λ" 'face 'eshell-prompt-symbol-face) " ")))
        prompt))

    (setq eshell-prompt-function 'eshell-prompt
          eshell-prompt-regexp "^[^λ\n]*λ "))

Info Pages

Configuration for Info-mode to set the location for local info files.

  (add-to-list 'Info-directory-list (expand-file-name "~/Documents/Info/"))

EWW

  (add-hook 'eww-mode-hook #'(lambda () (display-line-numbers-mode -1)))

XWWP

Follow links in the webkit browser within emacs using xwidget-webkit Packages: xwwp by Damien Merenne

  (use-package xwwp
    :vc (:url "https://github.com/canatella/xwwp" :rev :newest)
    :ensure t
    :config
    (xwwp-follow-link-completion-system 'consult)
    (defun consult-xwwp-follow-link--preview (candidates update-fn)
    "Create preview function for xwwp links CANDIDATES by calling UPDATE-FN."
    (lambda (action cand)
      (when (and (eq action 'preview) cand)
        (let* ((selected cand)
               (rest (seq-filter (lambda (c) (not (eq c selected))) candidates))
               (xwwp-follow-link-consult-candidates (cons selected rest)))
          (funcall update-fn)))))
    (defun xwwp-follow-link-consult-lookup (selected candidates _input _narrow)
    "Lookup SELECTED in CANDIDATES."
    (seq-find (lambda (c) (string= (car c) selected)) candidates))
    :init
    (require 'xwwp-follow-link-consult)
    :bind (:map xwidget-webkit-mode-map
           ("f" . xwwp-follow-link)))

Ollama

Interface with a local llm from ollama. Packages: ellama by Sergey Kostyaev

  (use-package ellama
    :ensure t
    :hook (org-ctrl-c-ctrl-c-hook . ellama-chat-send-last-message)
    :init (setopt ellama-auto-scroll t))

Email

Manage email from within Emacs. Packages: mu4e by Dirk-Jan Binnema

  (add-to-list 'load-path "/opt/homebrew/share/emacs/site-lisp/mu/mu4e")
  (use-package mu4e
    :ensure nil
    :custom
      (user-full-name "Stefan Roche")
      (user-mail-address "stefanroche@protonmail.com")
      (mu4e-maildir "~/.maildir/protonmail")
      (mu4e-change-filenames-when-moving t)
      (mu4e-drafts-folder "/Drafts")
      (mu4e-sent-folder "/Sent")
      (mu4e-refile-folder "/Archive")
      (mu4e-trash-folder "/Trash")
      (mu4e-get-mail-command "mbsync protonmail")
      (mu4e-update-interval 300)
      (mu4e-view-show-images t)
      (mu4e-headers-auto-update t)
      (mu4e-html2text-command "w3m -T text/html")
      (mu4e-attachment-dir "~/Downloads")
      (mu4e-index-cleanup t)
      (mu4e-index-lazy-check nil)
      (mu4e-headers-fields
       '((:from-or-to   . 22)
         (:subject      . 60)
         (:human-date   . 12)
         (:flags        . 6)
         (:mailing-list . 10)))
      (mu4e-maildir-shortcuts
       '(("/Inbox" . ?i)
         ("/Archive" . ?a)
         ("/Sent" . ?s)
         ("/Spam" . ?x)))
      (setq mu4e-bookmarks '(()))
    :config
    (add-to-list 'gnutls-trustfiles
                 (expand-file-name "~/.maildir/certificates/cert.pem"))
    (mu4e-modeline-mode -1))

  (dolist (hook '(mu4e-main-mode-hook
                  mu4e-headers-mode-hook
                  mu4e-view-mode-hook
                  mu4e-compose-mode-hook))
    (add-hook hook (lambda () (display-line-numbers-mode -1))))

  (use-package smtpmail-multi
    :ensure t
    :custom
    (send-mail-function 'smtpmail-send-it)
    (message-send-mail-function 'smtpmail-send-it)
    (smtpmail-smtp-server "127.0.0.1")
    (smtpmail-smtp-service 1025)
    (smtpmail-stream-type 'ssl)
    (smtpmail-auth-credentials "~/.authinfo"))

Feeds

Read and tag RSS feeds. Packages: elfeed by Daniel Mendler

  (use-package elfeed
    :ensure t
    :custom
    ; Open URLs using the internal xwidget webkit browser
    (browse-url-browser-function 'xwidget-webkit-browse-url)
    ; Disable read-unread feature
    (elfeed-initial-tags '())
    (elfeed-search-filter "@6months")
    :config
    (setq elfeed-feeds
            ; Websites
          '(("https://hnrss.org/best" computing social)
            ("https://protesilaos.com/master.xml" computing blog)
            ("https://feeds.bbci.co.uk/news/rss.xml" news uk)
            ; Reddit
            ("https://old.reddit.com/r/goodnewsuk.rss" news uk social)
            ("https://old.reddit.com/r/emacs.rss" computing social)
            ("https://old.reddit.com/r/lua.rss" computing social)
            ; Youtube
            ("https://www.youtube.com/feeds/videos.xml?channel_id=UC0uTPqBCFIpZxlz_Lv1tk_g" computing youtube)
            ("https://www.youtube.com/feeds/videos.xml?channel_id=UCj1_pZ7vmxnhy5clIcMVJtg" news uk youtube)
            ("https://www.youtube.com/feeds/videos.xml?channel_id=UCEbYhDd6c6vngsF5PQpFVWg" computing youtube)
            ("https://www.youtube.com/feeds/videos.xml?channel_id=UCdT68dsulMFouI2InvXWM5w" computing youtube)))
    (dolist (hook '(elfeed-search-mode-hook
                    elfeed-tree-mode-hook
                    elfeed-show-mode-hook))
      (add-hook hook (lambda () (display-line-numbers-mode -1))))
      (set-face-attribute 'elfeed-search-title-face nil :inherit 'elfeed-search-unread-title-face))

Completion and LSP

Completion Style

Make completion matching much more powerful. Packages: orderless by Omar Antolín Camarena

  (use-package orderless
    :ensure t
    :config
    (setq completion-styles '(orderless basic)
          completion-category-defaults nil
          completion-category-overrides '((file (styles . (partial-completion)))
                                          (eglot (styles . (orderless))))))

Minibuffer Completion

Enable powerful minibuffer completion with fuzzy finding. Packages: vertico by Daniel Mendler

  (use-package vertico
    :ensure t
    :hook (after-init . vertico-mode)
    :bind (:map vertico-map
                ("DEL" . vertico-directory-delete-char)))

Floating Minibuffer

Float the minibuffer in a posframe in the centre of the screen. Packages: vertico-posframe by tumashu

  (use-package vertico-posframe
    :ensure t
    :config
    (vertico-posframe-mode 1))

Completion Annotations

Give completions annotations to describe what a function does. Packages: marginalia by Daniel Mendler

  (use-package marginalia
    :ensure t
    :after vertico consult nerd-icons
    :hook
    ((emacs-startup . marginalia-mode)))
    ;(marginalia-mode . nerd-icons-completion-marginalia-setup)))

Consult

These packages provide replacements for built-in emacs functions that have support for completion. Packages: consult by Daniel Mendler and affe also by Daniel Mendler

  (use-package consult
    :ensure t)

  (use-package affe
    :ensure t
    :after consult)

In-Buffer Completion

Lightweight completion popup package for an improved auto-completion experience along with Nerd Font icons for symbol representation. Packages: corfu by Daniel Mendler and nerd-icons-corfu by Luigi Sartor Piucco

  (use-package corfu
    :ensure t
    :hook (prog-mode eshell-mode markdown-mode comint-mode)
    :bind (:map corfu-map
                ("TAB" . corfu-insert)
                ("<tab>" . corfu-insert)
                ("RET" . nil)
                ("C-n" . corfu-next)
                ("C-p" . corfu-previous)
                ("C-g" . corfu-quit))
    :config
    (setq corfu-cycle t
          corfu-auto t
          corfu-auto-delay 0.2
          corfu-preselect 'first
          corfu-quit-at-boundary t
          corfu-quit-no-match t
          corfu-scroll-margin 5
          corfu-tab-always-indent 'complete
          corfu-preview-current nil
          corfu-min-width 20
          corfu-popupinfo-delay '(1.25 . 0.5)
          corfu-on-exact-match nil)
    (corfu-popupinfo-mode 1)
    (with-eval-after-load 'savehist
      (corfu-history-mode 1)
      (add-to-list 'savehist-additional-variables 'corfu-history)))

  (use-package nerd-icons-corfu
    :ensure t
    :after nerd-icons corfu
    :config
    (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))

Snippets

Snippet expansion with powerful multi-stage completion along with a collection of common snippets. Packages: yasnippet by João Távora and yasnippet-snippets by Andrea Crotti

  (use-package yasnippet
    :ensure t
    :hook (prog-mode . yas-minor-mode)
    :config
    (yas-reload-all))

  (use-package yasnippet-snippets
    :after yasnippet
    :ensure t)

Completion Extensions

Use cape to provide completion-at-point extensions. Packages: cape by Daniel Mendler

  (use-package cape
    :ensure t
    :config
    ; TODO find out what the wrap buster actually does (caching or whatever)
    (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster))

YASnippet Capf

Display yasnippet in completions. Packages: yasnippet-capf by Ellis Kenyő

  (use-package yasnippet-capf
    :ensure t
    :after cape)

Eglot and YASnippet - Together At Last!

Combine eglot and yasnippet into a combined completion function.

  (defun eglot-capf-with-yasnippet ()
    (setq-local completion-at-point-functions
                (list
                 (cape-capf-super
                  #'eglot-completion-at-point
                  #'yasnippet-capf))))
  (with-eval-after-load 'eglot
    (add-hook 'eglot-managed-mode-hook #'eglot-capf-with-yasnippet))

LSP Client

Use eglot as a lightweight interface for LSP servers to enable smart completion, diagnostics and much more within Emacs. Packages: eglot by João Távora

  (use-package eglot
    :ensure t
    :after cape
    :config
    ; Disable progress indicator in the modeline
    (setq eglot-report-progress nil
          eglot-extend-to-xref t))

Consult Integration

Jump to workspace symbols from the LSP with a consult interface. Packages: consult-eglot by Mohsin Kaleem

  (use-package consult-eglot
    :ensure t
    :after consult eglot)

LSP Booster

Use a rust-powered booster to communicate more efficiently between Emacs and the LSP server. The booster can be downloaded from Yikai Zhao. Packages: eglot-booster by JD Smith

  (use-package eglot-booster
    :vc (:url "https://github.com/jdtsmith/eglot-booster.git")
    :ensure t
  	:after eglot
  	:config
    ; Use emacs-30's built in JSON handler
    (setq eglot-booster-io-only t)
    (eglot-booster-mode))

LSP Transient Menu

A menu for eglot and related functions for easy access.

  (require 'transient)
  (transient-define-prefix eglot-transient ()
    "Transient menu for Eglot."
    [["Server"
      ("c" "Reconnect" eglot-reconnect)
      ("C" "Shutdown" eglot-shutdown)
      ("I" "Server Info" eglot-show-workspace-configuration)]
     ["Navigation"
      ("g" "Go to Definition" xref-find-definitions)
      ("d" "Describe Thing at Point" eldoc-box-help-at-point)
      ("D" "Go to Declaration" eglot-find-declaration)
      ("i" "Go to Implementation" eglot-find-implementation)
      ("f" "Find References" xref-find-references)
      ("t" "Type Definition" eglot-find-typeDefinition)
      ("s" "Search Symbols"
       (lambda ()
         (interactive)
         (if (eq major-mode 'java-mode)
             (call-interactively 'consult-eglot-jdt-symbols)
           (call-interactively 'consult-eglot-symbols))))]
     ["Code Actions"
      ("a" "Code Actions" eglot-code-actions)
      ("q" "Quick Fix" eglot-code-action-quickfix)
      ("=" "Format Buffer" eglot-format-buffer)
      ("o" "Organize Imports" eglot-code-action-organize-imports)
      ("r" "Rename Symbol" eglot-rename)]
     ["Diagnostics"
      ("l" "List Diagnostics" flycheck-list-errors)
      ("L" "Project Diagnostics" flymake-show-project-diagnostics)]]
    (interactive)
     (transient-setup 'eglot-transient))

Documentation Popups

View documentation with eldoc in a popup, correctly syntax highlighted in markdown and limited to only use eglot when available. Packages: eldoc-box by Yuan Fu and markdown-mode by Jason Blevins

  (use-package markdown-mode
    :ensure t)

  (use-package eldoc-box
    :ensure t)
  ; Follow markdown links inside eldoc boxes on selection
  (defun markdown-follow-help-or-link-at-point-advice (orig-fun &rest args)
    "Prefer to use the help-echo property as `browse-url' target."
    (let* ((event-win (posn-window (event-start last-input-event)))
           (help-echo (with-selected-frame (window-frame event-win)
                        (with-current-buffer (window-buffer event-win)
                          (get-text-property (point) 'help-echo))))
           (help-is-url (url-type (url-generic-parse-url help-echo))))
      (message "if %s (browse-url %S)" help-is-url help-echo)
      (if help-is-url
          (browse-url help-echo)
        (apply orig-fun args))))
  (advice-add 'markdown-follow-link-at-point :around #'markdown-follow-help-or-link-at-point-advice)

  (add-hook 'eglot-managed-mode-hook
            (lambda ()
              (setq-local eldoc-documentation-functions
                          (list #'eglot-hover-eldoc-function))))

Diagnostics

Display diagnostics such as Information, Warnings and Errors within the relevant text buffer and in a separate combined buffer. Packages: flycheck by Bozhidar Batsov and the Flycheck Maintainers and flycheck-eglot by Sergey Firsov and the Flycheck Maintainers

  (use-package flycheck
    :ensure t
    :config
    (global-flycheck-mode 1))

  (use-package flycheck-eglot
    :ensure t
    :after (flycheck eglot)
    :custom (flycheck-eglot-exclusive nil)
    :config
    (global-flycheck-eglot-mode 1))

Org Mode

Core Configuration

Configuration for org-mode for code blocks and cleaner looks.

        ; Open source blocks in the current window
  (setq org-src-window-setup 'current-window
        ; Don't confirm when evaluating a code block
        org-confirm-babel-evaluate nil
        ; Make org documents more seamless by hiding markup
        org-hide-emphasis-markers t
        ; Don't indent tags
        org-tags-column 0
        ; Don't split line on M-Ret
        org-M-RET-may-split-line '((default . nil))
        ; Respect section text on M-Ret
        org-insert-heading-respect-content t
        ; Log Time of task completion
        org-log-done 'time
        ; Log into a drawer to keep hidden
        org-log-into-drawer t
        ; Setup keywords for todo
        org-todo-keywords '((sequence "TODO(t)" "ACTIVE(a!)" "HOLD(h!)" "|" "CANCEL(c!)" "DONE(d!)")))
  ; Enable a non-monospace font for org documents
  (add-hook 'org-mode-hook 'variable-pitch-mode)
  ; Enable line wrapping for org documents
  (add-hook 'org-mode-hook 'visual-line-mode)
  ; Disable flycheck in org mode
  (add-hook 'org-mode-hook #'(lambda () (flycheck-mode -1)))
  ; Enable corfu for org roam
  (add-hook 'org-mode-hook 'corfu-mode)

Org Tempo Snippets

Quick snippets for common org templates.

  (require 'org-tempo)

Tables of Contents

Generate and update indexes automatically in Org documents.

  (use-package org-make-toc
    :ensure t
    :hook org-mode
    :custom
    (org-make-toc-insert-custom-ids t))

Disable Auto-Indent

Disable automatic indentation when editing org documents.

  (add-hook 'org-mode-hook (lambda () (electric-indent-local-mode -1)))

Highlighting

Highlight text in Org Mode in different faces. Packages: org-remark by nobiot

  (use-package org-remark
    :ensure t)

Roam

Make zettelkasten method notes with Org. Packages: org-roam by The Org-roam Maintainers

  (use-package org-roam
    :ensure t
    :custom
    (org-roam-directory (file-truename "~/Documents/Roam"))
    (org-roam-completion-everywhere t)
    :config
    (org-roam-setup))

Agenda

Schedule life with Org Mode.

  (setq org-agenda-files
        '("~/Documents/Agenda.org")
        org-agenda-span 10
        org-agenda-start-on-weekday nil
        org-agenda-start-day "-2d")

Language Support

Lua

Packages: lua-mode by immerrr

  (use-package lua-mode
    :ensure t
    :hook eglot-ensure
    :config
          ; Use a 2 space indent level for formatting
    (setq lua-indent-level 2
          ; Use lua 5.4 for documentation
          lua-documentation-url "https://www.lua.org/manual/5.4/manual.html"))

  ;; Settings for lua_ls
  (add-hook 'lua-mode-hook
    (lambda ()
      (setq-local eglot-workspace-configuration
                  `(:Lua
                    (:codeLens (:enable :json-false)

                     :completion (:enable t
                                  :callSnippet "Replace"
                                  :autoRequire :json-false
                                  :showWord "Disable"
                                  :postfix "@")

                     :diagnostics (:enable t
                                   :disable ["lowercase-global"
                                             "spell-check"]
                                   :severity (:undefined-field "Warning"
                                              :undefined-global "Warning"))

                     :format (:enable t)

                     :hint (:enable t
                            :paramName "Disable"
                            :paramType :json-false)

                     :hover (:enable t)

                     :runtime (:version "Lua 5.4"
                               :path ["?.lua"
                                      "?/init.lua"
                                      "./stubs/?.lua"
                                      "./stubs/?/init.lua"])

                     :semantic (:enable :json-false)

                     :workspace (:library [,(concat (getenv "HOME") "/.luarocks/share/lua/5.4")
                                           "./stubs"]))))))

  ; TODO Try fix this only for lua-mode as that is where the bug is
  (setq eglot-ignored-server-capabilities
        '(:documentOnTypeFormattingProvider))

Pico 8

  (use-package pico8-mode
    :vc (:url "https://github.com/Kaali/pico8-mode.git")
    :ensure t)

Nix

Packages: nix-mode by The NixOS Maintainers

  (use-package nix-mode
    :ensure t
    :mode "\\.nix\\'"
    :hook eglot-ensure
    :config
    (add-to-list 'eglot-server-programs '(nix-mode . ("nil"))))

C/C++

Packages: rmsbolt by Kay Kamat

  (add-hook 'c++-mode-hook #'eglot-ensure)
  (add-hook 'c-mode-hook #'eglot-ensure)

  (setq c-default-style "linux"
        c-basic-offset 2)

  (use-package rmsbolt
    :ensure t
    :custom
    (rmsbolt-asm-format nil))

  (setq gdb-many-windows t
        gdb-show-main t)

Emacs Lisp

  (add-hook 'emacs-lisp-mode-hook #'dim-parens-mode)
  (add-hook 'emacs-lisp-mode-hook (lambda () (local-set-key (kbd "M-p") #'ignore)
                                        (local-set-key (kbd "M-n") #'ignore)))

  ;; (defun mycommand
  ;;     (when (and (this-predicate)
  ;;                (that-predicate))
  ;;       (do-something)
  ;;       (do-some-more)
  ;;       (a-third-thing)))

Common Lisp

Packages: sly by João Távora

  (use-package sly
    :ensure t
    :hook ((lisp-mode . dim-parens-mode))
    :bind (:map lisp-mode-map
                ("M-p" . ignore)
                ("M-n" . ignore))
    :custom
    (inferior-lisp-program "ros -Q run"))

  (require 'transient)
  (transient-define-prefix lisp-transient ()
    "Transient menu for Sly."
    [["REPL"
      ("c" "Connect" sly)
      ("C" "Shutdown" sly-quit-lisp)
      ("I" "Sly Info" sly-info)]
     ["Navigation"
      ("g" "Go to Definition" sly-edit-definition)
      ("d" "Describe Thing at Point" sly-describe-symbol)
      ("f" "Find References" sly-who-references)
      ("i" "Inspect Evaluation" sly-inspect)
      ("h" "Hyperspec Lookup" hyperspec-lookup) ]
     ["Code Actions"
      ("a" "Code Actions" eglot-code-actions)
      ("q" "Quick Fix" eglot-code-action-quickfix)
      ("=" "Format Buffer" eglot-format-buffer)
      ("o" "Organize Imports" eglot-code-action-organize-imports)
      ("r" "Rename Symbol" eglot-rename) ]]
    (interactive)
    (transient-setup 'lisp-transient))

Fennel

Packages: fennel-mode by Phil Hagelberg

  (use-package fennel-mode
    :ensure t
    :hook ((fennel-mode . fennel-proto-repl-minor-mode)
           (fennel-mode . dim-parens-mode)
           (fennel-mode . eglot-ensure)
           (fennel-repl-mode . dim-parens-mode))
    :bind (:map fennel-mode-map
                ("M-p" . ignore)
                ("M-n" . ignore)))

  (defun fennel-capf-after-eglot ()
    (when (derived-mode-p 'fennel-mode)
      (setq-local completion-at-point-functions
                  '(fennel-proto-repl-complete fennel-complete tags-completion-at-point-function))))

  (add-hook 'eglot-managed-mode-hook #'fennel-capf-after-eglot t)

  (add-hook 'fennel-mode-hook
            (lambda ()
              (push '("lambda" . 955) prettify-symbols-alist)))

  (require 'transient)
  (transient-define-prefix fennel-transient ()
    "Transient menu for Fennel."
    [["Server"
      ("c" "Reconnect" eglot-reconnect)
      ("C" "Shutdown" eglot-shutdown)]
     ["Navigation"
      ("g" "Go to Definition" xref-find-definitions)
      ("d" "Describe Thing at Point" eldoc-box-help-at-point)
      ("D" "Print Documentation" fennel-show-documentation)
      ("f" "Find References" xref-find-references)]
     ["Code Actions"
      ("a" "Code Actions" eglot-code-actions)
      ("q" "Quick Fix" eglot-code-action-quickfix)
      ("=" "Format with fnlfmt" fennel-format)
      ("o" "Organize Imports" eglot-code-action-organize-imports)
      ("r" "Rename Symbol" eglot-rename)]
     ["Diagnostics"
      ("l" "List Diagnostics" flycheck-list-errors)
      ("L" "Project Diagnostics" flymake-show-project-diagnostics)]
     ["REPL"
      ("z" "Start Proto REPL" fennel-proto-repl)
      ("b" "Eval Buffer" fennel-proto-repl-eval-buffer)]]
    (interactive)
     (transient-setup 'fennel-transient))

Clojure

Packages: cider by Bozhidar Batsov

  (use-package cider
    :ensure t
    :hook ((cider-repl-mode . (lambda () (display-line-numbers-mode -1)))
           (cider-repl-mode . smartparens-mode)
           (cider-repl-mode . corfu-mode))
           ;(clojure-mode . eglot-ensure))
    :custom
    (cider-shadow-cljs-command "bunx shadow-cljs")
    :config
    (setq-default cider-eldoc-display-for-symbol-at-point nil)

    (defun mu-cider-disable-eldoc ()
      "Let LSP handle ElDoc instead of CIDER."
      (remove-hook 'eldoc-documentation-functions #'cider-eldoc t))

    (add-hook 'cider-mode-hook #'mu-cider-disable-eldoc))

    ;; (defun mu-cider-disable-completion ()
    ;;   "Let LSP handle completion instead of CIDER."
    ;;   (remove-hook 'completion-at-point-functions #'cider-complete-at-point t))

    ;; (add-hook 'cider-mode-hook #'mu-cider-disable-completion)

  (use-package flycheck-clj-kondo
    :ensure t)

  (use-package flycheck-joker
    :ensure t)

  (use-package clojure-mode
    :ensure t
    :config
    (require 'flycheck-clj-kondo)
    (require 'flycheck-joker))

Keybindings

This section contains one large emacs-lisp block that contains all the custom keybindings for easy reference and modification.

  (require 'bind-key)
  ;; Buffer Begin and End
  (bind-key* "C-," 'beginning-of-buffer)
  (bind-key* "C-." 'end-of-buffer)

  ;; Regex find and replace
  (keymap-global-set "C-c r" 'replace-regexp)

  ;; Recent files
  (keymap-global-set "C-x C-r" 'recentf-open)
  (which-key-add-key-based-replacements "C-x C-r" "recent-files")

  ;; Compile Mode
  (keymap-global-set "C-c m c" 'compile)
  (keymap-global-set "C-c m r" 'recompile)
  (keymap-global-set "C-c m g" 'rmsbolt)
  (which-key-add-key-based-replacements "C-c m" "make")

  ;; Move text up and down
  (keymap-global-set "M-p" 'move-text-up)
  (keymap-global-set "M-n" 'move-text-down)

  ;; Zen Mode
  (keymap-global-set "C-c z" 'olivetti-mode)

  ;; IBuffer
  (keymap-global-set "C-x C-b" 'ibuffer)

  ;; Project management
  (keymap-set ctl-x-map "p" 'disproject-dispatch)

  ;; Search lines
  (keymap-global-set "C-c s" 'consult-line)
  (which-key-add-key-based-replacements "C-c s" "search-lines")

  ;; Go to line
  (keymap-global-set "M-g" 'consult-goto-line)

  ;; Go to imenu
  (keymap-global-set "C-c g" 'consult-imenu)
  (which-key-add-key-based-replacements "C-c g" "imenu")

  ;; Find Files
  (keymap-global-set "C-c f f" 'affe-find)
  (keymap-global-set "C-c f g" 'affe-grep)
  (keymap-global-set "C-c f ." (lambda () (interactive) (affe-find default-directory)))
  (which-key-add-key-based-replacements "C-c f ." "affe-find-cwd")
  (keymap-global-set "C-c f c" (lambda () (interactive) (find-file "~/.config/emacs/config.org")))
  (which-key-add-key-based-replacements "C-c f c" "find-config")
  (keymap-global-set "C-c f t" (lambda () (interactive) (find-file "~/Documents/Notes/TODO.md")))
  (which-key-add-key-based-replacements "C-c f t" "find-todo")
  (keymap-global-set "C-c f a" (lambda () (interactive) (find-file "~/Documents/Agenda.org")))
  (which-key-add-key-based-replacements "C-c f t" "find-agenda")
  (which-key-add-key-based-replacements "C-c f" "find-file")

  ;; Denote
  ;; (keymap-global-set "C-c n n"   'denote)
  ;; (keymap-global-set "C-c n N"   'denote-type)
  ;; (keymap-global-set "C-c n r"   'denote-rename-file)
  ;; (keymap-global-set "C-c n l f" 'denote-link)
  ;; (keymap-global-set "C-c n l h" 'denote-org-link-to-heading)
  ;; (keymap-global-set "C-c n b"   'denote-backlinks)
  ;; (keymap-global-set "C-c n g"   'denote-grep)
  ;; (keymap-global-set "C-c n f"   'consult-denote-find)
  ;; (keymap-global-set "C-c n d"   'list-denotes)
  ;; (which-key-add-key-based-replacements "C-c n" "denotes")

  ;; ZK Notes
  ;; (keymap-global-set "C-c k a" 'zk4e-alias)
  ;; (keymap-global-set "C-c k e" 'zk4e-edit)
  ;; (keymap-global-set "C-c k d" (lambda () (interactive) (zk4e-new "Diario")))
  ;; (which-key-add-key-based-replacements "C-c k d" "zk4e-diario")
  ;; (which-key-add-key-based-replacements "C-c k" "zk4e")

  ;; Org Roam
  (keymap-global-set "C-c n l" 'org-roam-buffer-toggle)
  (keymap-global-set "C-c n f" 'org-roam-node-find)
  (keymap-global-set "C-c n i" 'org-roam-node-insert)
  (keymap-global-set "C-c n c" 'org-id-get-create)
  (keymap-global-set "C-c n a a" 'org-roam-alias-add)
  (keymap-global-set "C-c n a d" 'org-roam-alias-remove)
  (which-key-add-key-based-replacements "C-c n a" "alias")
  (which-key-add-key-based-replacements "C-c n" "org-roam")

  ;; Modus Themes
  ;; (keymap-global-set "C-c v t" 'modus-themes-toggle)
  ;; (keymap-global-set "C-c v s" 'modus-themes-select)
  ;; (which-key-add-key-based-replacements "C-c v" "vivendi-theme")

  (keymap-global-set "C-c b" 'ellama)

  ;; Yasnippet
  (keymap-global-set "C-c y n" 'yas-new-snippet)
  (keymap-global-set "C-c y v" 'yas-visit-snippet-file)
  (keymap-global-set "C-c y i" 'yas-insert-snippet)
  (which-key-add-key-based-replacements "C-c y" "yasnippets")

  ;; Eglot
  (define-key eglot-mode-map (kbd "C-c l")
              (lambda ()
                (interactive)
                (cond ((eq major-mode 'fennel-mode) (call-interactively #'fennel-transient))                    
                      (t (call-interactively #'eglot-transient)))))

  ;; Sly
  ; INFO: Can't use sly-mode-map because that doesn't get loaded till later on
  (define-key lisp-mode-map (kbd "C-c l") (lambda ()
                                           (interactive)
                                           (call-interactively #'lisp-transient)))

  ;; Webapps
  (keymap-global-set "C-c w w" 'webapp-dashboard)
  (keymap-global-set "C-c w e" (lambda () (interactive)(webapp-open 'ProtonMail)))
  (which-key-add-key-based-replacements "C-c w e" "protonmail")
  (keymap-global-set "C-c w g" (lambda () (interactive)(webapp-open 'Git)))
  (which-key-add-key-based-replacements "C-c w g" "git")
  (keymap-global-set "C-c w j" (lambda () (interactive)(webapp-open 'Jellyfin)))
  (which-key-add-key-based-replacements "C-c w j" "jellyfin")
  (keymap-global-set "C-c w l" (lambda () (interactive)(webapp-open 'Lumo)))
  (which-key-add-key-based-replacements "C-c w l" "lumo")
  (keymap-global-set "C-c w c" (lambda () (interactive)(webapp-open 'Claude)))
  (which-key-add-key-based-replacements "C-c w c" "claude")
  (keymap-global-set "C-c w b" (lambda () (interactive)(webapp-open 'Browse)))
  (which-key-add-key-based-replacements "C-c w c" "browse")
  (keymap-global-set "C-c w r" 'webapp-reload)
  (keymap-global-set "C-c w R" 'webapp-register)
  (keymap-global-set "C-c w y" 'webapp-copy-url)
  (keymap-global-set "C-c w s" 'webapp-suspend)
  (keymap-global-set "C-c w S" 'webapp-suspend-all)
  (which-key-add-key-based-replacements "C-c w" "webapps")

  ;; Agenda
  (keymap-global-set "C-c a" 'org-agenda)

  ;; Email
  (keymap-global-set "C-c e" 'mu4e)

  ;; Elfeed
  (keymap-global-set "C-c F" 'elfeed)