aboutsummaryrefslogtreecommitdiff

Introduction

This is my Vanilla Emacs configuration, made to work with my NixOS configuration. For that reason, you will not see :ensure t inside any use-package declaration, for emacs packages are all compiled natively and reproducibly on the NixOS side. This configuration uses the emacs-lisp language only to configure variables for said packages, for the most part.

User

Change these variables:

(setq system-email "ret2pop@gmail.com")
(setq system-username "prestonpan")
(setq system-fullname "Preston Pan")

Emacs

(use-package emacs
  :custom
  (scroll-conservatively 101)
  (display-time-24hr-format t)
  (display-line-numbers-type 'relative)
  (use-short-answers t)
  (make-backup-files nil)
  (warning-minimum-level :emergency)
  (debug-ignored-errors
   (cons 'remote-file-error debug-ignored-errors))
  (mouse-wheel-scroll-amount '(1 ((shift) . 1)))
  (mouse-wheel-progressive-speed nil)
  (mouse-wheel-follow-mouse 't)
  (scroll-step 1)
  (display-fill-column-indicator-column 100)
  :config
  (require 'tex-site)
  (pixel-scroll-precision-mode 1)
  (display-battery-mode 1)
  (display-time-mode 1)
  (menu-bar-mode -1)
  (scroll-bar-mode -1)
  (tool-bar-mode -1)
  (and window-system (server-start))
  (load-theme 'catppuccin :no-confirm)
  (set-face-attribute 'default nil :height 120)
  (set-frame-parameter nil 'alpha-background 90)
  (add-to-list 'default-frame-alist '(alpha-background . 90))
  (set-face-attribute 'default nil :font "Iosevka Nerd Font" :height 140)
  (setq-default line-spacing 2)
  (setq-default fill-column 100)
  (global-prettify-symbols-mode 1)

  :hook ((text-mode . auto-fill-mode)
   (text-mode . visual-line-mode)
   (prog-mode . auto-fill-mode)
   (prog-mode . display-line-numbers-mode)
   (prog-mode . display-fill-column-indicator-mode)
   (org-mode . auto-fill-mode)
   (org-mode . display-fill-column-indicator-mode)

   (org-mode . (lambda ()
                 (setq prettify-symbols-alist
                   '(("#+begin_src" . ?)
                     ("#+BEGIN_SRC" . ?)
                     ("#+end_src" . ?)
                     ("#+END_SRC" . ?)
                     ("#+begin_example" . ?)
                     ("#+BEGIN_EXAMPLE" . ?)
                     ("#+end_example" . ?)
                     ("#+END_EXAMPLE" . ?)
                     ("#+header:" . ?)
                     ("#+HEADER:" . ?)
                     ("#+name:" . ?﮸)
                     ("#+NAME:" . ?﮸)
                     ("#+results:" . ?)
                     ("#+RESULTS:" . ?)
                     ("#+call:" . ?)
                     ("#+CALL:" . ?)
                     (":PROPERTIES:" . ?)
                     (":properties:" . ?)
                     ("lambda" . )
                     ("->"     . ?→)
                     ("map"    . ?↦)
                     ("/="     . ?≠)
                     ("!="     . ?≠)
                     ("=="     . ?≡)
                     ("<="     . ?≤)
                     (">="     . ?≥)
                     ("&&"     . ?∧)
                     ("||"     . ?∨)
                     ("sqrt"   . ?√)
                     ("..."    . ?…)))
             (prettify-symbols-mode)))
   (prog-mode .
              (lambda ()
                (setq prettify-symbols-alist
                  '(("lambda" . ?λ)
                    ("->"     . ?→)
                    ("map"    . ?↦)
                    ("/="     . ?≠)
                    ("!="     . ?≠)
                    ("=="     . ?≡)
                    ("<="     . ?≤)
                    (">="     . ?≥)
                    ("&&"     . ?∧)
                    ("||"     . ?∨)
                    ("sqrt"   . ?√)
                    ("..."    . ?…)))
                (prettify-symbols-mode)))))

Org Mode

(use-package org
  :init
  (setq org-confirm-babel-evaluate nil)
  (setq org-export-with-broken-links t)
  (setq org-src-fontify-natively t)
  (setq org-latex-preview-image-directory (expand-file-name "~/.cache/ltximg/"))
  (setq org-preview-latex-image-directory (expand-file-name "~/.cache/ltximg/"))
  (setq org-latex-pdf-process
  '("xelatex -interaction=nonstopmode -output-directory=%o %f"))
  (setq preview-default-option-list '("displaymath" "textmath" "graphics"))
  (setq preview-image-type 'png)
  (setq TeX-engine 'xetex)
  (setq TeX-PDF-mode t)
  (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5))
  (setq org-return-follows-link t)
  (setq org-startup-with-latex-preview t)
  (setq org-habit-preceding-days 1)
  (setq-default org-startup-indented t
          org-pretty-entities t
          org-use-sub-superscripts "{}"
          org-hide-emphasis-markers t
          org-startup-with-inline-images t
          org-image-actual-width '(300))
  (setq org-agenda-files (list "~/monorepo/agenda.org"
                 "~/org/notes.org"
                 "~/org/agenda.org"))
  (setq org-default-notes-file (concat org-directory "/notes.org"))
  (setq org-publish-project-alist
  '(("website-org"
     :base-directory "~/monorepo"
     :base-extension "org"
     :publishing-directory "~/website_html"
     :recursive t
     :publishing-function org-html-publish-to-html
     :headline-levels 4
     :html-preamble t
     :html-preamble-format (("en" "<p class=\"preamble\"><a href=\"/index.html\">home</a> | <a href=\"./index.html\">section main page</a></p><hr>")))
    ("website-static"
     :base-directory "~/monorepo"
     :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|ico\\|asc\\|pub\\|webmanifest\\|xml"
     :publishing-directory "~/website_html/"
     :recursive t
     :publishing-function org-publish-attachment)
    ("website" :auto-sitemap t :components ("website-org" "website-static"))))
  (setq org-html-postamble "Copyright © 2024 Preston Pan")
  :config
  (require 'ox-publish)
  (require 'org-tempo)
  (require 'org-habit)
  (org-babel-do-load-languages 'org-babel-load-languages
                 '((shell . t)
               (python . t)
               (latex . t))))

Unicode

(use-package unicode-fonts
  :init (unicode-fonts-setup))

Autopair

Use electric-pair to automatically complete pairs of things. We need to change what electric-pair does based on the mode.

(use-package electric-pair
  :hook ((org-mode . electric-pair-mode)
   (prog-mode . electric-pair-mode)))

Lyrics

(use-package lyrics-fetcher
  :after (emms)
  :config
  (setq lyrics-fetcher-genius-access-token
    (password-store-get "genius_api"))
  (lyrics-fetcher-use-backend 'genius))

Fragtog

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

Snippets

(use-package yasnippet
  :config
  (add-to-list 'yas-snippet-dirs "~/monorepo/yasnippet/")
  (yas-global-mode 1)
  :hook (org-mode . (lambda () (yas-minor-mode) (yas-activate-extra-mode 'latex-mode))))

Completion

Company-mode! We need this to do autocomplete stuff.

(use-package company
  :config
  '(add-to-list 'company-backends
      '(company-ispell company-capf company-irony
               company-yasnippet company-files))
  :hook ((after-init . global-company-mode)))

Spelling

(use-package ispell
  :init
  (setq ispell-program-name "aspell")
  (setq ispell-silently-savep t)
  (setq ispell-dictionary "en")
  (setq ispell-alternate-dictionary "~/.local/share/dict"))

(use-package flyspell
  :hook (text-mode . flyspell-mode))

Packages

First, some small configurations and some evil-mode initilaization because I like vim keybindings:

(use-package evil
  :init
  (setq evil-want-keybinding nil)
  :config
  (evil-mode 1)
  (evil-set-undo-system 'undo-redo))

(use-package evil-collection
  :after (evil)
  :init
  (setq evil-want-keybinding nil)
  :config
  (evil-collection-init))
(with-eval-after-load 'evil-maps
(define-key evil-motion-state-map (kbd "SPC") nil)
(define-key evil-motion-state-map (kbd "RET") nil)
(define-key evil-motion-state-map (kbd "TAB") nil))

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

(use-package evil-org
  :after (evil org) 
  :hook (org-mode . (lambda () evil-org-mode))
  :config
  (require 'evil-org-agenda)
  (evil-org-agenda-set-keys))

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

(use-package page-break-lines
  :init
  (page-break-lines-mode))
(evil-set-initial-state 'pdf-view-mode 'normal)

Journal

I use org-journal to journal about my life, and it\'s a part of my website:

(use-package org-journal
  :after (org)
  :init
    (setq org-journal-dir "~/monorepo/journal/")
    (setq org-journal-date-format "%A, %d %B %Y")

    (defun org-journal-file-header-func (time)
    "Custom function to create journal header."
    (concat
  (pcase org-journal-file-type
    (`daily "#+TITLE: Daily Journal\n#+STARTUP: showeverything\n#+DESCRIPTION: My daily journal entry\n#+AUTHOR: Preston Pan\n#+HTML_HEAD: <link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\" />\n#+html_head: <script src=\"https://polyfill.io/v3/polyfill.min.js?features=es6\"></script>\n#+html_head: <script id=\"MathJax-script\" async src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js\"></script>\n#+options: broken-links:t")
    (`weekly "#+TITLE: Weekly Journal\n#+STARTUP: folded")
    (`monthly "#+TITLE: Monthly Journal\n#+STARTUP: folded")
    (`yearly "#+TITLE: Yearly Journal\n#+STARTUP: folded"))))

  (setq org-journal-file-header 'org-journal-file-header-func)
  (setq org-journal-file-format "%Y%m%d.org")
  (setq org-journal-enable-agenda-integration t))

Doom Modeline

The default modeline is ugly.

(use-package doom-modeline
  :config
  (doom-modeline-mode 1))

Grammar

I want to write good!

(use-package writegood-mode
  :hook (text-mode . writegood-mode))

Make Org Look Better

Org superstar adds those nice looking utf-8 bullets:

(use-package org-superstar
  :after (org)
  :hook (org-mode . (lambda () (org-superstar-mode 1))))

LSP

We set up eglot, the LSP manager for emacs, now built in:

(use-package eglot
  :config
  (add-to-list 'eglot-server-programs '(nix-mode . ("nil")))
  :hook
  (prog-mode . eglot-ensure)
  (nix-mode . eglot-ensure))
(use-package lsp
  :hook
  (prog-mode . lsp))
(use-package platformio-mode
  :hook (prog-mode . platformio-conditionally-enable))

C/C++

(use-package irony-mode
  :hook (
  (c++-mode . irony-mode)
  (c-mode . irony-mode)
  (objc-mode . irony-mode)
  (iro