From 4c272bf2729b91518258cc94fdc6f9507ec6c62c Mon Sep 17 00:00:00 2001 From: Nicholas Rodrigues Lordello Date: Tue, 6 Jan 2026 23:21:12 +0100 Subject: Integrate Emacs Bedrock Added some of the Emacs Bedrock configurations that I was interested in. In particular: 1. Some of the auto-revert configuration (for performance, and TRAMP support which was annoying me) 2. Added some startup speed-ups to the early initialization 3. Add some new packages: Corfu, Marginalia, and Vertico 4. Use `avi-goto-char-timer`, which is just awesome! In addition, I did some refactoring: - Deprecated the `system/flavour` setup that I had (but never really used, all my systems were in `'development` mode anyway) - Use `major-mode-remap-alist` for tree-sitter mode selection - Completion mode configuration to `use-package` with cycling keybinds --- config/emacs/early-init.el | 8 +- config/emacs/init.el | 231 ++++++++++++++++++++++----------------------- 2 files changed, 118 insertions(+), 121 deletions(-) diff --git a/config/emacs/early-init.el b/config/emacs/early-init.el index bf76d4b..01620f1 100644 --- a/config/emacs/early-init.el +++ b/config/emacs/early-init.el @@ -3,11 +3,17 @@ ;;; Commentary: ;; Early initialization configuration. Right now, it just increases -;; the `gc-cons-threshold' in order to speed up initialization. +;; startup performance and reduces noise. ;;; Code: +(setq init/gc-cons-threshold gc-cons-threshold) (setq gc-cons-threshold 104857600) +(setq byte-compile-warnings '(not obsolete)) +(setq warning-suppress-log-types '((comp) (bytecomp))) +(setq native-comp-async-report-warnings-errors 'silent) +(setq inhibit-startup-echo-area-message "nlordell") + (provide 'early-init) ;;; early-init.el ends here diff --git a/config/emacs/init.el b/config/emacs/init.el index dee639d..d436f6b 100644 --- a/config/emacs/init.el +++ b/config/emacs/init.el @@ -5,29 +5,10 @@ ;; Emacs initialization file. Contains my personal and evolving Emacs ;; configuration - what a rabbit hole! -;;; TODO: - -;; 1. Setup LLM coding: gptel, aidermacs -;; 2. Try out neocaml - tree-sitter based OCaml mode -;; 3. Take some stuff from Emacs NANO -;; -;; 4. Take some stuff from Emacs Bedrock -;; - ;;; Code: ;;; -- Customizations -- -(defcustom init/system-flavour 'plain - "The flavour of system. - - Allows initialization and customization differentiation with a - shared .emacs." - :tag "System Flavour" - :type '(choice (const :tag "Plain" plain) - (const :tag "Development" development)) - :group 'convenience) - (defcustom init/journal-file "~/Documents/Journal.org" "The path to my journal file." :tag "Journal File" @@ -42,7 +23,7 @@ (defun init/show-trailing-whitespace () "Show trailing whitespace for the current buffer." - (setq show-trailing-whitespace t)) + (setq-local show-trailing-whitespace t)) (defun init/auto-save-directory () "The auto-save directory where the save file lives." @@ -63,20 +44,6 @@ (interactive) (find-file init/journal-file)) -(defun init/dev () - "Returns whether or not this configuration is for the `development' flavour." - (eq init/system-flavour 'development)) - -(defun init/project-remember () - "Remember all projects under `~/Developer'" - (interactive) - (dolist (file (directory-files-and-attributes - "~/Developer" t directory-files-no-dot-files-regexp)) - (let ((name (car file)) - (is-dir (eq (cadr file) t))) - (when is-dir - (project-remember-projects-under name))))) - (defun devbox/magit-status () "Opens the local Git status for a devbox directory. @@ -92,31 +59,19 @@ If the current buffer is not open in the devbox, then this function just runs ;;; -- Emacs Configuration -- (use-package emacs - :hook ((prog-mode . completion-preview-mode) - (prog-mode . display-line-numbers-mode) + :hook ((prog-mode . display-line-numbers-mode) (prog-mode . init/show-trailing-whitespace) (before-save . delete-trailing-whitespace)) :bind (("C-c ," . init/open-local-init) ("C-c C-," . init/open-init) ("C-c C-j" . init/open-journal) - ("C-c C-p" . init/project-remember) ("C-x k" . kill-current-buffer) ("M-/" . hippie-expand)) - :init - (menu-bar-mode -1) - (tool-bar-mode -1) - (when (fboundp 'scroll-bar-mode) - (scroll-bar-mode -1)) - (which-key-mode +1) - (column-number-mode +1) - (delete-selection-mode +1) - (global-auto-revert-mode +1) - (load-theme 'modus-vivendi t) - (load (init/expand-file-name "local-init.el") t t) :custom (use-short-answers t) (inhibit-startup-screen t) (initial-scratch-message "") + (initial-major-mode 'fundamental-mode) (frame-title-format '("%b")) (ring-bell-function 'ignore) (sentence-end-double-space nil) @@ -128,41 +83,58 @@ If the current buffer is not open in the devbox, then this function just runs (auto-save-file-name-transforms `((".*" ,(init/auto-save-directory) t))) (create-lockfiles nil) (tab-width 4) - (custom-file (init/expand-file-name "local-init.el"))) + (tab-always-indent 'complete) + (completion-styles '(basic initials substring)) + (auto-revert-avoid-polling t) + (auto-revert-remote-files t) + (major-mode-remap-alist + '((c-mode . c-ts-mode) + (javascript-mode . js-ts-mode) + (typescript-mode . typescript-ts-mode))) + (custom-file (init/expand-file-name "local-init.el")) + :init + (menu-bar-mode -1) + (tool-bar-mode -1) + (when (fboundp 'scroll-bar-mode) + (scroll-bar-mode -1)) + (which-key-mode +1) + (savehist-mode +1) + (column-number-mode +1) + (delete-selection-mode +1) + (global-auto-revert-mode +1) + (load-theme 'modus-vivendi t) + (load (init/expand-file-name "local-init.el") t t) + (setq gc-cons-threshold (or init/gc-cons-threshold 800001))) ;;; -- Built-ins -- -(use-package c-ts-mode - :mode "\\.[ch]\\'") +(use-package completion-preview + :hook ((prog-mode . completion-preview-mode)) + :bind (:map completion-preview-active-mode-map + ("M-n" . completion-preview-next-candidate) + ("M-p" . completion-preview-prev-candidate))) (use-package eglot :bind (:map eglot-mode-map - ("M-q" . eglot-format))) - -(use-package js-ts-mode - :mode "\\.m?js\\'" - :custom - (js-indent-level 2)) - -(use-package rust-ts-mode - :mode "\\.rs\\'" - :hook - (rust-ts-mode . eglot-ensure)) + ("M-q" . eglot-format)) + :config + (fset #'jsonrpc--log-event #'ignore)) -(use-package typescript-ts-mode - :mode "\\.tsx?\\'" +(use-package project :custom - (typescript-ts-mode-indent-offset 2)) + (project-mode-line t) + :config + (add-to-list 'project-switch-commands + '(devbox/magit-status "Magit" "m") t)) -(use-package xref +(use-package tramp :config - (when (executable-find "rg") - (setq xref-search-program 'ripgrep))) + (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) -(use-package project +(use-package xref :config - (add-to-list 'project-switch-commands - '(magit-project-status "Magit" "m") t)) + (when (executable-find "grep") + (setopt xref-search-program 'ripgrep))) ;;; -- Packages -- @@ -188,17 +160,32 @@ If the current buffer is not open in the devbox, then this function just runs (use-package avy :ensure t :bind (("C-:" . avy-goto-char) + ("C-'" . avy-goto-char-timer) ("M-g f" . avy-goto-line))) +(use-package corfu + :ensure t + :hook ((prog-mode . corfu-mode) + (corfu-mode . corfu-popupinfo-mode)) + :bind (:map corfu-map + ("SPC" . corfu-insert-separator) + ("C-n" . corfu-next) + ("C-p" . corfu-previous)) + :custom + (corfu-cycle t) + (corfu-popupinfo-delay '(0.25 . 0.1)) + (corfu-popupinfo-hide nil)) + (use-package exec-path-from-shell :if (eq system-type 'darwin) :ensure t :config (exec-path-from-shell-initialize)) -(use-package magit +(use-package marginalia :ensure t - :bind (("C-x g" . devbox/magit-status))) + :config + (marginalia-mode +1)) (use-package undo-tree :ensure t @@ -214,67 +201,71 @@ If the current buffer is not open in the devbox, then this function just runs :config (spacious-padding-mode +1)) +(use-package vertico + :ensure t + :config + (vertico-mode +1)) + ;;; -- General Development -- -(when (init/dev) - (use-package ligature - :ensure t - :hook - (prog-mode . ligature-mode) - :config - (ligature-set-ligatures - 'prog-mode - '(".." "..." "::" ":=" ";;" ";;;" "??" "**" "/*" "*/" "/**" "<-" - "->" "-->" "" "