Skip to content

cedarbaum/.emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emacs configuration

photos/emacs-logo.png

This is my Emacs configuration! It is largely based around Evil mode.

Compatibility

This config is written for Emacs 29+. It assumes that eglot (LSP integration) and Tree-sitter are available.

(if (version< emacs-version "29.0")
    (display-warning 'config "Configuration is designed for Emacs 29+"))

General configuration

Personal information

(setq user-full-name "Sam Cedarbaum"
      user-mail-address "[email protected]")

GPG

Enable pin entry within the Emacs minibuffer.

(setq epa-pinentry-mode 'loopback)

Use GPG for plstore encryption.

(require 'plstore)
(when-let ((gpg-encryption-key-id (getenv "GPG_ENCRYPTION_KEY_ID")))
  (add-to-list 'plstore-encrypt-to gpg-encryption-key-id))

auth-sources

Look for JSON files when searching auth sources.

(require 'auth-source)
(dolist (file '("~/.authinfo.json" "~/.authinfo.json.gpg"))
  ((lambda ()
     (when (file-exists-p file) (add-to-list 'auth-sources file)))))

Startup window

Disable startup screen.

(setq inhibit-startup-screen t)

GUI configuration

This section is for themes and GUI configuration. Below code will reload the configuration each time a new frame is created. This is useful when using Emacs server/client.

(use-package nerd-icons)
(use-package snazzy-theme)
;; Wait for theme install before calling configure-frame
(elpaca-wait)

(defun configure-frame (&optional frame)
  "Customize the FRAME and load theme."
  (load-theme 'snazzy t)
  (set-face-attribute 'fringe nil :background nil)
  (custom-set-faces
  '(tooltip ((t :foreground "white"))))
  (unless frame
    (setq frame (selected-frame)))
  (when frame
    (with-selected-frame frame
      (when (display-graphic-p)
        (menu-bar-mode -1)
        (toggle-scroll-bar -1)
        (tool-bar-mode -1)))))

;; Configure frame and also ensure each new frame will be configured
(configure-frame)
(add-hook 'after-make-frame-functions #'configure-frame t)

Enable winner-mode.

(when (fboundp 'winner-mode)
  (winner-mode 1))

Help system

Select the help window when opened.

(setq help-window-select t)

Sounds

Disable bell function.

(setq ring-bell-function 'ignore)

File management

Don’t delete any backups.

(setq delete-old-versions -1)

Unconditionally make numeric backups for files.

(setq version-control t)

Backup files even if they’re under version control.

(setq vc-make-backup-files t)

Place automatically saved files in a single directory.

(setq auto-save-file-name-transforms
      `((".*" ,(concat user-emacs-directory "auto-save-list/") t)))

Place all backups in a single directory.

(setq backup-directory-alist
      `((".*" . ,(concat user-emacs-directory "backups"))))

Save the minibuffer history between sessions. Also save the kill-ring and search rings.

(require 'savehist)
(savehist-mode 1)
(setq history-length 10000)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
      '(kill-ring
        search-ring
        regexp-search-ring
        register-alist))

Don’t create lock files.

(setq create-lockfiles nil)

Enable auto revert mode.

(global-auto-revert-mode 1)

Customize

Put all automatic configurations in a separate file.

(setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file 'noerror)

Text encoding

Prefer UTF-8 Encoding.

(prefer-coding-system 'utf-8)
(when (display-graphic-p)
  (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))

Font

Try to use either Berkeley Mono, Fira Code, JetBrains Mono, or Hack font.

(defun get-font (font-list)
  (seq-find (lambda (font)
              (member font (font-family-list)))
            font-list))

(defun get-preferred-font (&optional size)
  (let ((font-name (get-font '("Berkeley Mono" "Fira Code" "JetBrains Mono" "Hack"))))
    (when font-name
      (if size
          (format "%s-%s" font-name size)
        font-name))))

(when-let ((font (get-preferred-font 14)))
  (set-face-attribute 'default nil :font font))

Spaces/tabs

Use spaces instead of tabs.

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)

Cleanup whitespace on save.

(add-hook 'before-save-hook 'whitespace-cleanup)

Recent files

Enable recentf-mode and save lots of items.

(recentf-mode 1)
(setq recentf-auto-cleanup 'never)
(setq recentf-max-menu-items 1000)
(setq recentf-max-saved-items 1000)

World clock

Configure world clock display.

(setq display-time-world-time-format "%FT%T%z") ;; ISO 8601
(setq display-time-world-timer-second 1)
(setq display-time-world-list '(("UTC"     "UTC")
                                ("EST5EDT" "New York")
                                ("CST6CDT" "Chicago")
                                ("PST8PDT" "Los Angeles")))

Kill ring

Save existing clipboard text into kill ring before replacing it.

(setq save-interprogram-paste-before-kill t)

Native compilation

Don’t display compilation warnings.

(setq native-comp-async-report-warnings-errors nil)

ANSI Color support

Enable ANSI color support. See:

  • https://www.emacswiki.org/emacs/AnsiColor
  • https://emacs.stackexchange.com/a/8137
    (require 'ansi-color)
    
    (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
    (add-to-list 'comint-output-filter-functions 'ansi-color-process-output)
    
    (defun my/ansi-colorize-buffer ()
      (let ((buffer-read-only nil))
        (ansi-color-apply-on-region (point-min) (point-max))))
    (add-hook 'compilation-filter-hook 'my/ansi-colorize-buffer)
        

Vesion control

Don’t warn about following symlinks.

(setq vc-follow-symlinks t)

Performance

Increase GC threshold to 100MB.

(setq gc-cons-threshold 100000000) ;; 100MB

Read more data from process output (e.g., LSPs).

(setq read-process-output-max (* 1024 1024)) ;; 1MB

OS specific settings

macOS

Bind the command key to meta.

(when (eq system-type 'darwin)
  (setq mac-command-modifier 'meta))

Modes and packages

Ubiquitous modes

General

Use General for keybindings.

(use-package general :demand t)
;; Wait for :general macro to be available for other packages
(elpaca-wait)

Hydra

Install Hydra.

(use-package hydra
  :general
  ("<f2>" 'hydra-zoom/body)
  :config
  (defhydra hydra-zoom ()
    "zoom"
    ("g" text-scale-increase "in")
    ("l" text-scale-decrease "out")
    ("r" (text-scale-set 0)  "reset")))

Add :hydra keyword to use-package.

(use-package use-package-hydra)
;; Wait for :hydra macro to be available to other packages
(elpaca-wait)

Evil mode

Vim emulation for Emacs (GitHub).

(use-package evil
  :init
  (setq evil-ex-complete-emacs-commands nil)
  (setq evil-vsplit-window-right t)
  (setq evil-split-window-below t)
  (setq evil-want-keybinding nil)
  (setq evil-undo-system 'undo-tree)
  :config
  (evil-mode))

;; Use undo-tree for Evil mode's undo functionality
(use-package undo-tree
  :config
  (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))
  (setq undo-tree-auto-save-history t)
  (global-undo-tree-mode 1))

Vim-style key-bindings for Org mode (GitHub).

(use-package evil-org
  :config
  (add-hook 'org-mode-hook 'evil-org-mode)
  (add-hook 'evil-org-mode-hook
            (lambda ()
              (evil-org-set-key-theme)))
  (require 'evil-org-agenda)
  (evil-org-agenda-set-keys))

Vim-style key-bindings for many common Emacs modes (GitHub).

(use-package evil-collection :config (evil-collection-init))

Evil surround support similar to surround.vim.

(use-package evil-surround :config (global-evil-surround-mode 1))

Evil comment support similar to commentary.vim.

(use-package evil-commentary :config (evil-commentary-mode))

Add visual hints when editing with evil.

(use-package evil-goggles
  :config
  (evil-goggles-mode)
  (evil-goggles-use-diff-faces))

Preview registers and marks before using them.

(use-package evil-owl
  :config
  (if window-system
      (setq evil-owl-display-method 'posframe
            evil-owl-extra-posframe-args '(:width 50 :height 20)
            evil-owl-max-string-length 50)
    (progn
      (setq evil-owl-max-string-length 500)
      (add-to-list 'display-buffer-alist
                   '("*evil-owl*"
                     (display-buffer-in-side-window)
                     (side . bottom)
                     (window-height . 0.3)))))
  (evil-owl-mode))

Better searching.

(use-package evil-anzu
  :config
  (global-anzu-mode +1))

Vertico / Orderless / Consult / Marginalia / Embark

Vertical completion UI.

(use-package vertico
  :ensure (vertico :files (:defaults "extensions/*")
                   :includes (vertico-buffer
                              vertico-directory
                              vertico-flat
                              vertico-indexed
                              vertico-mouse
                              vertico-quick
                              vertico-repeat
                              vertico-reverse))
  :init
  (vertico-mode)
  (setq vertico-count 20)
  (setq vertico-resize t)
  (setq vertico-cycle t))

;; Configure directory extension.
(use-package vertico-directory
  :after vertico
  :ensure nil
  :general
  (:keymaps 'vertico-map "C-l" 'vertico-directory-up)
  :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))

More flexible completion engine: https://github.com/oantolin/orderless.

(use-package orderless
  :init
  (setq completion-styles '(orderless basic)
        completion-category-defaults nil
        completion-category-overrides '((file (styles partial-completion)))))

Completing reads for common commands.

(use-package consult
  :general
  ;; C-c bindings (mode-specific-map)
  ("C-c h" 'consult-history)
  ("C-c m" 'consult-mode-command)
  ("C-c k" 'consult-kmacro)
  ;; C-x bindings (ctl-x-map)
  ("C-x M-:" 'consult-complex-command)
  ("C-x b"   'consult-buffer)
  ("C-x 4 b" 'consult-buffer-other-window)
  ("C-x 5 b" 'consult-buffer-other-frame)
  ("C-x r b" 'consult-bookmark)
  ("C-x p b" 'consult-project-buffer)
  ;; Custom M-# bindings for fast register access
  ("M-#"   'consult-register-load)
  ("M-'"   'consult-register-store)
  ("C-M-#" 'consult-register)
  ;; Other custom bindings
  ("M-y"      'consult-yank-pop)
  ;; M-g bindings (goto-map)
  ("M-g e"   'consult-compile-error)
  ("M-g f"   'consult-flymake)
  ("M-g g"   'consult-goto-line)
  ("M-g M-g" 'consult-goto-line)
  ("M-g o"   'consult-outline)
  ("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 (search-map)
  ("M-s d"   'consult-find)
  ("M-s D"   'consult-locate)
  ("M-s g"   'consult-grep)
  ("M-s G g" 'consult-git-grep)
  ("M-s r"   'consult-ripgrep)
  ("M-s l"   'consult-line)
  ("M-s L"   'consult-line-multi)
  ("M-s m"   'consult-multi-occur)
  ("M-s k"   'consult-keep-lines)
  ("M-s u"   'consult-focus-lines)
  ;; Isearch integration
  (:keymaps 'isearch-mode-map
            "M-s e" 'consult-isearch-history
            "M-e"   'consult-isearch-history
            "M-s e" 'consult-isearch-history
            "M-s l" 'consult-line
            "M-s L" 'consult-line-multi)
  ;; Minibuffer history
  (:keymaps 'minibuffer-local-map
            "M-s" 'consult-history
            "M-r" 'consult-history)
  ;; Enable automatic preview at point in the *Completions* buffer. This is
  ;; relevant when you use the default completion UI.
  :hook (completion-list-mode . consult-preview-at-point-mode)
  :init
  ;; This improves the register 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)

  ;; This adds thin lines, sorting and hides the mode line of the window.
  (advice-add #'register-preview :override #'consult-register-window)

  ;; Use Consult to select xref locations with preview
  (setq xref-show-xrefs-function #'consult-xref
        xref-show-definitions-function #'consult-xref)
  :config
  (consult-customize
   consult-theme
   :preview-key '(:debounce 0.2 any)
   consult-ripgrep consult-git-grep consult-grep
   consult-bookmark consult-recent-file consult-xref
   consult--source-bookmark consult--source-recent-file
   consult--source-project-recent-file
   :preview-key "M-.")

  (setq consult-narrow-key "<"))

(use-package consult-ls-git
  :general
  ("M-s G f"  #'consult-ls-git)
  ("M-s G F"  #'consult-ls-git-other-window))

Add marginalia to minibuffer completions.

(use-package marginalia
  :init
  (marginalia-mode))

Action dispatch from minibuffer.

(use-package embark
  :general
  ("C-."   'embark-act)
  ("C-;"   'embark-dwim)
  ("C-h B" 'embark-bindings)
  :init
  (setq prefix-help-command #'embark-prefix-help-command)
  :config
  (add-to-list 'display-buffer-alist
               '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
                 nil
                 (window-parameters (mode-line-format . none)))))

(use-package embark-consult
  :after (embark consult)
  :demand t
  :hook
  (embark-collect-mode . consult-preview-at-point-mode))

Add icons to minibuffer.

(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))

corfu

Text completion framework.

(use-package corfu
  :demand
  :custom
  (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
  (corfu-auto t)  ;; Enable auto completion
  :init
  (global-corfu-mode))

Flycheck

Syntax checker.

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

Use flycheck for Eglot.

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

Flyspell

Use ==aspell== for spell checking.

(setq ispell-program-name "aspell")

rainbow-delimiters

Make corresponding delimiters the same color (e.g., {, (, “)

(use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode))

rainbow-mode

Set background color to strings that match color.

(use-package rainbow-mode
  :hook (prog-mode))

doom-modeline

doom-modeline mode line.

(use-package doom-modeline
  :ensure t
  :init (doom-modeline-mode 1)
  :config
  (setq doom-modeline-minor-modes t)
  (setq doom-modeline-modal-modern-icon nil))

Minions

Minimal mode line.

(use-package minions
  :config (minions-mode 1))

eyebrowse

Window manager.

(use-package eyebrowse
  :demand t
  :general
  (:keymaps 'eyebrowse-mode-map "C-w 1" 'eyebrowse-switch-to-window-config-1 :states '(normal visual emacs))
  (:keymaps 'eyebrowse-mode-map "C-w 2" 'eyebrowse-switch-to-window-config-2 :states '(normal visual emacs))
  (:keymaps 'eyebrowse-mode-map "C-w 3" 'eyebrowse-switch-to-window-config-3 :states '(normal visual emacs))
  (:keymaps 'eyebrowse-mode-map "C-w 4" 'eyebrowse-switch-to-window-config-4 :states '(normal visual emacs))
  :config
  (eyebrowse-mode t)
  ;; Conflicts with evil-commentary.
  ;; (eyebrowse-setup-evil-keys)
  (setq eyebrowse-new-workspace t))

Dashboard

Dashboard shown on startup.

(use-package dashboard
  :config
  (setq dashboard-items '((recents   . 5)
                          (bookmarks . 5)
                          (projects  . 5)
                          (agenda    . 5)
                          (registers . 5)))
  (setq dashboard-startup-banner 'logo)
  (dashboard-setup-startup-hook))

goto-line-preview

Preview line before jumping to it.

(use-package goto-line-preview
  :general
  ("M-g g" 'goto-line-preview))

alert

Alert system.

(use-package alert
  :config
  (when (eq system-type 'darwin)
    (setq alert-default-style 'osx-notifier)))

Treemacs

Treemacs - a tree layout file explorer for Emacs.

(use-package treemacs
  :config
  (treemacs-git-mode 'simple)
  (treemacs-follow-mode t)
  (treemacs-filewatch-mode t)
  (treemacs-fringe-indicator-mode t)
  :general
  ("C-c t" 'treemacs))

(use-package treemacs-evil)

(use-package treemacs-projectile)

(use-package treemacs-icons-dired
  :config (treemacs-icons-dired-mode))

(use-package treemacs-magit)

(use-package treemacs-all-the-icons)

Smex

Enhanced M-x command. Allows counsel-M-x to list commands by recently used.

(use-package smex)

ElDoc box

Displays ElDoc documentations in a childframe.

(use-package eldoc-box
  :hook ((eldoc-mode . eldoc-box-hover-mode)))

Coding and Dev Ops

Git

Git integration.

(use-package transient :ensure (:fetcher github :repo "magit/transient"))
(use-package magit
  :general ("C-x g" 'magit-status)
  :config
  (add-hook 'magit-diff-visit-file-hook  (lambda ()
                                           (when smerge-mode
                                             (unpackaged/smerge-hydra/body)))))

;; (use-package magit-libgit) ; Not being actively used yet.

Open files in remote Git portals.

(use-package git-link
  :config
  (setq git-link-open-in-browser t))

Travel through Git history.

(use-package git-timemachine)

Major modes for Git configuration files.

(use-package git-modes)

Resolve merge conflicts. From: https://github.com/alphapapa/unpackaged.el#smerge-mode.

(require 'hydra)
(require 'smerge-mode)
(defhydra unpackaged/smerge-hydra
  (:color pink :hint nil :post (smerge-auto-leave))
  "
^Move^       ^Keep^               ^Diff^                 ^Other^
^^-----------^^-------------------^^---------------------^^-------
_n_ext       _b_ase               _<_: upper/base        _C_ombine
_p_rev       _u_pper              _=_: upper/lower       _r_esolve
^^           _l_ower              _>_: base/lower        _k_ill current
^^           _a_ll                _R_efine
^^           _RET_: current       _E_diff
"
  ("n" smerge-next)
  ("p" smerge-prev)
  ("b" smerge-keep-base)
  ("u" smerge-keep-upper)
  ("l" smerge-keep-lower)
  ("a" smerge-keep-all)
  ("RET" smerge-keep-current)
  ("\C-m" smerge-keep-current)
  ("<" smerge-diff-base-upper)
  ("=" smerge-diff-upper-lower)
  (">" smerge-diff-base-lower)
  ("R" smerge-refine)
  ("E" smerge-ediff)
  ("C" smerge-combine-with-next)
  ("r" smerge-resolve)
  ("k" smerge-kill-current)
  ("ZZ" (lambda ()
          (interactive)
          (save-buffer)
          (bury-buffer))
   "Save and bury buffer" :color blue)
  ("q" nil "cancel" :color blue))

Projectile

Project (e.g., Git) management and navigation.

(use-package projectile
  :general
  ("C-c p" '(:keymap projectile-command-map))
  :config
  (projectile-mode))

libvterm

Emacs libvterm integration.

(use-package vterm)
(use-package multi-vterm)

Docker

Interface to Docker.

(use-package docker :general ("C-c o"  'docker))

Use Dockerfile tree-sitter mode.

(require 'dockerfile-ts-mode)

Kubernetes

Interface to Kubernetes.

(use-package kubernetes
  :commands (kubernetes-overview)
  :config
  (setq kubernetes-poll-frequency 3600
        kubernetes-redraw-frequency 3600))

EditorConfig

EditorConfig plugin.

(use-package editorconfig
  :config
  (editorconfig-mode 1))

origami

A text folding minor mode for Emacs.

(use-package origami)

Copilot.el

Unofficial integration with GitHub Copilot.

(use-package copilot
  :ensure (:host github :repo "zerolfx/copilot.el" :files ("dist" "*.el"))
  :config
  (add-hook 'prog-mode-hook 'copilot-mode)
  :general
  ("C-<tab>" 'copilot-accept-completion))

eglot

Built-in LSP integration.

(setq eglot-confirm-server-initiated-edits nil)

tree-sitter

Intelligently use tree-sitter major modes when possible.

(use-package treesit-auto
  :demand t
  :config
  (add-to-list 'treesit-auto-fallback-alist '(bash-ts-mode . sh-mode))
  (setq treesit-auto-install 'prompt)
  (global-treesit-auto-mode))

dotenv-mode

Major mode for editing .env files.

(use-package dotenv-mode
  :mode ("\\.env\\..*\\'" . dotenv-mode))

format-all

Formatting for many languages.

(use-package format-all)

File and language specific modes

Org mode

Use UTF-8 bullet points in org-mode.

(use-package org-bullets :hook (org-mode . org-bullets-mode))

HTML export.

(use-package htmlize)

Enable better mouse support for org mode.

(require 'org-mouse)

Flash cards in org mode.

(use-package org-drill :commands org-drill)

Edit and export Anki notes.

(use-package anki-editor)

Allow org babel to execute without confirmation.

(setq org-confirm-babel-evaluate nil)

Markdown

A major mode for Markdown (.md) files.

(use-package markdown-mode)

JavaScript / TypeScript

Load TypeScript mode with tree-sitter support.

(require 'typescript-ts-mode)
(defun deno-project-p ()
  "Determine if the current project is a Deno project."
  (or
   (locate-dominating-file default-directory "deno.json")
   (locate-dominating-file default-directory "import_map.json")))

(defun node-project-p ()
  "Determine if the current project is a Node project."
  (locate-dominating-file default-directory "package.json"))

;; Based on https://github.com/guilhermecomum/emacs.d/blob/main/readme.org#eglot
(defun ecma-server-program (_)
  "Decide which server to use for ECMA Script based on project characteristics."
  (cond ((node-project-p) '("typescript-language-server" "--stdio"))
        ((deno-project-p) '("deno" "lsp" :initializationOptions (:enable t :lint t)))
        (t                nil)))

(with-eval-after-load 'eglot
  ;; See: https://github.com/joaotavora/eglot/issues/525
  (put 'typescript-ts-mode 'eglot-language-id "typescript")
  (put 'js-ts-mode 'eglot-language-id "javascript")
  (add-to-list 'eglot-server-programs
               '((js-mode js-ts-mode tsx-ts-mode typescript-ts-mode typescript-mode) . ecma-server-program)))

Run Jest unit tests.

(use-package jest)

LaTeX

Utility for writing and exporting TeX files.

(use-package auctex
  ;; :ensure nil
  :ensure  (auctex :pre-build (("./autogen.sh")
                               ("./configure"
                                "--without-texmf-dir"
                                "--with-packagelispdir=./"
                                "--with-packagedatadir=./")
                               ("make"))
                   :build (:not elpaca--compile-info) ;; Make will take care of this step
                   :files ("*.el" "doc/*.info*" "etc" "images" "latex" "style")
                   :version (lambda (_) (require 'tex-site) AUCTeX-version))
  :config
  (setq TeX-parse-self t) ; Enable parse on load.
  (setq TeX-auto-save t)) ; Enable parse on save.

JSON

Mode for editing JSON files.

(use-package json-mode)

Lua

Mode for editing Lua files.

(use-package lua-mode)

Python

Always use Python 3.

(setq python-shell-interpreter "python3")

Haskell

Haskell major mode.

(use-package haskell-mode)

PDF Tools

Display and edit PDFs.

(use-package pdf-tools
  :mode  ("\\.pdf\\'" . pdf-view-mode)
  :config
  (setq-default pdf-view-display-size 'fit-page)
  (setq pdf-annot-activate-created-annotations t)
  (pdf-tools-install :no-query)
  (require 'pdf-occur))

YAML

YAML mode.

(use-package yaml-mode
  :mode ("\\.yml\\'" . yaml-mode))

GraphQL

GraphQL files.

(use-package graphql-mode)

Go

Go major mode.

(require 'go-ts-mode)

Rust

Rust major mode.

(require 'rust-ts-mode)

Transient interface for Cargo.

(use-package cargo-transient)

Protocol Buffers

Protocol Buffers support.

(use-package protobuf-mode)

Vimscript

Vimrc mode.

(use-package vimrc-mode
  :mode ("\\.vim\\(rc\\)?\\'"))

Swift

Swift mode.

(use-package swift-mode
  :config
  (with-eval-after-load 'eglot
    (add-to-list 'eglot-server-programs
                 '(swift-mode . ("xcrun" "sourcekit-lsp"))))
  )

Bash / Shell

Bash / Shell highlighting.

(require 'sh-script)
;; Load for .zsh, .zshrc, zshrc
(add-to-list 'auto-mode-alist '("\\.zsh\\'" . bash-ts-mode))
(add-to-list 'auto-mode-alist '("\\.zshrc\\'" . bash-ts-mode))
(add-to-list 'auto-mode-alist '("/zshrc\\'" . bash-ts-mode))

.NET

Setup C# LSP support.

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
               '(csharp-mode . ("csharp-ls"))))

Utilities

ESUP - Emacs Start Up Profiler

Emacs startup profiler.

(use-package esup)

persistent-scratch

Save and backup the \*scratch\* buffer.

(use-package persistent-scratch
  :config
  (setq persistent-scratch-backup-directory (concat user-emacs-directory "scratch"))
  (persistent-scratch-autosave-mode))

scratch

Create new scratch buffers with same major mode as current buffer.

(use-package scratch)

exec-path-from-shell

Inherit environment variables from SHELL.

(use-package exec-path-from-shell
  :if (memq window-system '(mac ns x))
  :config
  (dolist (var '("SSH_AUTH_SOCK" "SSH_AGENT_PID" "GPG_AGENT_INFO" "LANG" "GPG_ENCRYPTION_KEY_ID"))
    (add-to-list 'exec-path-from-shell-variables var))
  (exec-path-from-shell-initialize))

which-key

Display possible keybindings after an incomplete prefix.

(use-package which-key :config (which-key-mode))

Lorem Ipsum

Insert filler (lorem ipsum) text.

(use-package lorem-ipsum)

restclient

Major mode for debugging REST API calls.

(use-package restclient :mode (("\\.http\\'" . restclient-mode)))

wgrep

wgrep allows you to edit a grep buffer and apply those changes to the file buffer like sed interactively.

(use-package wgrep)

gptel

A simple, no-frills ChatGPT client for Emacs.

(use-package gptel
  :config
  (let* ((open-ai-auth (car (auth-source-search :host "OpenAI"))))
    (setq gptel-api-key (plist-get open-ai-auth :api_key))))

Fun

emacs-fireplace

Fireplace in Emacs.

(use-package fireplace)

wttrin.el

Display the weather.

(use-package wttrin
  :config
  ;; Patch for https://github.com/bcbcarl/emacs-wttrin/issues/16
  (defun wttrin-fetch-raw-string (query)
    "Get the weather information based on your QUERY."
    (let ((url-user-agent "curl"))
      (add-to-list 'url-request-extra-headers wttrin-default-accept-language)
      (with-current-buffer
          (url-retrieve-synchronously
           (concat "http://wttr.in/" query)
           (lambda (status) (switch-to-buffer (current-buffer))))
        (decode-coding-string (buffer-string) 'utf-8))))
  (setq wttrin-default-cities '("New York, NY" "Chicago, IL")))

XKCD

View XKCD comics.

(use-package xkcd
  :general
  (:states '(normal visual) :keymaps 'xkcd-mode-map "j" #'xkcd-next)
  (:states '(normal visual) :keymaps 'xkcd-mode-map "k" #'xkcd-prev))

Emoji

Display emoji.

(use-package emojify
  :hook
  (dashboard-mode  . emojify-mode)
  (org-mode        . emojify-mode)
  (org-agenda-mode . emojify-mode))

Adhoc Elisp functions

Helper function to reload init file.

(defun reload-init-file ()
  "Reload init.el."
  (interactive)
  (load-file (expand-file-name (concat user-emacs-directory "init.el"))))

Open a file in OS file explorer (source).

(defun browse-file-directory ()
  "Open the current file's directory however the OS would."
  (interactive)
  (if default-directory
      (browse-url-of-file (expand-file-name default-directory))
    (error "No `default-directory' to open")))

Load ad hoc script files. These are system specific and not checked in. The load-directory snippet is from the EmacsWiki.

(defun load-directory (dir)
  "Load all elisp files within DIR."
  (let ((load-it (lambda (f)
                   (load-file (concat (file-name-as-directory dir) f)))
                 ))
    (mapc load-it (directory-files dir nil "\\.el$"))))

(let ((site-lisp (concat user-emacs-directory "site-lisp")))
  (when (file-directory-p site-lisp)
    (load-directory site-lisp)
    (add-to-list 'load-path site-lisp)))

About

My Emacs configuration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published