Skip to content

Latest commit

 

History

235 Commits

Folders and files

Repository files navigation

Emacs Configuration

Overview

A lightweight GNU Emacs 31.1 configuration focused on Rust (eglot + rust-analyzer + tree-sitter) and Org-mode notes. It also borrows several ideas from Neovim (telescope-style search, flash-style jumps, surround-style editing).

The configuration is modular: each plugin lives in its own file under ~/.config/emacs/modules/. init.el loads them in order; early-init.el sets up package mirrors, quickstart, and GC tuning. For fast emacs --daemon startup, non-essential packages are deferred (:defer 1 loads them 1s after idle) and the native-comp cache is warmed in the background (see Notes).

Requirements

Run ./install-dependencies.sh to install the system packages, or install them manually.

PackageUsed by
ripgrepconsult-ripgrep (live grep)
fddirvish (fast file search)
libvips (vipsthumbnail)dirvish (image preview)
popplerdirvish (PDF preview)
graphvizorg-roam (graph layout, fdp)
cmake libvtermvterm (terminal module)
ffmpegthumbnailerdirvish (video thumbnails, optional)
texlive-coreorg-mode LaTeX preview (dvisvgm, optional)

Non-pacman dependencies:

rust-analyzer
rustup component add rust-analyzer
mmdc (mermaid-cli)
npm install -g @mermaid-js/mermaid-cli (for ob-mermaid)
Rust tree-sitter grammar
compiled and placed in ~/.config/emacs/tree-sitter/

ELPA packages are installed automatically on first launch via use-package :ensure t.

Install

git clone <this-repo> ~/.config/emacs
cd ~/.config/emacs
./install-dependencies.sh

Launch Emacs. Packages install automatically on the first run.

Plugins

Each plugin lives in its own file under modules/. init.el loads redirect-file-config.el first, then the rest in alphabetical order.

Appearance

ui-config.el
font (JetBrainsMono NF), absolute line numbers, pixel scrolling, UI chrome
keycast-config.el
keycast (show pressed keys on the mode line)
which-key-config.el
which-key (keybinding hints popup)

Editing

paren-config.el
show-paren (highlight matching pair) + electric-pair (auto-insert pairs)
editing-config.el
global editing defaults (delete-selection, no tabs, auto-chmod scripts, …)
auto-revert-config.el
auto-revert buffers when files change on disk
so-long-config.el
fall back to fundamental-mode for files with very long lines
repeat-config.el
repeat commands by pressing only their last key
embrace-config.el
add/change/delete surrounding pairs (surround.nvim style)

Navigation

better-jumper-config.el
jump list (C-c j b / C-c j f)
avy-config.el
jump to visible text via labels (flash.nvim style)

Completion and search (vertico + consult stack)

vertico-config.el
vertical minibuffer completion UI
orderless-config.el
out-of-order fuzzy matching
marginalia-config.el
annotate candidates with descriptions
embark-config.el
contextual actions on candidates / things at point
consult-config.el
interactive search/navigation (telescope replacement)
consult-eglot-config.el
LSP workspace symbol search through consult
symbol-overlay-config.el
highlight all occurrences of the symbol at point
completion-config.el
global completion defaults (Tab completes, vertical list)
corfu-config.el
in-buffer completion popup (auto-trigger + docs)
cape-config.el
extra completion-at-point backends (dabbrev, files, keywords, elisp)

Buffers, windows, files

ibuffer-config.el
ibuffer (advanced buffer list, replaces list-buffers)
recentf-config.el
track recently opened files
savehist-config.el
persist minibuffer history, kill ring, search rings
dired-config.el
dired defaults (dwim target, auto-revert)
window-config.el
winner undo/redo + windmove + display rules
dirvish-config.el
yazi-style file manager (two-pane dir + preview)
nerd-icons-config.el
nerd-icons fonts (completion/corfu/ibuffer/marginalia; dirvish draws its own icons, so nerd-icons-dired is disabled)

IDE / LSP

eglot-config.el
LSP client (rust-analyzer)
exec-path-from-shell-config.el
import shell env for GUI/daemon
editorconfig-config.el
apply .editorconfig project settings
flymake-config.el
diagnostics navigation
flymake-popon-config.el
show diagnostics in a popup near point
rust-config.el
rust-ts-mode remap + cargo commands

Git / shell

magit-config.el
magit (git porcelain)
diff-hl-config.el
inline git change indicators
vterm-config.el
vterm (terminal emulator)

Org-mode

org-config.el
org-mode (agenda, capture, latex preview)
ob-mermaid-config.el
mermaid diagrams in org-babel source blocks
ox-gfm-config.el
GitHub Flavored Markdown export backend
org-roam-config.el
networked notes (backlinks, graph)

Utilities / housekeeping

helper-config.el
helper commands (add lexical-binding header, fullwidth→halfwidth)
redirect-file-config.el
redirect cache/config files into var/ (org-roam db, tramp, eww, eshell, bookmarks, transient, backups, auto-saves, recentf, …)

Keybindings

Navigation

KeyAction
C-c j bjump backward (better-jumper)
C-c j fjump forward (better-jumper)
M-g cjump to a character (avy)
M-g ljump to a line (avy)

Jump points are recorded automatically before xref/consult/consult-eglot/avy/ org-roam/mark navigation commands, so C-c j b / C-c j f can navigate them.

Search (consult)

KeyAction
C-x bfuzzy switch buffer/file
M-s lfuzzy search in current buffer (consult-line)
M-s glive grep in project (consult-ripgrep)
M-s rrestore search history (consult-history)
M-g ggo to line (consult-goto-line)
M-g ioutline/imenu navigation (consult-imenu)
M-yfuzzy yank (consult-yank-pop)

Embark

KeyAction
C-.act on target (embark-act)
C-;do the right thing (embark-dwim)

LSP (eglot, in Rust buffers)

KeyAction
C-c l acode actions
C-c l rrename
C-c l fformat buffer
C-c l .go to definition
C-c l ,go to references
C-c l sworkspace symbols

Symbol (symbol-overlay, in code buffers)

KeyAction
M-njump to next same symbol
M-pjump to previous same symbol

Diagnostics

KeyAction
C-c qlist diagnostics (consult-flymake)
C-c ! nnext error (flymake)
C-c ! pprevious error (flymake)

Surround editing

KeyAction
C-c e aadd a surrounding pair
C-c e cchange surrounding pair
C-c e ddelete surrounding pair

Files (dirvish)

KeyAction
C-x dopen dirvish (replaces dired)
C-c dopen dirvish sidebar

Windows

KeyAction
C-c w u / C-c w rundo / redo layout
C-c w n/p/b/fmove down/up/left/right

Cargo (Rust)

KeyAction
C-c C-c C-urust-compile
C-c C-c C-krust-check
C-c C-c C-trust-test
C-c C-c C-lrust-run-clippy
C-c C-frust-format-buffer

Text tools

KeyAction
C-c C-t pconvert fullwidth to halfwidth (CJK to ASCII)

Git (magit)

KeyAction
C-x gmagit-status
C-c gmagit-dispatch
C-c fmagit-file-dispatch

Org

KeyAction
C-c aorg-agenda
C-c corg-capture

Org-roam

KeyAction
C-c n ffind or create a note (org-roam-node-find)
C-c n iinsert a link to an existing note
C-c n ltoggle the backlinks sidebar
C-c n gshow the notes graph
C-c n tadd a tag to the current note
C-c n aadd an alias to the current note

Buffers

KeyAction
C-x C-bibuffer (advanced buffer list, remaps list-buffers)

Other

KeyAction
C-c pcape commands

Notes

  • Startup speed: emacs --daemon startup is kept fast by (1) deferring non-essential packages — the completion stack (vertico / marginalia / orderless / corfu / which-key) uses :defer 1 (loaded 1s after idle), ox-gfm loads :after org, and the heavy ones (magit / org-roam / vterm / org) are deferred; and (2) native compilation is kept non-blocking: package-native-compile is nil (no compile during install), native-comp-jit-compilation is t (async JIT: bytecode first, native code compiled in the background), native-comp-async-report-warnings-errors is nil (silent), and init.el pre-warms the cache via native-compile-async over elpa/. early-init.el no longer nils out file-name-handler-alist (that hack conflicted with native-comp). Note: the first run is still slow mainly because ~30 packages are downloaded over the network, not because of compilation.
  • Rust mode: .rs files open in the tree-sitter rust-ts-mode. The rust-mode package is kept only for the cargo commands.
  • Dirvish extensions: dirvish installs its optional extensions (dirvish-icons, dirvish-subtree, dirvish-collapse, dirvish-side, …) under elpa/dirvish-<ver>/extensions/, which is not on the load-path by default. dirvish-config.el adds it so that nerd-icons / subtree-state / collapse attributes work (otherwise dirvish errors with Cannot open load file dirvish-icons). For the same reason dirvish-side is autoloaded explicitly (:bind would mis-autoload it from dirvish).
  • Dirvish layout: dirvish-default-layout is set to '(0 0 0.4), a clean two-pane current dir | preview split. The upstream default '(1 0.11 0.55) also opens parent-directory panes, which clutter the frame. dirvish-use-header-line and dirvish-use-mode-line are both set to nil because Dirvish draws those as extra windows (above/below the panes).
  • Dirvish sidebar size: the sidebar width is dirvish-side-width (integer columns, default 35). Set it in dirvish-config.el to resize, e.g. =#+begin_src emacs-lisp (setq dirvish-side-width 30) ; narrower sidebar

    Its position is controlled by dirvish-side-display-alist (default ((side . left) (slot . -1)); set side to right to flip it).

  • Dirvish image preview: previews (images, pdf, video thumbnails) only appear in the full-frame layout (C-x d / M-x dirvish), which has a dedicated preview pane. The sidebar (C-c d / dirvish-side) is a plain tree view with no preview window. Image preview needs vipsthumbnail (from libvips); video thumbnails need ffmpegthumbnailer.
  • Fonts: the icons need a Nerd Font (JetBrainsMono NF is used). If icons look broken, run M-x nerd-icons-install-fonts.
  • Tree-sitter: grammars go in ~/.config/emacs/tree-sitter/ and are found automatically through treesit-extra-load-path.

About

my emacs' configs

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages