the big refactor

This commit is contained in:
Jacob Janzen 2024-10-01 17:42:59 -05:00
parent 7a347653df
commit 7b0ea5cbda
59 changed files with 827 additions and 834 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
tmp.org

View file

@ -1,38 +1,89 @@
.PHONY: install update nixos-update nixos-install
.PHONY: install update macos-update macos-install nixos-update nixos-install fonts
SYSTEM = $(shell uname -n)
# Determine the current system from its hostname.
# My university network changes my hostname on my laptop. I use the disgusting system_profiler pipeline to get the real hostname
# if the uname command fails
SYSTEM := $(shell uname -n)
ifeq ($(wildcard src/$(project)/*),)
SYSTEM = $(shell system_profiler SPSoftwareDataType | grep "Computer Name" | xargs | sed 's/Computer Name: //' | sed 's/$$/.local/')
endif
# Set directories
SRCDIR = ./$(SYSTEM)
DSTDIR = $(HOME)
FONTSDIR = .local/share/fonts
# Get the list of files that need to be generated
SOURCES := $(shell find -L $(SRCDIR)/ -type f)
CONFIGS := $(subst $(SRCDIR)/,$(DSTDIR)/,$(SOURCES:%.org=%))
NOGPG := $(SOURCES:%.gpg=%)
NOORG := $(NOGPG:%.org=%)
CONFIGS := $(subst $(SRCDIR)/,$(DSTDIR)/,$(NOORG))
# Set any extra targets based on the hostname
UPDATE_TARGET :=
INSTALL_TARGET :=
ifeq ($(SYSTEM), nixos)
UPDATE_TARGET += nixos-update
INSTALL_TARGET += nixos-install
else ifeq ($(SYSTEM), macos.local)
UPDATE_TARGET += macos-update
INSTALL_TARGET += macos-install
endif
# update by default, install first
all: update
update: install $(UPDATE_TARGET)
# install configs and any additional targets
install: $(CONFIGS) $(INSTALL_TARGET)
# ignored files
%.tar.gz:
:
# install encrypted org configs
$(DSTDIR)/%: $(SRCDIR)/%.org.gpg
mkdir -p $(dir $@)
gpg -d --batch $< 1> tmp.org
python3 ./extract_src.py tmp.org $@
rm tmp.org
# install org configs
$(DSTDIR)/%: $(SRCDIR)/%.org
mkdir -p $(dir $@)
python3 ./extract_src.py $< $@
# install generic files
$(DSTDIR)/%: $(SRCDIR)/%
mkdir -p $(dir $@)
cp $< $@
# install fonts
fonts: $(DSTDIR)/$(FONTSDIR)/.ComputerModern $(DSTDIR)/$(FONTSDIR)/.SauceCodePro
-fc-cache -f
$(DSTDIR)/$(FONTSDIR)/.ComputerModern: $(SRCDIR)/$(FONTSDIR)/ComputerModern.tar.gz
mkdir -p $(DSTDIR)/$(FONTSDIR)
tar xf $(SRCDIR)/$(FONTSDIR)/ComputerModern.tar.gz -C $(DSTDIR)/$(FONTSDIR)
touch $(DSTDIR)/$(FONTSDIR)/.ComputerModern
$(DSTDIR)/$(FONTSDIR)/.SauceCodePro: $(SRCDIR)/$(FONTSDIR)/SauceCodePro.tar.gz
mkdir -p $(DSTDIR)/$(FONTSDIR)
tar xf $(SRCDIR)/$(FONTSDIR)/SauceCodePro.tar.gz -C $(DSTDIR)/$(FONTSDIR)
touch $(DSTDIR)/$(FONTSDIR)/.SauceCodePro
# macos update just runs brew upgrade
macos-update: install
brew upgrade
# macos install also install fonts and tells System Events to update the wallpaper
macos-install: $(CONFIGS) fonts
osascript -e "tell application \"System Events\" to tell every desktop to set picture to \"/$$HOME/.wallpaper\" as POSIX file"
# nixos update backs up the flake lock file
nixos-update: install
nix flake update $(DSTDIR)/.flake
cp $(DSTDIR)/.flake/flake.lock $(SRCDIR)/.flake
sudo nixos-rebuild switch --flake $(DSTDIR)/.flake
# nixos install runs nixos-rebuild switch to install everything declaratively
nixos-install: $(CONFIGS)
sudo nixos-rebuild switch --flake $(DSTDIR)/.flake

View file

@ -0,0 +1,39 @@
#+title: Emacs RSS Feed
#+begin_src org :tangle ~/.config/emacs/feed.org :mkdirp yes
,* Blogs
:PROPERTIES:
:ID: elfeed
:END:
,** Journalism :journalism:
,*** [[https://waxy.org/feed/][Waxy.org]]
,*** [[https://pluralistic.net/feed/][Cory Doctorow]] :technology:software:fiction:
,** Computer Science :cs:
,*** [[https://a.exozy.me/index.xml][Some Random Website]] :math:algorithms:fiction:
,** Technology :technology:
,*** [[https://ciechanow.ski/atom.xml][Bartosz Ciechanowshki]]
,*** [[https://www.citationneeded.news/rss/][Citation Needed]]
,*** [[https://www.lilysthings.org/blog/rss.xml][The Cool Blog]]
,** Software :software:
,*** [[https://eieio.games/feed.xml][eieio.games]]
,*** [[https://ersei.net/en/blog.atom][Ersei]]
,*** [[https://lilysthings.org/blog/rss.xml][Lily's Things]]
,*** [[https://ntietz.com/atom.xml][Technically a Blog]]
,*** [[https://alexwlchan.net/atom.xml][Alex Chan]]
,*** [[https://eaton-works.com/feed.atom][Eaton Works]] :hacking:
,*** [[https://computer.rip/rss.xml][Computer's Are Bad]] :technology:
,*** [[https://mark.stosberg.com/rss/][Mark Stosberg]] :biking:
,*** [[https://maia.crimew.gay/feed.xml][Maia Crimew]] :internet:hacking:
,*** [[https://drewdevault.com/blog/index.xml][Drew DeVault]]
,** Comics :comic:
,*** [[https://xkcd.com/atom.xml][XKCD]]
,** People I know
,*** [[https://www.weavingwatersexpedition.com/news?format=rss][Weaving Waters Expedition]] :journalism:
,*** [[https://pinkish.bearblog.dev/feed/][Pinkish]] :software:
,*** [[https://jjanzen.ca/rss.xml][Me]] :software:review:
,** Internet Infrastructure :internet:software:
,*** [[https://daniel.haxx.se/blog/feed/][cURL]]
,*** [[https://blog.archive.org/feed/][Archive.org]]
,** Reviews :review:
,*** [[https://mountainofink.com/?format=rss][Mountain of Ink]]
#+end_src

View file

@ -0,0 +1,8 @@
#+title: Emacs Force the Usage of a =custom.el= File
Force the usage of a =custom.el= file for customizations instead of placing them in =init.el=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/force-custom-file.el :mkdirp yes
(setq custom-file (concat user-emacs-directory "custom.el"))
(when (file-exists-p custom-file)
(load custom-file))
#+end_src

View file

@ -0,0 +1,10 @@
#+title: Emacs Configuration
Load files for config.
#+begin_src emacs-lisp :tangle ~/.config/emacs/init.el :mkdirp yes
(load "~/.config/emacs/force-custom-file.el")
(load "~/.config/emacs/package-setup.el")
(load "~/.config/emacs/user-interface.el")
(load "~/.config/emacs/tools.el")
(load "~/.config/emacs/languages.el")
#+end_src

View file

@ -0,0 +1,148 @@
#+title: Emacs Programming Language Setup
* Shell Script
Run =eglot= on shell script files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'sh-mode-hook 'jj/eglot-setup)
#+end_src
* C
Run =eglot= on C and C++ files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'c-mode-hook 'jj/eglot-setup)
(add-hook 'c++-mode-hook 'jj/eglot-setup)
(add-hook 'cc-mode-hook 'jj/eglot-setup)
#+end_src
Run =eglot= on CMake files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package cmake-mode
:init
(add-hook 'cmake-mode-hook 'jj/eglot-setup))
#+end_src
Turn off C mode in =lex= and =yacc= files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-to-list 'auto-mode-alist '("\\.l$" . prog-mode))
(add-to-list 'auto-mode-alist '("\\.y$" . prog-mode))
#+end_src
* Web
Run =eglot= on HTML files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'html-mode-hook 'jj/eglot-setup)
#+end_src
Run =eglot= on CSS files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'css-mode-hook 'jj/eglot-setup)
#+end_src
Run =eglot= on JavaScript files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'js-json-mode-hook 'jj/eglot-setup)
(add-hook 'js-mode-hook 'jj/eglot-setup)
#+end_src
* Python
Run =eglot= on Python files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'python-mode-hook 'jj/eglot-setup)
#+end_src
* Go
Install Go support and run =eglot= on Go files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package go-mode
:init
(add-hook 'go-mode-hook 'jj/eglot-setup))
#+end_src
Get documentation for Go variables, functions, and arguments.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package go-eldoc
:init
(add-hook 'go-mode-hook 'go-eldoc-setup))
#+end_src
Automatically generate tests in Go.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package go-gen-test)
#+end_src
Get refactoring tools from =go-guru=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package go-guru
:hook (go-mode . go-guru-hl-identifier-mode))
#+end_src
* Lua
Install Lua support and run =eglot= on Lua files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package lua-mode
:init
(add-hook 'lua-mode-hook 'jj/eglot-setup))
#+end_src
Better Lisp editing with =lispy=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package lispy
:hook (emacs-lisp-mode . lispy-mode))
(use-package lispyville
:after lispy
:hook (lispy-mode . lispyville-mode))
#+end_src
Better parentheses handling in lisp with =parinfer-rust-mode=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package parinfer-rust-mode
:hook (emacs-lisp-mode . parinfer-rust-mode)
:init
(setq parinfer-rust-auto-download t))
#+end_src
* Markdown
Install Markdown support and run =eglot= on Markdown files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package markdown-mode
:init
(add-hook 'markdown-mode-hook 'jj/eglot-setup))
#+end_src
* LaTeX
Run =eglot= on TeX files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'tex-mode-hook 'jj/eglot-setup)
#+end_src
Use AUCTeX for extra LaTeX integration.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package auctex
:config
(add-hook 'LaTeX-mode-hook 'jj/eglot-setup)
(add-hook 'LaTeX-mode-hook
(lambda ()
(put 'LaTeX-mode 'eglot-language-id "latex"))))
#+end_src
Use CDLaTeX for environment and macro insertion.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package cdlatex
:config
(add-hook 'LaTeX-mode-hook #'turn-on-cdlatex))
#+end_src
* YAML
Install YAML support and run =eglot= on YAML files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package yaml-mode
:init
(add-hook 'yaml-mode-hook 'jj/eglot-setup))
#+end_src
* Nix
Install =nix= support and run =eglot= on =nix= files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package nix-mode
:mode "\\.nix\\'")
#+end_src

View file

@ -0,0 +1,25 @@
#+title: Emacs Package Setup
Install =straight= for better package management.
#+begin_src emacs-lisp :tangle ~/.config/emacs/package-setup.el :mkdirp yes
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
#+end_src
Install =use-package= for declarative package installation. Make =use-package= default to =ensure t= so that packages are enabled if they are declared.
#+begin_src emacs-lisp :tangle ~/.config/emacs/package-setup.el :mkdirp yes
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
#+end_src

View file

@ -0,0 +1,391 @@
#+title: Emacs Tool Setup
* Vi Keybindings
Use =vi= keybindings with =evil=. Set the undo system to =undo-fu=. Wrapped lines can be moved between with =j= and =k=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package evil
:init
(setq evil-want-keybinding nil)
:config
(evil-mode)
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
(evil-global-set-key 'motion (kbd "RET") nil)
:custom
(evil-undo-system 'undo-fu))
#+end_src
Use =evil-collection= to include =vi= keybindings in extra modes.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package evil-collection
:after evil
:config
(evil-collection-init))
#+end_src
* Undo
Better undo with =undo-fu=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package undo-fu)
#+end_src
Make undo persistent when closing Emacs with =undo-fu-session=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package undo-fu-session
:init (undo-fu-session-global-mode 1))
#+end_src
* Lookup
Better lookup with =dumb-jump=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package dumb-jump
:init (add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
#+end_src
* Version Control
Install Magit for Git integration.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package magit)
#+end_src
* Remote Editing
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq tramp-default-method "ssh")
#+end_src
* Document Viewing
Replace =DocView= with a better document viewer from =pdf-tools=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package pdf-tools
:config
(pdf-tools-install)
:init
(add-hook 'pdf-view-mode-hook #'(lambda () (display-line-numbers-mode -1)))
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
:config
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
TeX-source-correlate-start-server t))
#+end_src
Save place in PDFs with =saveplace-pdf-view=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package saveplace-pdf-view
:config (save-place-mode 1))
#+end_src
* Org-Mode
Ensure that =org= is set up before any of this.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package org)
#+end_src
Set my =org-mode= directory.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq org-directory "~/org")
#+end_src
Hide emphasis markers because I can see if something is *bold*, /italic/, or =monospace= without needing to see the markers.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq org-hide-emphasis-markers t)
#+end_src
Set up nicer looking bullet points.
- they look like circles
- instead of hyphens
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
#+end_src
Set up fonts. Don't use =monospace= by default. Do use it where necessary though. Also, make different heading levels different sizes.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(add-hook 'org-mode-hook 'variable-pitch-mode)
(custom-set-faces
`(variable-pitch ((t :font ,jj/var-font)))
`(fixed-pitch ((t :font ,jj/mono-font)))
'(org-block ((t (:inherit fixed-pitch))))
'(org-code ((t (:inherit (shadow fixed-pitch)))))
'(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
'(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
'(org-verbatim ((t (:inherit (shadow fixed-pitch)))))
'(org-table ((t (:inherit (shadow fixed-pitch)))))
'(org-document-title ((t (:inherit title :height 2.0 :underline nil))))
'(org-level-1 ((t (:inherit outline-1 :weight: bold :height 1.75))))
'(org-level-2 ((t (:inherit outline-2 :weight: bold :height 1.5))))
'(org-level-2 ((t (:inherit outline-3 :weight: bold :height 1.25))))
'(org-level-2 ((t (:inherit outline-4 :weight: bold :height 1.1))))
'(org-level-4 ((t (:inherit outline-4 :height 1.1))))
'(org-level-5 ((t (:inherit outline-5 :height 1.0))))
)
#+end_src
Wrap lines and centre the view to make for a nicer reading experience.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package visual-fill-column)
(add-hook 'org-mode-hook 'visual-line-mode)
(add-hook 'org-mode-hook #'(lambda () (display-line-numbers-mode -1)))
(defun jj/org-mode-visual-fill ()
(setq visual-fill-column-width 100
visual-fill-column-center-text t)
(visual-fill-column-mode 1))
(add-hook 'org-mode-hook #'jj/org-mode-visual-fill)
#+end_src
Increase the size of LaTeX previews.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
#+end_src
Follow links with the return key.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq org-return-follows-link t)
#+end_src
Tangle on save.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(defun org-babel-tangle-config ()
(when (string-suffix-p ".org" (buffer-file-name))
(org-babel-tangle)))
(add-hook 'org-mode-hook
(lambda ()
(add-hook 'after-save-hook #'org-babel-tangle-config)))
#+end_src
Enable Org Crypt.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance '("crypt"))
(setq org-crypt-key nil)
(setq auto-save-default nil)
#+end_src
* Shell
Use =eshell= as an integrated shell.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package eshell)
(global-set-key (kbd "C-c e") 'eshell)
#+end_src
* Language Servers
Add =eglot= keybindings.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(global-set-key (kbd "C-c r") 'eglot-rename)
(global-set-key (kbd "C-c a") 'eglot-code-actions)
#+end_src
Install =tree-sitter=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package tree-sitter)
(use-package tree-sitter-langs)
#+end_src
Define function to set up =eglot= automatically.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(defun jj/eglot-setup ()
(eglot-ensure)
(tree-sitter-mode 1)
(tree-sitter-hl-mode 1))
#+end_src
* Completions
Use company for completions with no delay, starting immediately after first character is typed.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package company
:config
(add-hook 'after-init-hook 'global-company-mode)
(setq company-idle-delay 0
company-minimum-prefix-length 1
company-selection-wrap-around t))
#+end_src
Use =vertico= as a completion user interface.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package vertico
:custom
(vertico-cycle t)
:init
(vertico-mode))
#+end_src
Use =orderless= to allow typing any portion of a word that you want to search for.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
#+end_src
Get descriptions of items in =vertico= with =marginalia=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package marginalia
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
:init
(marginalia-mode))
#+end_src
Get nerd font icons in completions.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package nerd-icons-completion
:config
(nerd-icons-completion-mode))
#+end_src
Use consult with =vertico= for extra functionality to various functions.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package consult
:bind (
("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 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 t b" . consult-buffer-other-tab)
("C-x r b" . consult-bookmark)
("C-x p b" . consult-project-buffer)
("M-#" . consult-register-load)
("M-'" . consult-register-store)
("C-M-#" . consult-register)
("M-y" . consult-yank-pop)
("M-g e" . consult-compile-error)
("M-g f" . consult-flycheck)
("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 d" . 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)
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history)
("M-s e" . consult-isearch-history)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
:map minibuffer-local-map
("M-s" . consult-history)
("M-r" . consult-history))
:hook (completion-list-mode . consult-preview-at-point-mode)
:init
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
(advice-add #'register-preview :override #'consult-register-window)
(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-file-register
consult--source-recent-file consult--source-project-recent-file
:preview-key '(:debounce 0.4 any))
(setq consult-narrow-key "<"))
#+end_src
Use Flycheck for syntax checking.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package flycheck
:config
(add-hook 'after-init-hook #'global-flycheck-mode))
#+end_src
Use Flyspell for spell checking.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
(use-package flyspell-correct
:after flyspell
:bind (:map flyspell-mode-map ("C-;" . flyspell-correct-wrapper)))
#+end_src
* Snippets
Use =yasnippet= for snippets so I don't need to type as much.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package yasnippet
:init
(yas-global-mode 1)
:config
(global-set-key (kbd "C-c s") 'yas-insert-snippet))
#+end_src
Install snippet collection for =yasnippet=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package yasnippet-snippets)
#+end_src
* Formatting
Automatically format with Apheleia and =clang-format=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package apheleia
:init (apheleia-global-mode +1))
(use-package clang-format)
#+end_src
* RSS
Use Emacs as an RSS feed with =elfeed=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package elfeed
:config
(global-set-key (kbd "C-c f") 'elfeed)
(global-set-key (kbd "C-c M-f") 'elfeed-update))
#+end_src
Make =elfeed= more powerful with =elfeed-goodies=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package elfeed-goodies
:after elfeed
:config
(elfeed-goodies/setup))
#+end_src
Store my feed in Org-mode [[./feed.org][here]].
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package elfeed-org
:config
(elfeed-org)
(setq rmh-elfeed-org-files (list "~/.config/emacs/feed.org")))
#+end_src
* Deft
Use the Deft package to manage notes.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package deft
:config
(global-set-key (kbd "C-c d") 'deft)
(setq deft-directory "~/notes/"
deft-default-extension "org"))
#+end_src
* Reference Management
Use Biblio and Citar to manage citations.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package biblio)
(use-package citar
:custom
(citar-bibliography '("~/bib/references.bib"))
:hook
(LaTeX-mode . citar-capf-setup)
(org-mode . citar-capf-setup))
(use-package citar-embark
:after citar embark
:no-require
:config (citar-embark-mode))
#+end_src

View file

@ -0,0 +1,131 @@
#+title: Emacs User Interface
* Theming
Set up Source Code Pro with Nerd Font patches as default font and Computer Modern as a variable pitch font.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(defvar jj/mono-font)
(defvar jj/var-font)
(pcase system-type
(`gnu/linux
(when (eq (system-name) "gentoo"))
(setq jj/mono-font "SauceCodePro Nerd Font-11")
(setq jj/var-font "CMU Serif-14"))
(`darwin
(setq jj/mono-font "SauceCodePro Nerd Font-14:weight=thin")
(setq jj/var-font "CMU Serif-18")))
(add-to-list 'default-frame-alist
`(font . ,jj/mono-font))
#+end_src
Use my custom Doom Disco light theme.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package doom-themes
:straight (doom-themes :type git :host github :repo "doomemacs/themes"
:fork (:host github
:repo "JacobJanzen/emacs-doom-themes"))
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
(load-theme 'doom-disco t)
(doom-themes-org-config))
(add-to-list 'default-frame-alist '(alpha-background . 90))
#+end_src
Use =doom-modeline= for a nicer modeline.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package doom-modeline
:init (doom-modeline-mode 1))
#+end_src
Remove the title bar.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(add-to-list 'default-frame-alist '(undecorated . t))
#+end_src
* Clean UI
Disable the Emacs start screen and make the =scratch= buffer default to empty.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(setq inhibit-startup-screen t)
(setq initial-scratch-message nil)
#+end_src
Disable scroll bar, tool bar, and menu bar.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
#+end_src
* Fancy Stuff
Use line numbers by default.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(global-display-line-numbers-mode 1)
#+end_src
Highlight changes for an operation with =evil-goggles=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package evil-goggles
:after evil
:config
(evil-goggles-mode)
(evil-goggles-use-diff-faces))
#+end_src
Install nerd font icons.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package nerd-icons)
#+end_src
Scroll one line at a time.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(setq scroll-conservatively most-positive-fixnum)
#+end_src
Create parent directories when they don't yet exist.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(defun jj/create-non-existent-directory ()
(let ((parent-directory (file-name-directory buffer-file-name)))
(when (and (not (file-exists-p parent-directory))
(y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
(make-directory parent-directory t))))
(add-to-list 'find-file-not-found-functions #'jj/create-non-existent-directory)
#+end_src
* Whitespace Management
Use spaces over tabs and set tab width to 4.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(setq-default indent-tabs-mode nil)
(setq tab-width 4
c-basic-offset tab-width)
#+end_src
Delete trailing whitespace on save.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(defun jj/before-save-hook ()
(unless (eql (with-current-buffer (current-buffer) major-mode)
'markdown-mode)
(delete-trailing-whitespace)))
(add-hook 'before-save-hook #'jj/before-save-hook)
#+end_src
* Backup Management
Don't create backup files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(setq make-backup-files nil)
#+end_src
* Customize =dired=
Use nerd font icons in =dired=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package nerd-icons-dired
:hook (dired-mode . nerd-icons-dired-mode))
#+end_src
Use colours in =dired= with =diredfl=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package diredfl
:init (diredfl-global-mode 1))
#+end_src

Binary file not shown.

4
extract_src.py Normal file → Executable file
View file

@ -1,5 +1,7 @@
#!/usr/bin/env python3
import os
from stat import ST_MODE
import sys
import re
@ -27,3 +29,5 @@ with open(sys.argv[1], "r") as inp:
if min_spaces == -1 or min_spaces > spaces:
min_spaces = spaces
curr.append(re.sub(r"^(\s*),(\*|,\*|#\+|,#\+)", r"\1\2", line))
os.chmod(sys.argv[2], os.stat(sys.argv[1])[ST_MODE])

83
install
View file

@ -1,83 +0,0 @@
#!/bin/sh
echo 'backing up previous log file to ~/.update-home-old.log'
mv ~/.update-home.log ~/.update-home-old.log >> /dev/null 2>&1
if ! test -d ~/.dotfiles; then
echo '.dotfiles should be at ~/.dotfiles; reinstalling dotfiles at ~/.dotfiles...'
git clone git@git.sr.ht:~jjanzen/.dotfiles ~/.dotfiles >> ~/.update-home.log 2>&1
fi
echo 'retrieving the latest changes (any unmerged local changes will be stashed)...'
{
git stash
git checkout main
git pull --rebase
} >> ~/.update-home.log 2>&1
CWD=$(pwd)
if [ "$(uname)" = 'Darwin' ]; then
echo 'detected Mac OS; installing Mac OS configuration...'
cd ~/.dotfiles/macos/ || exit
elif [ "$(uname)" = 'Linux' ] && grep -q 'ID=nixos' /etc/os-release; then
echo 'detected NixOS; installing NixOS configuration...'
cd ~/.dotfiles/nixos/ || exit
else
echo 'unsupported operating system'
exit 1
fi
echo 'installing configuration files...'
find -L -- . -type f -name "*\.org" | while read -r file; do
echo " installing $file..."
emacs --batch "$file" -f package-initialize --eval '(org-babel-tangle)' >> ~/.update-home.log 2>&1
done
find -L -- . -type f -name "*\.org\.gpg" | while read -r file; do
echo " installing $file..."
gpg -d --batch "$file" 1> tmp.org 2>> ~/.update-home.log
emacs --batch tmp.org -f package-initialize --eval '(org-babel-tangle)' >> ~/.update-home.log 2>&1
rm tmp.org
done
echo 'installing wallpaper...'
cp .wallpaper ~/.wallpaper
if [ "$(uname)" = 'Darwin' ]; then
osascript -e "tell application \"System Events\" to tell every desktop to set picture to \"/$HOME/.wallpaper\" as POSIX file"
fi
if [ "$(uname)" = 'Linux' ] && grep -q 'ID=nixos' /etc/os-release; then
echo 'installing NixOS flake'
sudo cp ./.flake/system/hardware-configuration.nix ~/.flake/system
sudo cp ./.flake/home/.wallpaper ~/.flake/home
sudo cp ./.flake/flake.lock ~/.flake
sudo nixos-rebuild switch --flake "$HOME/.flake#nixos"
fi
if [ "$(uname)" = 'Darwin' ]; then
fonts_changed=false
echo 'installing fonts...'
mkdir -p ~/.local/share/fonts
if ! test -d ~/.local/share/fonts/ComputerModern; then
echo ' Computer Modern font missing. Installing...'
tar xf .local/share/fonts/ComputerModern.tar.gz -C ~/.local/share/fonts >> ~/.update-home.log 2>&1
fonts_changed=true
fi
if ! test -f ~/.local/share/fonts/NFM.ttf; then
echo ' Nerd Font Mono font missing. Installing...'
tar xf .local/share/fonts/NFM.tar.gz -C ~/.local/share/fonts >> ~/.update-home.log 2>&1
fonts_changed=true
fi
if ! test -d ~/.local/share/fonts/SauceCodePro; then
echo ' Source Code Pro Nerd Font missing. Installing...'
tar xf .local/share/fonts/SauceCodePro.tar.gz -C ~/.local/share/fonts >> ~/.update-home.log 2>&1
fonts_changed=true
fi
if [ $fonts_changed = true ]; then
echo ' updating the font cache...'
fc-cache -f >> ~/.update-home.log
fi
fi
cd "$CWD" || exit

View file

@ -0,0 +1 @@
../common/.clang-format.org

View file

@ -0,0 +1 @@
../../common/.config/alacritty

View file

@ -0,0 +1 @@
../../common/.config/sketchybar

1
macos.local/.config/skhd Symbolic link
View file

@ -0,0 +1 @@
../../common/.config/skhd

1
macos.local/.config/yabai Symbolic link
View file

@ -0,0 +1 @@
../../common/.config/yabai

View file

@ -0,0 +1 @@
../common/.gitconfig.org.gpg

View file

1
macos.local/.profile.org Symbolic link
View file

@ -0,0 +1 @@
../common/.profile.org

1
macos.local/.zshrc.org Symbolic link
View file

@ -0,0 +1 @@
../common/.zshrc.org

View file

@ -1 +0,0 @@
../common/clang-format.org

View file

@ -1 +0,0 @@
../common/gitconfig.org.gpg

View file

@ -1 +0,0 @@
../common/profile.org

View file

@ -1 +0,0 @@
../common/zshrc.org

View file

@ -1,39 +0,0 @@
#+title: Emacs RSS Feed
#+begin_src org :tangle ~/.config/emacs/feed.org :mkdirp yes
,* Blogs
:PROPERTIES:
:ID: elfeed
:END:
,** Journalism :journalism:
,*** [[https://waxy.org/feed/][Waxy.org]]
,*** [[https://pluralistic.net/feed/][Cory Doctorow]] :technology:software:fiction:
,** Computer Science :cs:
,*** [[https://a.exozy.me/index.xml][Some Random Website]] :math:algorithms:fiction:
,** Technology :technology:
,*** [[https://ciechanow.ski/atom.xml][Bartosz Ciechanowshki]]
,*** [[https://www.citationneeded.news/rss/][Citation Needed]]
,*** [[https://www.lilysthings.org/blog/rss.xml][The Cool Blog]]
,** Software :software:
,*** [[https://eieio.games/feed.xml][eieio.games]]
,*** [[https://ersei.net/en/blog.atom][Ersei]]
,*** [[https://lilysthings.org/blog/rss.xml][Lily's Things]]
,*** [[https://ntietz.com/atom.xml][Technically a Blog]]
,*** [[https://alexwlchan.net/atom.xml][Alex Chan]]
,*** [[https://eaton-works.com/feed.atom][Eaton Works]] :hacking:
,*** [[https://computer.rip/rss.xml][Computer's Are Bad]] :technology:
,*** [[https://mark.stosberg.com/rss/][Mark Stosberg]] :biking:
,*** [[https://maia.crimew.gay/feed.xml][Maia Crimew]] :internet:hacking:
,*** [[https://drewdevault.com/blog/index.xml][Drew DeVault]]
,** Comics :comic:
,*** [[https://xkcd.com/atom.xml][XKCD]]
,** People I know
,*** [[https://www.weavingwatersexpedition.com/news?format=rss][Weaving Waters Expedition]] :journalism:
,*** [[https://pinkish.bearblog.dev/feed/][Pinkish]] :software:
,*** [[https://jjanzen.ca/rss.xml][Me]] :software:review:
,** Internet Infrastructure :internet:software:
,*** [[https://daniel.haxx.se/blog/feed/][cURL]]
,*** [[https://blog.archive.org/feed/][Archive.org]]
,** Reviews :review:
,*** [[https://mountainofink.com/?format=rss][Mountain of Ink]]
#+end_src

View file

@ -0,0 +1 @@
../../../../../common/.config/emacs/feed.org.org

View file

@ -1,8 +0,0 @@
#+title: Emacs Force the Usage of a =custom.el= File
Force the usage of a =custom.el= file for customizations instead of placing them in =init.el=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/force-custom-file.el :mkdirp yes
(setq custom-file (concat user-emacs-directory "custom.el"))
(when (file-exists-p custom-file)
(load custom-file))
#+end_src

View file

@ -0,0 +1 @@
../../../../../common/.config/emacs/force-custom-file.el.org

View file

@ -1,148 +0,0 @@
#+title: Emacs Programming Language Setup
* Shell Script
Run =eglot= on shell script files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'sh-mode-hook 'jj/eglot-setup)
#+end_src
* C
Run =eglot= on C and C++ files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'c-mode-hook 'jj/eglot-setup)
(add-hook 'c++-mode-hook 'jj/eglot-setup)
(add-hook 'cc-mode-hook 'jj/eglot-setup)
#+end_src
Run =eglot= on CMake files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package cmake-mode
:init
(add-hook 'cmake-mode-hook 'jj/eglot-setup))
#+end_src
Turn off C mode in =lex= and =yacc= files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-to-list 'auto-mode-alist '("\\.l$" . prog-mode))
(add-to-list 'auto-mode-alist '("\\.y$" . prog-mode))
#+end_src
* Web
Run =eglot= on HTML files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'html-mode-hook 'jj/eglot-setup)
#+end_src
Run =eglot= on CSS files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'css-mode-hook 'jj/eglot-setup)
#+end_src
Run =eglot= on JavaScript files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'js-json-mode-hook 'jj/eglot-setup)
(add-hook 'js-mode-hook 'jj/eglot-setup)
#+end_src
* Python
Run =eglot= on Python files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'python-mode-hook 'jj/eglot-setup)
#+end_src
* Go
Install Go support and run =eglot= on Go files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package go-mode
:init
(add-hook 'go-mode-hook 'jj/eglot-setup))
#+end_src
Get documentation for Go variables, functions, and arguments.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package go-eldoc
:init
(add-hook 'go-mode-hook 'go-eldoc-setup))
#+end_src
Automatically generate tests in Go.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package go-gen-test)
#+end_src
Get refactoring tools from =go-guru=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package go-guru
:hook (go-mode . go-guru-hl-identifier-mode))
#+end_src
* Lua
Install Lua support and run =eglot= on Lua files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package lua-mode
:init
(add-hook 'lua-mode-hook 'jj/eglot-setup))
#+end_src
Better Lisp editing with =lispy=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package lispy
:hook (emacs-lisp-mode . lispy-mode))
(use-package lispyville
:after lispy
:hook (lispy-mode . lispyville-mode))
#+end_src
Better parentheses handling in lisp with =parinfer-rust-mode=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package parinfer-rust-mode
:hook (emacs-lisp-mode . parinfer-rust-mode)
:init
(setq parinfer-rust-auto-download t))
#+end_src
* Markdown
Install Markdown support and run =eglot= on Markdown files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package markdown-mode
:init
(add-hook 'markdown-mode-hook 'jj/eglot-setup))
#+end_src
* LaTeX
Run =eglot= on TeX files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(add-hook 'tex-mode-hook 'jj/eglot-setup)
#+end_src
Use AUCTeX for extra LaTeX integration.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package auctex
:config
(add-hook 'LaTeX-mode-hook 'jj/eglot-setup)
(add-hook 'LaTeX-mode-hook
(lambda ()
(put 'LaTeX-mode 'eglot-language-id "latex"))))
#+end_src
Use CDLaTeX for environment and macro insertion.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package cdlatex
:config
(add-hook 'LaTeX-mode-hook #'turn-on-cdlatex))
#+end_src
* YAML
Install YAML support and run =eglot= on YAML files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package yaml-mode
:init
(add-hook 'yaml-mode-hook 'jj/eglot-setup))
#+end_src
* Nix
Install =nix= support and run =eglot= on =nix= files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/languages.el :mkdirp yes
(use-package nix-mode
:mode "\\.nix\\'")
#+end_src

View file

@ -0,0 +1 @@
../../../../../common/.config/emacs/languages.el.org

View file

@ -1,25 +0,0 @@
#+title: Emacs Package Setup
Install =straight= for better package management.
#+begin_src emacs-lisp :tangle ~/.config/emacs/package-setup.el :mkdirp yes
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
#+end_src
Install =use-package= for declarative package installation. Make =use-package= default to =ensure t= so that packages are enabled if they are declared.
#+begin_src emacs-lisp :tangle ~/.config/emacs/package-setup.el :mkdirp yes
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
#+end_src

View file

@ -0,0 +1 @@
../../../../../common/.config/emacs/package-setup.el.org

View file

@ -1,391 +0,0 @@
#+title: Emacs Tool Setup
* Vi Keybindings
Use =vi= keybindings with =evil=. Set the undo system to =undo-fu=. Wrapped lines can be moved between with =j= and =k=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package evil
:init
(setq evil-want-keybinding nil)
:config
(evil-mode)
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
(evil-global-set-key 'motion (kbd "RET") nil)
:custom
(evil-undo-system 'undo-fu))
#+end_src
Use =evil-collection= to include =vi= keybindings in extra modes.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package evil-collection
:after evil
:config
(evil-collection-init))
#+end_src
* Undo
Better undo with =undo-fu=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package undo-fu)
#+end_src
Make undo persistent when closing Emacs with =undo-fu-session=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package undo-fu-session
:init (undo-fu-session-global-mode 1))
#+end_src
* Lookup
Better lookup with =dumb-jump=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package dumb-jump
:init (add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
#+end_src
* Version Control
Install Magit for Git integration.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package magit)
#+end_src
* Remote Editing
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq tramp-default-method "ssh")
#+end_src
* Document Viewing
Replace =DocView= with a better document viewer from =pdf-tools=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package pdf-tools
:config
(pdf-tools-install)
:init
(add-hook 'pdf-view-mode-hook #'(lambda () (display-line-numbers-mode -1)))
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
:config
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
TeX-source-correlate-start-server t))
#+end_src
Save place in PDFs with =saveplace-pdf-view=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package saveplace-pdf-view
:config (save-place-mode 1))
#+end_src
* Org-Mode
Ensure that =org= is set up before any of this.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package org)
#+end_src
Set my =org-mode= directory.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq org-directory "~/org")
#+end_src
Hide emphasis markers because I can see if something is *bold*, /italic/, or =monospace= without needing to see the markers.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq org-hide-emphasis-markers t)
#+end_src
Set up nicer looking bullet points.
- they look like circles
- instead of hyphens
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
#+end_src
Set up fonts. Don't use =monospace= by default. Do use it where necessary though. Also, make different heading levels different sizes.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(add-hook 'org-mode-hook 'variable-pitch-mode)
(custom-set-faces
`(variable-pitch ((t :font ,jj/var-font)))
`(fixed-pitch ((t :font ,jj/mono-font)))
'(org-block ((t (:inherit fixed-pitch))))
'(org-code ((t (:inherit (shadow fixed-pitch)))))
'(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
'(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
'(org-verbatim ((t (:inherit (shadow fixed-pitch)))))
'(org-table ((t (:inherit (shadow fixed-pitch)))))
'(org-document-title ((t (:inherit title :height 2.0 :underline nil))))
'(org-level-1 ((t (:inherit outline-1 :weight: bold :height 1.75))))
'(org-level-2 ((t (:inherit outline-2 :weight: bold :height 1.5))))
'(org-level-2 ((t (:inherit outline-3 :weight: bold :height 1.25))))
'(org-level-2 ((t (:inherit outline-4 :weight: bold :height 1.1))))
'(org-level-4 ((t (:inherit outline-4 :height 1.1))))
'(org-level-5 ((t (:inherit outline-5 :height 1.0))))
)
#+end_src
Wrap lines and centre the view to make for a nicer reading experience.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package visual-fill-column)
(add-hook 'org-mode-hook 'visual-line-mode)
(add-hook 'org-mode-hook #'(lambda () (display-line-numbers-mode -1)))
(defun jj/org-mode-visual-fill ()
(setq visual-fill-column-width 100
visual-fill-column-center-text t)
(visual-fill-column-mode 1))
(add-hook 'org-mode-hook #'jj/org-mode-visual-fill)
#+end_src
Increase the size of LaTeX previews.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
#+end_src
Follow links with the return key.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(setq org-return-follows-link t)
#+end_src
Tangle on save.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(defun org-babel-tangle-config ()
(when (string-suffix-p ".org" (buffer-file-name))
(org-babel-tangle)))
(add-hook 'org-mode-hook
(lambda ()
(add-hook 'after-save-hook #'org-babel-tangle-config)))
#+end_src
Enable Org Crypt.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance '("crypt"))
(setq org-crypt-key nil)
(setq auto-save-default nil)
#+end_src
* Shell
Use =eshell= as an integrated shell.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package eshell)
(global-set-key (kbd "C-c e") 'eshell)
#+end_src
* Language Servers
Add =eglot= keybindings.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(global-set-key (kbd "C-c r") 'eglot-rename)
(global-set-key (kbd "C-c a") 'eglot-code-actions)
#+end_src
Install =tree-sitter=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package tree-sitter)
(use-package tree-sitter-langs)
#+end_src
Define function to set up =eglot= automatically.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(defun jj/eglot-setup ()
(eglot-ensure)
(tree-sitter-mode 1)
(tree-sitter-hl-mode 1))
#+end_src
* Completions
Use company for completions with no delay, starting immediately after first character is typed.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package company
:config
(add-hook 'after-init-hook 'global-company-mode)
(setq company-idle-delay 0
company-minimum-prefix-length 1
company-selection-wrap-around t))
#+end_src
Use =vertico= as a completion user interface.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package vertico
:custom
(vertico-cycle t)
:init
(vertico-mode))
#+end_src
Use =orderless= to allow typing any portion of a word that you want to search for.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
#+end_src
Get descriptions of items in =vertico= with =marginalia=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package marginalia
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
:init
(marginalia-mode))
#+end_src
Get nerd font icons in completions.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package nerd-icons-completion
:config
(nerd-icons-completion-mode))
#+end_src
Use consult with =vertico= for extra functionality to various functions.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package consult
:bind (
("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 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 t b" . consult-buffer-other-tab)
("C-x r b" . consult-bookmark)
("C-x p b" . consult-project-buffer)
("M-#" . consult-register-load)
("M-'" . consult-register-store)
("C-M-#" . consult-register)
("M-y" . consult-yank-pop)
("M-g e" . consult-compile-error)
("M-g f" . consult-flycheck)
("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 d" . 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)
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history)
("M-s e" . consult-isearch-history)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
:map minibuffer-local-map
("M-s" . consult-history)
("M-r" . consult-history))
:hook (completion-list-mode . consult-preview-at-point-mode)
:init
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
(advice-add #'register-preview :override #'consult-register-window)
(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-file-register
consult--source-recent-file consult--source-project-recent-file
:preview-key '(:debounce 0.4 any))
(setq consult-narrow-key "<"))
#+end_src
Use Flycheck for syntax checking.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package flycheck
:config
(add-hook 'after-init-hook #'global-flycheck-mode))
#+end_src
Use Flyspell for spell checking.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
(use-package flyspell-correct
:after flyspell
:bind (:map flyspell-mode-map ("C-;" . flyspell-correct-wrapper)))
#+end_src
* Snippets
Use =yasnippet= for snippets so I don't need to type as much.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package yasnippet
:init
(yas-global-mode 1)
:config
(global-set-key (kbd "C-c s") 'yas-insert-snippet))
#+end_src
Install snippet collection for =yasnippet=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package yasnippet-snippets)
#+end_src
* Formatting
Automatically format with Apheleia and =clang-format=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package apheleia
:init (apheleia-global-mode +1))
(use-package clang-format)
#+end_src
* RSS
Use Emacs as an RSS feed with =elfeed=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package elfeed
:config
(global-set-key (kbd "C-c f") 'elfeed)
(global-set-key (kbd "C-c M-f") 'elfeed-update))
#+end_src
Make =elfeed= more powerful with =elfeed-goodies=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package elfeed-goodies
:after elfeed
:config
(elfeed-goodies/setup))
#+end_src
Store my feed in Org-mode [[./feed.org][here]].
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package elfeed-org
:config
(elfeed-org)
(setq rmh-elfeed-org-files (list "~/.config/emacs/feed.org")))
#+end_src
* Deft
Use the Deft package to manage notes.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package deft
:config
(global-set-key (kbd "C-c d") 'deft)
(setq deft-directory "~/notes/"
deft-default-extension "org"))
#+end_src
* Reference Management
Use Biblio and Citar to manage citations.
#+begin_src emacs-lisp :tangle ~/.config/emacs/tools.el :mkdirp yes
(use-package biblio)
(use-package citar
:custom
(citar-bibliography '("~/bib/references.bib"))
:hook
(LaTeX-mode . citar-capf-setup)
(org-mode . citar-capf-setup))
(use-package citar-embark
:after citar embark
:no-require
:config (citar-embark-mode))
#+end_src

View file

@ -0,0 +1 @@
../../../../../common/.config/emacs/tools.el.org

View file

@ -1,131 +0,0 @@
#+title: Emacs User Interface
* Theming
Set up Source Code Pro with Nerd Font patches as default font and Computer Modern as a variable pitch font.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(defvar jj/mono-font)
(defvar jj/var-font)
(pcase system-type
(`gnu/linux
(when (eq (system-name) "gentoo"))
(setq jj/mono-font "SauceCodePro Nerd Font-11")
(setq jj/var-font "CMU Serif-14"))
(`darwin
(setq jj/mono-font "SauceCodePro Nerd Font-14:weight=thin")
(setq jj/var-font "CMU Serif-18")))
(add-to-list 'default-frame-alist
`(font . ,jj/mono-font))
#+end_src
Use my custom Doom Disco light theme.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package doom-themes
:straight (doom-themes :type git :host github :repo "doomemacs/themes"
:fork (:host github
:repo "JacobJanzen/emacs-doom-themes"))
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
(load-theme 'doom-disco t)
(doom-themes-org-config))
(add-to-list 'default-frame-alist '(alpha-background . 90))
#+end_src
Use =doom-modeline= for a nicer modeline.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package doom-modeline
:init (doom-modeline-mode 1))
#+end_src
Remove the title bar.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(add-to-list 'default-frame-alist '(undecorated . t))
#+end_src
* Clean UI
Disable the Emacs start screen and make the =scratch= buffer default to empty.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(setq inhibit-startup-screen t)
(setq initial-scratch-message nil)
#+end_src
Disable scroll bar, tool bar, and menu bar.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
#+end_src
* Fancy Stuff
Use line numbers by default.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(global-display-line-numbers-mode 1)
#+end_src
Highlight changes for an operation with =evil-goggles=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package evil-goggles
:after evil
:config
(evil-goggles-mode)
(evil-goggles-use-diff-faces))
#+end_src
Install nerd font icons.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package nerd-icons)
#+end_src
Scroll one line at a time.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(setq scroll-conservatively most-positive-fixnum)
#+end_src
Create parent directories when they don't yet exist.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(defun jj/create-non-existent-directory ()
(let ((parent-directory (file-name-directory buffer-file-name)))
(when (and (not (file-exists-p parent-directory))
(y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
(make-directory parent-directory t))))
(add-to-list 'find-file-not-found-functions #'jj/create-non-existent-directory)
#+end_src
* Whitespace Management
Use spaces over tabs and set tab width to 4.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(setq-default indent-tabs-mode nil)
(setq tab-width 4
c-basic-offset tab-width)
#+end_src
Delete trailing whitespace on save.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(defun jj/before-save-hook ()
(unless (eql (with-current-buffer (current-buffer) major-mode)
'markdown-mode)
(delete-trailing-whitespace)))
(add-hook 'before-save-hook #'jj/before-save-hook)
#+end_src
* Backup Management
Don't create backup files.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(setq make-backup-files nil)
#+end_src
* Customize =dired=
Use nerd font icons in =dired=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package nerd-icons-dired
:hook (dired-mode . nerd-icons-dired-mode))
#+end_src
Use colours in =dired= with =diredfl=.
#+begin_src emacs-lisp :tangle ~/.config/emacs/user-interface.el :mkdirp yes
(use-package diredfl
:init (diredfl-global-mode 1))
#+end_src

View file

@ -0,0 +1 @@
../../../../../common/.config/emacs/user-interface.el.org