This GitHub repository contains my Emacs configuration in literary form. I find this a more suitable format for exposing and explaining the configuration of a text-editing application such as Emacs.
All Emacs LISP expressions in this document were written for Emacs version 29.4.
I use NixOS as my main operating system, my NixOS configuration is very modularized, which includes Emacs configuration. It is written solely through Nix expressions, which are themselves written through the NixOS Emacs home-manager module.
The aim of this repository is to be able to use my configuration on any non-Nix distribution, i.e. without needing to build a derivation or evaluate NixOS modules.
It is therefore a KISS way of distributing my configuration.
All you need is Emacs and the GNU Make program and the following command line.
make install
You could need to run the command line above one more time if Emacs were not able to get the full context.
All the code blocks in this Org file containing Emacs LISP expressions will be collected and written to a init.el file. This file will be loaded and compiled by the Emacs application and the result of the compilation will be written in a file init.elc and installed in the directory ~/.emacs.d.
This section describes my entire configuration.
I use straight.el as my main package manager. This makes it easier for me to retrieve packages that aren’t in the official package archives. It’s still possible to retrieve packages from MELPA and ELPA but from straight.el.
The package greatly facilitates my package management and allows me to have an even more reproducible and detailed configuration.
;; Bootstrap the straight.el package ;; It download the install the install.el file in my .emacs.d directory if it does not exist (defvar bootstrap-version) (setq straight-recipes-gnu-elpa-use-mirror t) (setq straight-recipes-nongnu-elpa-use-mirror t) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 5)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) ;; Use straight.el for use-package expressions (straight-use-package 'use-package) ;; Use the :straight t argument pair by default with use-package (setq straight-use-package-by-default t) ;; Use the built-in Org package (straight-use-package '(org :type built-in))
Below is the general configuration of some general Emacs behaviors and customizations.
(global-auto-revert-mode 1) (show-paren-mode t) (setq use-short-answers t show-trailing-whitespace t) ;; Remove the menu bar (menu-bar-mode -1) (when (display-graphic-p) ;; Resize small font on the GUI Emacs application (set-face-attribute 'default nil :height 105) ;; Annoying displayed UI elements (tool-bar-mode -1) (scroll-bar-mode -1)) (setq display-line-numbers-type 'relative) (setq standard-indent 2) (add-hook 'prog-mode-hook 'display-line-numbers-mode) ;; Needed to request GPG passphrase with Emacs (setq epg-pinentry-mode 'loopback) ;; Disable the ring bell sound (setq ring-bell-function 'ignore) ;; See https://snarfed.org/gnu_emacs_backup_files (custom-set-variables '(auto-save-file-name-transforms '((".*" "~/.emacs.d/autosaves/\\1" t))) '(backup-directory-alist '((".*" . "~/.emacs.d/backups/")))) (make-directory "~/.emacs.d/autosaves/" t) (setq org-link-file-path-type 'relative) ;; See https://themkat.net/2025/03/25/simple_smoother_emacs_scrolling.html (setq scroll-conservatively 10 scroll-margin 15) (setq inhibit-startup-screen t) ;; Better and cool behaviors (electric-pair-mode 1) (global-hl-line-mode 1) (delete-selection-mode 1) ;; Run Emacs server (use-package server :ensure nil) (unless (server-running-p) (server-start))
I use the MonoLisa font patched to accommodate the Nerd font (sometime without). There is this GitHub repository to patch MonoLisa.
(use-package dracula-theme :config (load-theme 'dracula t)) ;; Load the font if it exist (let ((my-font "MonoLisa Nerd Font")) (when (find-font (font-spec :name my-font)) (set-frame-font my-font))) ;; Set font size (set-face-attribute 'default t :font (font-spec :size 11.000000)) ;; Set opacity (add-to-list 'default-frame-alist '(alpha-background . 100)) (use-package ligature :config (ligature-set-ligatures 't '("www")) (ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi")) (ligature-set-ligatures 'prog-mode '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>" ":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!==" "!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<" "<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->" "<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<" "..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~=" "~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|" "[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:" ">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:" "<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!" "##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:" "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)" "\\\\" "://")) (global-ligature-mode t))
(use-package auto-save :straight (auto-save :type git :host github :repo "manateelazycat/auto-save") :config (auto-save-enable) :custom (auto-save-silent t) (auto-save-delete-trailing-whitespace t) (auto-save-disable-predicates '((lambda () (string-suffix-p "gpg" (file-name-extension (buffer-name)) t)))))
(use-package all-the-icons) (use-package dashboard :after (all-the-icons) :init (dashboard-setup-startup-hook) :if (or (display-graphic-p) (and (not (daemonp)) (= (length command-line-args) 1))) :custom (dashboard-startup-banner '("./assets/04_padman.png" . "./assets/04_padman.txt")) (dashboard-banner-logo-title "I'm the King, I'm PADMAN.") (dashboard-center-content t) (dashboard-set-navigator t) (dashboard-icon-type 'all-the-icons) (dashboard-items '((projects . 5) (recents . 5) (agenda . 5))) (dashboard-set-file-icons t) (dashboard-projects-backend 'project-el) (dashboard-footer-messages '("Don't run, Don't jump, only hold still. It's better for me to frag you.." "Quit crying Freak, you were born as a loser..hehe" "do that again, bitch." "I bet you have to put a lot of effort into being that stupid." "Wow, is that my brain on the wall..?" "That wasn't luck, I just went easy on you." "Nobody can stop me." "Okay, here is PADMAN and it's time to frag you..!" "Oh, PADGiRL is looking for me, she wants to go to bed..!")) :config (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*") (dashboard-refresh-buffer))))
(use-package all-the-icons-dired) (use-package dired :ensure nil :straight nil :after (all-the-icons-dired dired-collapse) :defer 1 :commands (dired dired-jump) :custom (dired-kill-when-opening-new-dired-buffer t) ;; It prevents having hundreds useless buffers (dired-listing-switches "-lahv") :hook (dired-mode . (lambda () (interactive) (all-the-icons-dired-mode 1) (dired-collapse) (hl-line-mode 1)))) (use-package dired-collapse) (declare-function dired-collapse "dired-collapse")
(use-package doom-modeline :init (doom-modeline-mode 1))
(use-package magit :commands magit-status :bind ("C-x g" . magit-status))
(use-package org :custom (org-startup-with-inline-images t) (org-startup-folded t) (org-todo-keyword-faces '(("DONE" . "GREEN"))) (org-hide-emphasis-markers t) (org-image-actual-width nil) (org-support-shift-select t) (org-pretty-entities t) (org-agenda-files '("~/.emacs-org-agenda")))
(use-package org-download :after org :hook ((dired-mode . org-download-enable)) :custom (org-download-method 'directory) (org-download-image-dir "Attachments") (org-download-heading-lvl nil))
(use-package org-journal :defer t :after org :custom (org-journal-prefix-key "C-c j") (org-journal-dir "~/org/journal/") (org-journal-date-format "%A, %d %B %Y"))
(use-package visual-fill-column :custom (visual-fill-column-width 110) (visual-fill-column-center-text t)) (defun my/org-present-start () ;; Show images within the buffer (org-display-inline-images) ;; Center the text (visual-fill-column-mode 1) (visual-line-mode 1)) (defun my/org-present-end () ;; Hide images (org-remove-inline-images) ;; Cancel the text centering (visual-fill-column-mode 0) (visual-line-mode 0)) (use-package org-present :after (visual-fill-column org) :hook ((org-present-mode . my/org-present-start) (org-present-mode-quit . my/org-present-end)))
(use-package org-superstar :after org :hook (org-mode . org-superstar-mode) :custom (org-superstar-remove-leading-stars t) (org-superstar-headline-bullets-list '("⁖" "✿" "▷" "✸")))
(use-package pdf-tools :config (pdf-tools-install))
(use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode))
(use-package rg)(use-package treemacs :bind (("M-²" . treemacs-select-window) ("M-0" . treemacs-select-window)))
(use-package vertico :bind (:map vertico-map ("C-j" . vertico-next) ("C-k" . vertico-previous) ("C-f" . vertico-exit) :map minibuffer-local-map ("M-h" . backward-kill-word)) :custom (vertico-cycle t) :init (vertico-mode)) (use-package savehist :init (savehist-mode)) (use-package marginalia ;; :after vertico ;; :custom ;; (marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) :init (marginalia-mode)) (use-package all-the-icons :if (display-graphic-p)) (use-package all-the-icons-completion :after (marginalia all-the-icons) :hook (marginalia-mode . all-the-icons-completion-marginalia-setup) :init (all-the-icons-completion-mode)) ;; Emacs minibuffer configurations. (use-package emacs :custom ;; Enable context menu. `vertico-multiform-mode' adds a menu in the minibuffer ;; to switch display modes. (context-menu-mode t) ;; Support opening new minibuffers from inside existing minibuffers. (enable-recursive-minibuffers t) ;; Hide commands in M-x which do not work in the current mode. Vertico ;; commands are hidden in normal buffers. This setting is useful beyond ;; Vertico. (read-extended-command-predicate #'command-completion-default-include-p) ;; Do not allow the cursor in the minibuffer prompt (minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt)))
;; Example configuration for Consult (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 r" . consult-grep-match) ("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-g i" . consult-imenu) ("M-g 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 ;; The :init configuration is always executed (Not lazy) :init ;; Tweak the register preview for `consult-register-load', ;; `consult-register-store' and the built-in commands. This improves the ;; register formatting, adds thin separator lines, register sorting and hides ;; the window mode line. (advice-add #'register-preview :override #'consult-register-window) (setq register-preview-delay 0.5) ;; Use Consult to select xref locations with preview (setq xref-show-xrefs-function #'consult-xref xref-show-definitions-function #'consult-xref) ;; Configure other variables and modes in the :config section, ;; after lazily loading the package. :config ;; Optionally configure preview. The default value ;; is 'any, such that any key triggers the preview. ;; (setq consult-preview-key 'any) ;; (setq consult-preview-key "M-.") ;; (setq consult-preview-key '("S-<down>" "S-<up>")) ;; For some commands and buffer sources it is useful to configure the ;; :preview-key on a per-command basis using the `consult-customize' macro. (consult-customize consult-theme :preview-key '(:debounce 0.2 any) consult-ripgrep consult-git-grep consult-grep consult-man consult-bookmark consult-recent-file consult-xref ;; :preview-key "M-." :preview-key '(:debounce 0.4 any)) ;; Optionally configure the narrowing key. ;; Both < and C-+ work reasonably well. (setq consult-narrow-key "<") ;; "C-+" ;; Optionally make narrowing help available in the minibuffer. ;; You may want to use `embark-prefix-help-command' or which-key instead. ;; (keymap-set consult-narrow-map (concat consult-narrow-key " ?") #'consult-narrow-help) )
;; Optionally use the `orderless' completion style. (use-package orderless :custom ;; Configure a custom style dispatcher (see the Consult wiki) ;; (orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch)) ;; (orderless-component-separator #'orderless-escapable-split-on-space) (completion-styles '(orderless basic)) (completion-category-overrides '((file (styles partial-completion)))) (completion-category-defaults nil) ;; Disable defaults, use our settings (completion-pcm-leading-wildcard t)) ;; Emacs 31: partial-completion behaves like substring
(use-package all-the-icons-ibuffer :hook (ibuffer-mode . all-the-icons-ibuffer-mode))
(use-package direnv :config (direnv-mode))
See the emacs-libvterm GitHub repository if you need to install the dependencies.
(use-package vterm :commands vterm :custom (vterm-always-compile-module t) (term-prompt-regexp "^[^#$%>\n]*[#$%>] *") (vterm-shell "fish") (vterm-max-scrollback 10000))
(use-package markdown-mode :commands (markdown-mode gfm-mode) :mode (("README\\.md\\'" . gfm-mode) ("\\.md\\'" . markdown-mode) ("\\.markdown\\'" . markdown-mode)) :custom (markdown-command "pandoc"))
(use-package yaml-mode :commands (markdown-mode gfm-mode) :mode (("\\.yml\\'" . yaml-mode) ("\\.yaml\\'" . yaml-mode)))
(use-package sphinx-doc :hook (python-mode . sphinx-doc-mode) :custom (sphinx-doc-include-types t))
(use-package tldr)(use-package multiple-cursors :bind (("C-S-c C-S-c" . mc/edit-lines) ("C->" . mc/mark-next-like-this) ("C-<" . mc/mark-previous-like-this) ("C-c C-<" . mc/mark-all-like-this))) (use-package multiple-cursors-core :after multiple-cursors :straight nil :bind (:map mc/keymap ("<return>" . nil) ("C-<return>" . multiple-cursors-mode)))
(use-package elfeed :custom (elfeed-feeds '("https://www.journalduhacker.net/rss" "https://tilde.news/rss" "https://lobste.rs/rss" "https://news.ycombinator.com/rss")))
This Emacs package requires qBittorrent.
(use-package qbittorrent-transient :straight (qbittorrent-transient :type git :host github :repo "theobori/qbittorrent-transient"))
This Emacs package requires go-grip if you keep it as below.
(use-package grip-mode :config (setq grip-command 'go-grip) :bind (:map markdown-mode-command-map ("g" . grip-mode)))
(use-package yasnippet :diminish yas-minor-mode :config (yas-reload-all) (yas-global-mode 1)) (declare-function yas-reload-all "yasnippet") (use-package company :config (global-company-mode) :custom (company-idle-delay 0) (company-echo-delay 0) (company-minimum-prefix-length 1)) (use-package company-box :after company :if (display-graphic-p) :custom (company-box-frame-behavior 'point) (company-box-show-single-candidate t) (company-box-doc-delay 1)) (use-package lsp-mode :config (add-to-list 'load-path (expand-file-name "lib/lsp-mode" user-emacs-directory)) (add-to-list 'load-path (expand-file-name "lib/lsp-mode/clients" user-emacs-directory)) :hook ((sh-mode . lsp) (tex-mode . lsp)) :commands lsp :custom (lsp-headerline-breadcrumb-icons-enable nil)) (use-package lsp-ivy :after lsp-mode :commands lsp-ivy-workspace-symbol) (use-package lsp-ui :after lsp-mode :commands lsp-ui-mode) (use-package lsp-treemacs :config (lsp-treemacs-sync-mode 1))
(use-package dockerfile-mode :hook ((dockerfile-mode . lsp)) :mode "\\Dockerfile?$" :config (put 'dockerfile-image-name 'safe-local-variable #'stringp))
(use-package lsp-pyright :custom (lsp-pyright-langserver-command "pyright") :hook (python-mode . (lambda () (require 'lsp-pyright) (lsp))))
(use-package go-mode :hook (go-mode . lsp))
(use-package nix-mode :hook (nix-mode . lsp) :mode "\\.nix\\'" :custom (lsp-nix-nixd-server-path "nixd") (lsp-nix-nixd-formatting-command [ "nixfmt" ]) (lsp-nix-nixd-nixpkgs-expr "import <nixpkgs> { }"))
(use-package terraform-mode :hook ((terraform-mode . lsp-deferred) (terraform-mode . terraform-format-on-save-mode)) :mode "\\.tf\\'")
(use-package typescript-mode :hook (typescript-mode . lsp) :mode "\\.ts?$")
(use-package ccls :hook ((c-mode . lsp) (c++-mode . lsp) (objc-mode . lsp)))