emacs/init.el

1277 lines
39 KiB
EmacsLisp
Raw Normal View History

2024-04-17 11:43:59 +01:00
;;; init.el -- My emacs config -*- lexical-binding: t -*-
;;; Commentary:
;; Moving my Emacs config from separate directory
;; To install packages on non-NixOS systems run `install.el'
;;; Code:
;; Customise `use-package' behaviour, must be set before first time
;; it's used
(setopt use-package-check-before-init t
use-package-enable-imenu-support t)
;; Stop popups for warning messages, keep in log buffer
(setopt warning-minimum-level :error)
;; Configure packages archives, with priority, and list of installed
;; packages
(load-file (locate-user-emacs-file "lib/my-packages.el"))
2024-04-17 11:43:59 +01:00
(setq custom-file (locate-user-emacs-file "custom.el"))
2024-06-18 06:55:34 +01:00
(when (and custom-file
(file-exists-p custom-file))
2024-04-17 11:43:59 +01:00
(load custom-file nil 'nomessage))
(set-default-coding-systems 'utf-8)
2024-04-17 11:43:59 +01:00
(setq user-full-name "Evie Litherland-Smith"
user-mail-address "evie@xenia.me.uk"
inhibit-splash-screen t
2024-04-17 11:43:59 +01:00
use-short-answers t
tab-always-indent 'complete
completion-cycle-threshold nil
2024-04-17 11:43:59 +01:00
completions-detailed t
2024-04-22 08:19:20 +01:00
kill-do-not-save-duplicates t)
(setq-default truncate-lines t
truncate-partial-width-windows nil)
(setopt indent-tabs-mode nil
async-shell-command-display-buffer nil
compilation-scroll-output t)
(global-prettify-symbols-mode +1)
(global-auto-revert-mode +1)
(delete-selection-mode +1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
2024-04-22 11:16:25 +01:00
2024-04-22 08:19:20 +01:00
(use-package pixel-scroll
:init
(pixel-scroll-precision-mode +1))
2024-04-17 11:43:59 +01:00
2024-04-22 11:12:46 +01:00
(use-package mwheel
:custom
(mouse-wheel-scroll-amount '(1 ((shift) . 1)))
(mouse-wheel-progressive-speed nil)
(mouse-wheel-follow-mouse t))
2024-04-17 11:43:59 +01:00
;; Bind normal forward/back buttons on mouse to next/previous buffer respectively
(keymap-global-set "<mouse-8>" #'previous-buffer)
(keymap-global-set "<mouse-9>" #'next-buffer)
;; Quick bind for calling `git-sync-all'
(defun my/git-sync-all ()
"Run shell command `git-sync-all' asynchronously."
(interactive)
(async-shell-command "git-sync-all" "*git-sync-all*" "*git-sync-errors*"))
2024-04-17 11:43:59 +01:00
(keymap-global-set "C-c g s" #'my/git-sync-all)
;; Make shebang (#!) file executable when saved
(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
;; Remap `upcase-word' and `downcase-word' to DWIM versions
(keymap-global-set "<remap> <upcase-word>" 'upcase-dwim)
(keymap-global-set "<remap> <downcase-word>" 'downcase-dwim)
(setq backup-directory-alist '(("." . "~/.local/state/emacs/backups")))
2024-04-17 11:43:59 +01:00
(use-package savehist
:demand
:config
(savehist-mode +1))
2024-04-17 11:43:59 +01:00
(use-package dired
:custom
(dired-auto-revert-buffer t)
(dired-dwim-target t))
2024-04-17 11:43:59 +01:00
(use-package recentf
:config
(run-at-time nil (* 5 60) 'recentf-save-list)
(recentf-mode +1)
:custom
(recentf-max-saved-items 2048))
(use-package auth-source
:custom
(auth-sources '("secrets:Login")))
(use-package auth-source-pass
:requires auth-source
:config
(auth-source-pass-enable))
2024-04-17 11:43:59 +01:00
;; Make `describe-*' screens more helpful
(use-package helpful
:defines helpful-mode-map
2024-04-17 11:43:59 +01:00
:bind (("<remap> <describe-command>" . helpful-command)
("<remap> <describe-function>" . helpful-callable)
("<remap> <describe-key>" . helpful-key)
("<remap> <describe-symbol>" . helpful-symbol)
("<remap> <describe-variable>" . helpful-variable)
("C-h F" . helpful-function)
:map helpful-mode-map
("<remap> <revert-buffer>" . helpful-update)))
;; Bind extra `describe-*' commands
(keymap-global-set "C-h K" #'describe-keymap)
;; turn on spell checking, if available.
(use-package ispell
:custom
(ispell-dictionary "en_GB")
(ispell-personal-dictionary (locate-user-emacs-file "dictionary")))
2024-04-17 11:43:59 +01:00
(use-package flyspell
:hook ((text-mode . flyspell-mode)
(prog-mode . flyspell-prog-mode))
:init
(require 'ispell)
(require 'org) ; Fails without org-mode-map for some reason...
2024-04-17 11:43:59 +01:00
:custom
(flyspell-mode-line-string nil)
(flyspell-use-meta-tab nil)
:config
(require 'flyspell-correct)
(require 'consult-flyspell))
(use-package flyspell-correct
:after flyspell
:bind ( :map flyspell-mode-map
("C-;" . flyspell-correct-wrapper)))
(use-package consult-flyspell
:after (consult flyspell)
:bind ( :map flyspell-mode-map
("C-c s ;" . consult-flyspell))
:custom
(consult-flyspell-always-check-buffer t))
2024-04-17 11:43:59 +01:00
(use-package ibuffer
:defines ibuffer-filter-groups
2024-04-17 11:43:59 +01:00
:bind (("C-c b" . ibuffer)))
2024-05-22 10:03:56 +01:00
(use-package ace-window
:bind (("<remap> <other-window>" . ace-window))
:custom
(aw-scope 'frame)
(aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)))
2024-04-17 11:43:59 +01:00
(use-package link-hint
:bind (("C-c l o" . link-hint-open-link)
("C-c l c" . link-hint-copy-link)
("C-c l C-o" . link-hint-open-all-link)
("C-c l C-c" . link-hint-copy-all-link)))
(use-package avy
:bind (("<remap> <goto-char>" . avy-goto-char)))
2024-04-17 11:43:59 +01:00
(use-package comint
:bind ( :map comint-mode-map
("<remap> <comint-history-isearch-backward-regexp>" . consult-history)))
2024-04-17 11:43:59 +01:00
(use-package shell
:bind (("C-c t s" . shell)))
(use-package eshell
:bind (("C-c t e" . eshell))
:config
(require 'esh-mode))
(use-package esh-mode
:defines eshell-mode-map
:bind ( :map eshell-mode-map
("<remap> <eshell-previous-matching-input>" . consult-history)))
2024-04-17 11:43:59 +01:00
(use-package calc
:bind (("<Calculator>" . calc)))
(use-package xref
2024-04-17 11:43:59 +01:00
:custom
(xref-show-definitions-function 'xref-show-definitions-completing-read))
2024-04-17 11:43:59 +01:00
(use-package appt
:custom
(appt-display-diary nil)
(appt-display-format 'echo))
(use-package calendar
:after appt
:bind (("C-c >" . calendar))
:hook ((calendar-today-visible . calendar-mark-today))
:custom
(calendar-date-style 'iso)
(calendar-mark-holidays-flag t)
(calendar-mark-diary-entries-flag nil)
(calendar-view-holidays-initially-flag nil)
(calendar-view-diary-initially-flag nil)
:config
(appt-activate +1)
(add-to-list 'display-buffer-alist
'("\\*Calendar\\*"
(display-buffer-in-side-window)
(side . bottom)
(slot . 0)
(window-height . 0.2)
(window-parameters . ((no-delete-other-windows . t))))))
2024-04-17 11:43:59 +01:00
(add-hook 'prog-mode-hook #'(lambda () (display-line-numbers-mode +1)))
(use-package which-key
:functions which-key-mode
2024-04-17 11:43:59 +01:00
:config (which-key-mode +1))
(use-package elec-pair
:config
(electric-pair-mode +1))
2024-04-17 11:43:59 +01:00
(use-package paren
:config
(show-paren-mode +1))
2024-04-17 11:43:59 +01:00
;; add visual pulse when changing focus, like beacon but built-in
;; from from https://karthinks.com/software/batteries-included-with-emacs/
(defun pulse-line (&rest _)
"Pulse the current line."
(pulse-momentary-highlight-one-line (point)))
(use-package base16-theme
:demand
2024-06-08 07:13:55 +01:00
:defines (base16-one-light-theme-colors
my/load-theme-and-configure)
:hook (server-after-make-frame . my/load-theme-and-configure)
2024-04-17 11:43:59 +01:00
:custom
(base16-theme-distinct-fringe-background nil)
(base16-theme-highlight-mode-line 'contrast)
:init
(defun my/load-theme-and-configure ()
"Load theme and configure some faces."
2024-06-08 07:13:55 +01:00
(load-theme 'base16-one-light t)
;; Change outline headers to follow rainbow order
(require 'outline)
(dolist (pairing '((outline-1 . :base08)
(outline-2 . :base09)
(outline-3 . :base0A)
(outline-4 . :base0B)
(outline-5 . :base0C)
(outline-6 . :base0D)
(outline-7 . :base0E)
(outline-8 . :base0F)))
(set-face-attribute (car pairing) nil
:foreground
2024-06-08 07:13:55 +01:00
(plist-get base16-one-light-theme-colors (cdr pairing)))))
2024-04-17 11:43:59 +01:00
:config
(if (display-graphic-p) (my/load-theme-and-configure)))
2024-04-17 11:43:59 +01:00
(use-package nerd-icons
:functions (nerd-icons-octicon))
2024-04-17 11:43:59 +01:00
(use-package nerd-icons-dired
2024-05-31 10:01:41 +01:00
:diminish
:requires nerd-icons
2024-04-17 11:43:59 +01:00
:hook (dired-mode))
(use-package nerd-icons-ibuffer
2024-05-31 10:01:41 +01:00
:diminish
:requires nerd-icons
2024-04-17 11:43:59 +01:00
:hook (ibuffer-mode))
(use-package nerd-icons-completion
2024-05-31 10:01:41 +01:00
:diminish
:functions nerd-icons-completion-mode
:requires nerd-icons
:hook (after-init . (lambda () (nerd-icons-completion-mode +1))))
2024-04-17 11:43:59 +01:00
(use-package ligature
:functions (ligature-set-ligatures
global-ligature-mode)
2024-04-17 11:43:59 +01:00
:config
(ligature-set-ligatures
'(text-mode prog-mode org-mode)
2024-07-03 16:46:23 +01:00
'("<--" "<---" "<-" "->" "-->" "--->"
"<==" "<===" "<=" "=>" "==>" "===>"
"<->" "<-->" "<--->" "<---->"
"<=>" "<==>" "<===>" "<====>"
"==" "!=" "===" "!==" "!==="
"<|" "<|>" "|>" "<>" "</" "</>" "/>"
"/*" "*/" "+++" "<~~" "~~>" "<!---" "---!>"))
2024-04-17 11:43:59 +01:00
(global-ligature-mode +1))
(use-package whitespace
:custom
(whitespace-style '(face
empty
trailing
tab-mark
indentation::space))
(whitespace-action '(report-on-bogus
cleanup
auto-cleanup)))
(setq mode-line-compact 'long)
(line-number-mode -1)
(column-number-mode -1)
(size-indication-mode +1)
;; (require 'battery)
;; (when (and battery-status-function
;; (not ( string-match-p "unknown"
;; ( battery-format "%B"
;; (funcall battery-status-function)))))
;; (display-battery-mode +1))
2024-06-25 14:26:24 +01:00
(use-package time
:custom
(display-time-24hr-format t))
2024-04-17 11:43:59 +01:00
(use-package diff-hl
:functions (diff-hl-magit-pre-refresh
diff-hl-magit-post-refresh
global-diff-hl-mode)
2024-04-17 11:43:59 +01:00
:init
(add-hook 'magit-pre-refresh-hook #'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook #'diff-hl-magit-post-refresh)
:custom
(diff-hl-disable-on-remote t)
(diff-hl-draw-borders t)
:config
(global-diff-hl-mode))
2024-04-17 11:43:59 +01:00
(setq split-height-threshold nil
split-width-threshold 160)
(use-package winner
:demand
:config
(winner-mode))
(use-package ediff
:bind (("C-c d f" . ediff-files)
("C-c d b" . ediff-buffers)
("C-c d 3 f" . ediff-files3)
("C-c d 3 b" . ediff-buffers3))
:custom
(ediff-window-setup-function #'ediff-setup-windows-plain))
(use-package emms
:defines (emms-browser-mode-map
emms-playlist-mode-map)
:functions (emms-all
emms-default-players
emms-mpris-enable
emms-cache-enable
emms-show)
2024-04-17 11:43:59 +01:00
:bind (("C-c e e" . emms-smart-browse)
("C-c e p" . emms-pause)
("C-c e s" . emms-stop)
("C-c e z" . emms-toggle-repeat-track)
("C-c e C-r" . emms-toggle-repeat-playlist)
("C-c e C-b" . emms-browser)
("C-c e C-p" . emms-playlist-mode-go)
("<XF86AudioPlay>" . emms-pause)
("<XF86AudioPrev>" . emms-previous)
("<XF86AudioNext>" . emms-next)
:map emms-browser-mode-map
("e" . emms-smart-browse)
("P" . emms-pause)
("S" . emms-stop)
("z" . emms-toggle-repeat-track)
:map emms-playlist-mode-map
("e" . emms-smart-browse))
:custom
(emms-source-file-default-directory "~/Music/")
(emms-lyrics-dir (expand-file-name "lyrics" "~/Music/"))
(emms-browser-covers #'emms-browser-cache-thumbnail-async)
(emms-browser-default-covers (list (expand-file-name "placeholder.jpg" "~/Music/")))
(emms-repeat-playlist t)
:config
(emms-all)
(emms-default-players)
(emms-mpris-enable)
(emms-cache-enable)
(add-hook 'emms-player-started-hook #'emms-show))
(use-package org
:defines org-mode-map
:hook ((org-mode . turn-on-auto-fill))
:bind ( :map org-mode-map
("<remap> <imenu>" . consult-org-heading)
("<remap> <org-goto>" . consult-org-heading))
2024-04-17 11:43:59 +01:00
:custom
2024-05-15 07:55:32 +01:00
(org-directory "~/Documents/org")
(org-default-notes-file (expand-file-name "notes.org" org-directory))
(org-archive-location "::* Archived Tasks")
(org-hide-emphasis-markers t)
(org-use-sub-superscripts '{})
(org-pretty-entities t)
(org-pretty-entities-include-sub-superscripts t)
(org-fontify-done-headline t)
(org-fontify-todo-headline t)
(org-fontify-emphasized-text t)
(org-fontify-quote-and-verse-blocks t)
(org-tags-column 0)
(org-enforce-todo-dependencies t)
(org-enforce-todo-checkbox-dependencies t)
2024-04-17 11:43:59 +01:00
(org-yank-folded-subtrees nil)
(org-yank-adjusted-subtrees t)
2024-05-22 16:03:56 +01:00
(org-display-remote-inline-images 'cache)
2024-04-17 11:43:59 +01:00
(org-M-RET-may-split-line '((default . nil)
(headline . nil)
(item . nil)
(table . t))))
(use-package ox
:after org
:custom
(org-export-with-sub-superscripts org-use-sub-superscripts))
(use-package org-faces
:after org
:config
;; Ensure tables and src blocks use fixed-pitch font.
(set-face-attribute 'org-block nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit 'fixed-pitch)
(set-face-attribute 'org-table nil :inherit 'fixed-pitch)
(set-face-attribute 'org-verbatim nil :inherit 'org-code)
2024-04-17 11:43:59 +01:00
;; Let quote and verse blocks use variable-pitch font, if configured
(set-face-attribute 'org-quote nil :inherit 'variable-pitch)
(set-face-attribute 'org-verse nil :inherit 'variable-pitch))
(use-package org-keys
:after org
:custom
(org-return-follows-link t)
(org-mouse-1-follows-link t))
(use-package org-indent
:after org
:hook org-mode)
(use-package org-attach
:after org
:custom
2024-05-26 22:10:03 +01:00
(org-attach-id-dir (expand-file-name "data/" org-directory))
(org-attach-dir-relative t)
(org-attach-use-inheritance t))
(use-package org-refile
:after (org org-agenda)
:custom
(org-outline-path-complete-in-steps nil)
(org-refile-use-outline-path t)
(org-refile-allow-creating-parent-nodes t)
(org-refile-use-outline-path 'file)
(org-refile-targets '((nil . (:maxlevel . 3))
(org-agenda-files . (:maxlevel . 3)))))
(use-package org-src
:after org
:custom
(org-src-window-setup 'current-window))
2024-04-17 11:43:59 +01:00
(use-package ob-core
:after org
:hook ((org-babel-after-execute . org-redisplay-inline-images))
:config
(let (babel-languages)
(push '(lua . t) babel-languages)
(push '(python . t) babel-languages)
(push '(emacs-lisp . t) babel-languages)
(org-babel-do-load-languages 'org-babel-load-languages babel-languages)))
(use-package ob-python
:after ob-core
:custom
(org-babel-python-command "python3"))
(use-package org-capture
:after org
:bind ("C-c n" . org-capture))
2024-04-17 11:43:59 +01:00
(use-package org-roam
:after org
:defines org-roam-directory
:functions org-roam-db-autosync-mode
:bind (("C-c r i" . org-roam-node-insert)
("C-c r f" . org-roam-node-find)
2024-05-17 11:30:49 +01:00
("C-c r n" . org-roam-capture)
("C-c r j" . org-roam-dailies-capture-today)
("M-g j" . org-roam-dailies-goto-today)
("M-g C-j" . org-roam-dailies-goto-date)
2024-05-17 11:30:49 +01:00
:map org-mode-map
("C-c r b" . org-roam-buffer-toggle))
2024-04-17 11:43:59 +01:00
:custom
(org-roam-directory (expand-file-name "roam" org-directory))
(org-roam-completion-everywhere nil)
(org-roam-node-display-template (concat
"${title:*} "
(propertize "${tags:24}" 'face 'org-tag)))
(org-roam-capture-templates '(("d" "default" plain "%?"
:target (file+head "${slug}.org" "#+title: ${title}\n")
:unnarrowed t)))
2024-04-17 11:43:59 +01:00
:config
(mkdir org-roam-directory t)
(add-to-list 'display-buffer-alist
'("\\*org-roam\\*"
(display-buffer-in-side-window)
(side . right)
(slot . 0)
(window-width . 0.33)
(window-parameters . ((no-delete-other-windows . t)))))
2024-04-17 11:43:59 +01:00
(org-roam-db-autosync-mode +1))
(use-package org-roam-dailies
:custom
(org-roam-dailies-directory "./")
(org-roam-dailies-capture-templates
'(("d" "default" entry
"* %<%H:%M> %?"
:target (file+datetree "journal.org.gpg" week)))))
(use-package org-agenda
:after (org appt)
:bind (("C-c a" . org-agenda))
:hook (org-agenda-finalize . org-agenda-to-appt)
:custom
(org-agenda-span 'week)
(org-agenda-start-on-weekday 1)
(org-agenda-sticky nil)
(org-agenda-window-setup 'current-window)
(org-agenda-tags-column 0)
(org-agenda-diary-file (expand-file-name "calendar/diary.org.gpg" org-directory))
(org-agenda-include-diary nil)
(org-agenda-include-deadlines t)
(org-agenda-todo-ignore-scheduled 'future)
(org-agenda-todo-ignore-deadlines 'far)
(org-agenda-prefix-format '((agenda . " %-12:c%?-12t% s")
(todo . " %-12:c")
(tags . " %-12:c")
(search . " %-12:c")))
(org-agenda-file-regexp "\\`[^.].*\\.org\\\(\\.gpg\\\)?\\'")
(org-agenda-files (list
(expand-file-name org-directory)
(expand-file-name "calendar" org-directory)
(expand-file-name "roam/journal.org.gpg" org-directory)))
:config
(appt-activate +1))
(use-package ox-icalendar
:after org
:custom
(org-icalendar-store-UID t)
(org-icalendar-alarm-time 15)
(org-icalendar-include-body t)
(org-icalendar-include-sexps t)
(org-icalendar-include-todo t)
(org-icalendar-combined-name "org-mode")
(org-icalendar-combined-description "Emacs org-mode combined export"))
2024-04-17 11:43:59 +01:00
(use-package org-noter
:after (org doc-view citar)
:commands org-noter
2024-04-17 11:43:59 +01:00
:custom
(org-noter-always-create-frame nil)
(org-noter-kill-frame-at-session-end nil)
(org-noter-auto-save-last-location t)
(org-noter-default-notes-file-names '("noter.org"))
(org-noter-doc-property-in-notes t)
2024-05-23 07:42:34 +01:00
(org-noter-notes-search-path
(list (expand-file-name "notes" org-directory)
(car citar-notes-paths)))
2024-04-17 11:43:59 +01:00
(org-noter-prefer-root-as-file-level nil))
(use-package citar
:defines (citar-bibliography
citar-indicators)
:functions (citar-indicator-create
citar-has-files
citar-has-links
citar-has-notes
citar-is-cited)
:hook
(LaTeX-mode . citar-capf-setup)
(org-mode . citar-capf-setup)
2024-04-17 11:43:59 +01:00
:custom
(citar-bibliography
2024-05-23 07:42:34 +01:00
(list
(expand-file-name "citar/main.bib" org-directory)))
(citar-notes-paths
(list
(expand-file-name "citar/notes/" org-directory)))
(citar-library-paths
(list
(expand-file-name "~/Documents/library/")))
2024-04-17 11:43:59 +01:00
:config
(require 'org)
2024-04-17 11:43:59 +01:00
(require 'nerd-icons)
(require 'citar-embark)
(setopt org-cite-insert-processor 'citar
org-cite-follow-processor 'citar
org-cite-activate-processor 'citar)
(dolist (bibfile citar-bibliography)
(add-to-list 'org-cite-global-bibliography bibfile))
2024-04-17 11:43:59 +01:00
(defvar citar-indicator-files-icons
(citar-indicator-create
:symbol (nerd-icons-octicon
"nf-oct-file"
:face 'nerd-icons-green
:v-adjust -0.1)
:function #'citar-has-files
:padding " " ; need this because the default padding is too low for these icons
:tag "has:files"))
(defvar citar-indicator-links-icons
(citar-indicator-create
:symbol (nerd-icons-octicon
"nf-oct-link"
:face 'nerd-icons-orange
:v-adjust 0.01)
:function #'citar-has-links
:padding " " ; need this because the default padding is too low for these icons
:tag "has:links"))
(defvar citar-indicator-notes-icons
(citar-indicator-create
:symbol (nerd-icons-octicon
"nf-oct-note"
:face 'nerd-icons-blue
:v-adjust -0.3)
:function #'citar-has-notes
:padding " " ; need this because the default padding is too low for these icons
:tag "has:notes"))
(defvar citar-indicator-cited-icons
(citar-indicator-create
:symbol (nerd-icons-octicon
"nf-oct-circle"
:face 'nerd-icon-green)
:function #'citar-is-cited
:padding " " ; need this because the default padding is too low for these icons
:tag "is:cited"))
(setq citar-indicators (list citar-indicator-files-icons
citar-indicator-links-icons
citar-indicator-notes-icons
citar-indicator-cited-icons)))
(use-package citar-embark
2024-05-29 14:59:50 +01:00
:diminish
:requires citar
:functions citar-embark-mode
2024-04-17 11:43:59 +01:00
:init
(require 'embark)
:config
2024-04-17 11:43:59 +01:00
(citar-embark-mode +1))
(setq org-latex-compiler "lualatex")
(setq org-preview-latex-default-process 'dvisvgm)
(use-package vertico
:functions vertico-mode
:hook (after-init . (lambda () (vertico-mode +1)))
:custom
(vertico-cycle t)
(require 'vertico-directory)
(require 'marginalia)
(require 'orderless))
(use-package marginalia
:functions marginalia-mode
:custom
(marginalia-annotators '(marginalia-annotators-heavy
marginalia-annotators-light
nil))
:config (marginalia-mode +1))
(use-package orderless
:custom
(completion-styles '(orderless basic))
(completion-category-defaults nil)
(completion-category-overrides '((file (styles basic partial-completion))
(eglot (styles orderless))
(eglot-capf (styles orderless)))))
(use-package nerd-icons-corfu
:diminish
:functions nerd-icons-corfu-formatter
:requires nerd-icons)
(use-package corfu
2024-06-04 10:04:35 +01:00
:defines (corfu-map
corfu-mode-map
corfu-margin-formatters)
:functions (corfu-mode
global-corfu-mode
corfu-history-mode)
:hook (minibuffer-setup . (lambda ()
"Enable `corfu-mode' for `M-:' and `M-!'."
(when (local-variable-p 'completion-at-point-functions)
(corfu-mode +1))))
:bind ( :map corfu-map
("M-SPC" . corfu-insert-separator)
("RET" . nil)
("TAB" . corfu-insert)
([tab] . corfu-insert))
:init
(global-corfu-mode +1)
:custom
(corfu-cycle t)
(corfu-auto nil)
(corfu-preselect 'directory)
:config
(require 'corfu-history)
(when (require 'nerd-icons-corfu nil :noerror)
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
(when (require 'corfu-popupinfo nil :noerror)
(corfu-popupinfo-mode +1))
(when (and (require 'corfu-terminal nil :noerror)
(not (display-graphic-p)))
(corfu-terminal-mode +1)))
(use-package corfu-history
:requires (corfu savehist)
:functions corfu-history
:config
(add-to-list 'savehist-additional-variables #'corfu-history))
(use-package corfu-popupinfo
:requires corfu
:defines corfu-popupinfo-map
:functions corfu-popupinfo-mode
:bind ( :map corfu-popupinfo-map
("M-d" . corfu-popupinfo-toggle)
("M-n" . corfu-popupinfo-scroll-up)
("M-p" . corfu-popupinfo-scroll-down))
:custom
(corfu-popupinfo-delay 0.3))
(use-package corfu-terminal
:requires corfu
:functions corfu-terminal-mode)
(use-package cape
:after corfu
:functions (cape-emoji
cape-file
cape-dabbrev)
:hook ((conf-mode prog-mode text-mode) . (lambda ()
(dolist (cape-fn '(cape-dabbrev
cape-file
cape-emoji))
(add-hook 'completion-at-point-functions cape-fn nil t))))
:custom
(cape-dabbrev-min-length (+ corfu-auto-prefix 1)))
(use-package consult
:functions (consult-org-heading
consult-history)
:bind (("<remap> <imenu>" . consult-imenu)
("<remap> <switch-to-buffer>" . consult-buffer)
("<remap> <project-switch-to-buffer>" . consult-project-buffer)
("C-c s l" . consult-line)
("C-c s o" . consult-outline)
("C-c s f" . consult-fd)
("C-c s g" . consult-ripgrep)
("C-c s e" . consult-flymake)
("C-c s i" . consult-info)
:map minibuffer-local-map
("<remap> <previous-matching-history-element>" . consult-history)))
(use-package consult-eglot
:after (consult eglot)
:bind (("C-c s s" . consult-eglot-symbols)))
(use-package embark
:functions embark-prefix-help-command
:bind (("<remap> <describe-bindings>" . embark-bindings)
("C-." . embark-act))
:config
(setq prefix-help-command #'embark-prefix-help-command))
(use-package embark-consult
:after (embark consult)
:hook (embark-collect-mode . consult-preview-at-point-mode))
(use-package tempel
:defines tempel-path
:functions (tempel-expand
tempel-abbrev-mode)
:bind (("M-+" . tempel-complete)
("M-*" . tempel-insert))
:hook ((conf-mode prog-mode text-mode) . (lambda () (add-hook 'completion-at-point-functions 'tempel-complete nil t)))
:custom
(tempel-trigger-prefix "<"))
(require 'tramp)
2024-04-17 11:43:59 +01:00
(setq org-publish-project-alist
`(("xenia.me.uk"
:base-directory ,(expand-file-name "www/xenia.me.uk" "~/Projects/")
2024-04-17 11:43:59 +01:00
:base-extension "org"
:exclude "setup.org"
2024-04-17 11:43:59 +01:00
:recursive t
:publishing-function org-html-publish-to-html
:publishing-directory "/sshx:pixelifytica@legion:/var/www/xenia.me.uk"
:auto-sitemap t
:sitemap-title "Sitemap"
2024-04-17 11:43:59 +01:00
:section-numbers nil
:with-author t
:with-email t
:with-toc nil
:html-link-home "/"
:html-link-up "../"
;; :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/style.css\"/>"
2024-04-17 11:43:59 +01:00
)))
(use-package rainbow-delimiters
:hook (prog-mode))
2024-05-23 13:38:13 +01:00
(use-package envrc
:hook (after-init . envrc-global-mode)
:custom
(envrc-show-summary-in-minibuffer t))
2024-04-17 11:43:59 +01:00
2024-05-23 13:38:13 +01:00
(use-package gud
:defer t
:defines gdb-many-windows
2024-05-23 13:38:13 +01:00
:config
(setq gdb-many-windows t))
2024-04-17 11:43:59 +01:00
(use-package treesit
:custom
(treesit-font-lock-level 3))
2024-04-17 11:43:59 +01:00
(use-package treesit-auto
:requires treesit
:functions (treesit-auto-add-to-auto-mode-alist
global-treesit-auto-mode)
2024-04-17 11:43:59 +01:00
:config
(treesit-auto-add-to-auto-mode-alist)
(global-treesit-auto-mode +1))
(use-package eldoc
:custom
(eldoc-echo-area-display-truncation-message nil)
(eldoc-echo-area-prefer-doc-buffer 'maybe)
(eldoc-echo-area-use-multiline-p 3))
2024-04-17 11:43:59 +01:00
(use-package eglot
:demand
:bind ( :map prog-mode-map
("C-c c a" . eglot-code-actions)
("C-c c r" . eglot-rename))
:hook (((nix-mode lua-mode js-base-mode typescript-ts-base-mode) . eglot-ensure)
2024-05-19 11:02:51 +01:00
(eglot-managed-mode . (lambda () (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t))))
2024-04-17 11:43:59 +01:00
:custom
(eglot-menu-string "lsp")
(eglot-send-changes-idle-time 1)
2024-04-17 11:43:59 +01:00
(eglot-extend-to-xref t)
(eglot-autoshutdown t)
(eglot-sync-connect nil)
(eglot-autoreconnect (* 60 5))
(eglot-events-buffer-config '(:size 0))
(eglot-ignored-server-capabilities
'(:documentHighlightProvider
:documentFormattingProvider
:documentRangeFormattingProvider
:documentOnTypeFormattingProvider
:documentLinkProvider
:colorProvider
:foldingRangeProvider))
:init
2024-04-17 11:43:59 +01:00
(setq eglot-stay-out-of '(flymake))
:config
2024-04-17 11:43:59 +01:00
(setq-default eglot-workspace-configuration
'( :pylsp ( :plugins
( :autopep8 (:enabled nil)
:flake8 (:enabled nil)
:jedi_completion ( :enabled t
:include_params t
:include_class_objects t
:include_function_objects t
:fuzzy t)
:jedi_definition (:enabled t)
:jedi_hover (:enabled t)
:mccabe (:enabled nil)
:preload (:enabled nil)
:pycodestyle (:enabled nil)
:pydocstyle (:enabled nil)
:pyflakes (:enabled nil)
:pylint (:enabled nil)
:rope_autoimport ( :completions (:enabled t)
:code_actions (:enabled t))
:rope_completion (:enabled t)
:yapf (:enabled nil)))
:pyright (:python
(:analysis
( :autoSearchPaths t
:diagnosticMode "openFilesOnly"
:useLibraryCodeForTypes t)))
:nil ( :nix
( :maxMemoryMB nil
:flake
( :autoArchive t
:nixpkgsInputName "nixpkgs")))))
)
2024-04-17 11:43:59 +01:00
(use-package apheleia
:diminish
:defines (apheleia-formatters
apheleia-mode-alist)
2024-04-17 11:43:59 +01:00
:bind (("C-c c f" . apheleia-format-buffer))
:hook (prog-mode)
:custom (apheleia-remote-algorithm 'cancel)
2024-04-17 11:43:59 +01:00
:config
(add-to-list 'apheleia-formatters '(alejandra . ("alejandra")))
(add-to-list 'apheleia-formatters '(isort . ("isort" "--profile" "black" "-")))
2024-04-17 11:43:59 +01:00
(add-to-list 'apheleia-mode-alist '(nix-mode . alejandra))
(add-to-list 'apheleia-mode-alist '(python-base-mode . (black isort)))
(add-to-list 'apheleia-mode-alist '(python-mode . (black isort)))
(add-to-list 'apheleia-mode-alist '(python-ts-mode . (black isort))))
2024-04-17 11:43:59 +01:00
(use-package flymake
:bind (("C-c C-." . flymake-goto-next-error)
("C-c C-," . flymake-goto-prev-error))
:hook (prog-mode . (lambda () (flymake-mode +1)))
:custom
(flymake-no-changes-timeout 1)
(flymake-show-diagnostics-at-end-of-line nil))
2024-04-17 11:43:59 +01:00
(use-package flymake-popon
:diminish
:functions flymake-popon-mode
:requires flymake
:hook (flymake-mode . (lambda () (flymake-popon-mode +1))))
2024-04-17 11:43:59 +01:00
(use-package flymake-shellcheck
:if (executable-find "shellcheck")
:requires flymake
2024-04-17 11:43:59 +01:00
:hook (sh-mode . flymake-shellcheck-load))
(use-package flymake-yamllint
:if (executable-find "yamllint")
:functions flymake-yamllint-setup
:requires flymake
:hook (yaml-ts-mode . (lambda ()
(progn (flymake-mode +1)
(flymake-yamllint-setup)))))
2024-06-25 07:32:02 +01:00
(use-package flymake-eslint
:if (executable-find "eslint")
:functions flymake-eslint-enable
:requires flymake
:hook ((js-base-mode typescript-ts-base-mode) . flymake-eslint-enable))
(use-package project
:functions (project-forget-zombie-projects
project-remember-projects-under)
:custom
(project-switch-use-entire-map t)
(project-switch-commands '((project-find-file "Find file")
(project-find-regexp "Find regexp")
(project-find-dir "Find directory")
(project-eshell "Eshell")
(magit-project-status "Magit")))
:config
(defun my/project-find-common-projects ()
"Search and remember common project directories.
Calls `project-remember-projects-under' for ~/Projects/"
(interactive)
(require 'project)
(project-forget-zombie-projects)
(project-remember-projects-under user-emacs-directory nil)
(project-remember-projects-under "/etc/nixos/" nil)
(project-remember-projects-under "~/Projects" t)
))
2024-04-17 11:43:59 +01:00
(use-package magit
:bind (("C-c g g" . magit-status)
("C-c g d" . magit-dispatch)
("C-c g f" . magit-file-dispatch)
2024-05-23 14:37:00 +01:00
("C-c g b" . magit-blame-addition)
2024-04-17 11:43:59 +01:00
("C-c g p" . magit-pull)
("C-c g P" . magit-push)
("<remap> <project-vc-dir" . magit-project-status)
:map project-prefix-map
("m" . magit-project-status))
:custom
(magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)
(magit-define-global-key-bindings nil)
(magit-clone-default-directory "~/Projects/")
(magit-clone-set-remote.pushDefault t)
(magit-commit-show-diff t)
(magit-commit-diff-inhibit-same-window t)
(magit-diff-adjust-tab-width t)
(magit-diff-refine-hunk 'all)
(magit-diff-refine-ignore-whitespace t)
(magit-clone-name-alist '(("\\`\\(?:github:\\|gh:\\)?\\([^:]+\\)\\'" "github.com" "github.user")
("\\`\\(?:gitlab:\\|gl:\\)\\([^:]+\\)\\'" "gitlab.com" "gitlab.user")
("\\`\\(?:sourcehut:\\|sh:\\)\\([^:]+\\)\\'" "git.sr.ht" "sourcehut.user")
("\\`\\(?:gitea:\\|gt:\\)\\([^:]+\\)\\'" "git.xenia.me.uk" "gitea.user"))))
(use-package forge-topic
:custom
(forge-topic-list-limit '(60 . 10)))
(use-package treemacs
:functions (treemacs treemacs-load-theme)
:bind (("M-g t" . treemacs-select-window))
:hook (treemacs-mode . (lambda () (visual-line-mode -1)))
:config
(when (require 'treemacs-nerd-icons nil :noerror)
(treemacs-load-theme "nerd-icons")))
(use-package treemacs-nerd-icons
:diminish
:requires nerd-icons)
2024-04-17 11:43:59 +01:00
(use-package aggressive-indent
:hook (elisp-mode
lisp-mode
lisp-data-mode
rust-mode))
(use-package nix-mode
:mode "\\.nix\\'"
:functions nix-prettify-global-mode
2024-04-17 11:43:59 +01:00
:config
(require 'nix)
(require 'nix-flake)
(require 'nix-repl)
(require 'nix-store)
(nix-prettify-global-mode +1))
(defun my/enable-fill-column (col)
"Set and enable fill column to `COL'."
(set-fill-column col)
(display-fill-column-indicator-mode +1))
(use-package python
:hook ((python-base-mode . (lambda () (my/enable-fill-column 88))))
2024-04-17 11:43:59 +01:00
:custom
(python-shell-interpreter "python3")
(python-indent-def-block-scale 1)
(python-check-command "mypy --check-untyped-defs --warn-unreachable --show-error-codes --ignore-missing-imports")
(python-flymake-command
(cond ((executable-find "ruff") '("ruff" "check" "--output-format=concise" "--stdin-filename=stdin" "-"))
((executable-find "flake8") '("flake8" "--max-line-length" "88" "-"))
(t '("pyflakes"))))
2024-04-17 11:43:59 +01:00
:config
(setq python-ts-mode-hook python-mode-hook))
2024-04-17 11:43:59 +01:00
(use-package python-docstring
:hook python-base-mode)
2024-04-17 11:43:59 +01:00
2024-05-22 09:39:04 +01:00
(use-package files
:custom
(view-read-only t)
2024-05-22 09:39:04 +01:00
(enable-remote-dir-locals t))
2024-04-17 11:43:59 +01:00
(use-package tramp
:defer t
:custom
2024-05-20 10:14:03 +01:00
(tramp-default-method "scpx")
(tramp-backup-directory-alist backup-directory-alist)
(tramp-auto-save-directory (cdr (assoc "." tramp-backup-directory-alist)))
2024-04-17 11:43:59 +01:00
:config
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(add-to-list 'tramp-remote-path "~/.local/bin/"))
2024-04-17 11:43:59 +01:00
(connection-local-set-profile-variables
'remote-no-corfu-auto
'((corfu-auto . nil)))
(connection-local-set-profiles
'(:application tramp)
'remote-no-corfu-auto)
(use-package doc-view
:defer t
:bind ( :map doc-view-mode-map
("<mouse-8>" . doc-view-previous-page)
("<mouse-9>" . doc-view-next-page))
:custom
(doc-view-resolution 200)
(doc-view-imenu-enabled t)
(doc-view-scale-internally t)
(doc-view-image-width 850))
(use-package markdown-mode
:hook
((markdown-mode . turn-on-auto-fill))
2024-04-17 11:43:59 +01:00
:custom
(markdown-enable-math t)
(markdown-enable-html t)
:config
(set-face-attribute 'markdown-code-face nil :inherit 'fixed-pitch)
(set-face-attribute 'markdown-inline-code-face nil :inherit 'fixed-pitch)
(set-face-attribute 'markdown-table-face nil :inherit 'fixed-pitch)
(set-face-attribute 'markdown-blockquote-face nil :inherit 'variable-pitch)
(set-face-attribute 'markdown-comment-face nil :inherit 'variable-pitch))
(use-package pandoc-mode
:after (markdown-mode)
:hook (markdown-mode . conditionally-turn-on-pandoc))
(use-package sendmail
2024-04-17 11:43:59 +01:00
:custom
(sendmail-program (executable-find "msmtp"))
(send-mail-function #'sendmail-send-it))
2024-04-17 11:43:59 +01:00
(use-package message
2024-04-17 11:43:59 +01:00
:custom
(message-send-mail-function #'message-send-mail-with-sendmail)
(message-sendmail-f-is-evil t)
(message-sendmail-extra-arguments '("--read-envelope-from"))
(message-auto-save-directory nil)
(message-kill-buffer-on-exit t))
2024-04-17 11:43:59 +01:00
(use-package bbdb
:bind (("M-g b" . bbdb-display-all-records))
:custom
(bbdb-file (locate-user-emacs-file "bbdb.gpg")))
(load-file (locate-user-emacs-file "lib/mu4e-custom.el"))
2024-04-17 11:43:59 +01:00
(use-package erc
:commands erc-compute-nick
:custom
(erc-nick (user-login-name))
(erc-user-full-name (user-full-name))
:config
(when (require 'password-store nil :noerror)
(defun my/libera-chat-connect ()
"Connect to irc.libera.chat directly."
(interactive)
(require 'erc)
(require 'password-store)
(erc-tls
:server "irc.libera.chat"
:password (password-store-get 'irc.libera.chat)))
(defun my/znc-connect ()
"Connect to my ZNC IRC bouncer."
(interactive)
(require 'erc)
(require 'password-store)
(erc-tls
:server "xenia.me.uk"
:port 6697
:nick (concat (erc-compute-nick) "/liberachat")
:password (password-store-get 'znc)))))
(use-package eww
:defer t
:custom
(browse-url-browser-function 'browse-url-default-browser)
(browse-url-secondary-browser-function 'browse-url-default-browser)
(browse-url-new-window-flag t)
(eww-default-download-directory "~/Downloads/")
(eww-auto-rename-buffer 'title)
(eww-browse-url-new-window-is-tab nil))
2024-04-17 11:43:59 +01:00
(use-package elfeed
:bind (("C-c f" . elfeed))
:hook ((elfeed-search-mode . elfeed-update)
(elfeed-show-mode . (lambda () (visual-line-mode +1))))
2024-04-17 11:43:59 +01:00
:custom
(elfeed-search-filter "@2-months-ago +unread")
2024-04-17 11:43:59 +01:00
:config
(require 'elfeed-db)
(require 'elfeed-org))
2024-04-17 11:43:59 +01:00
(use-package elfeed-db
2024-04-17 11:43:59 +01:00
:after (elfeed org)
:custom
(elfeed-db-directory (expand-file-name "elfeed" org-directory)))
(use-package elfeed-org
:after (elfeed elfeed-db org)
:defines rmh-elfeed-org-files
:functions elfeed-org
:custom
(rmh-elfeed-org-files (list
(expand-file-name "feeds.org" elfeed-db-directory)))
2024-04-17 11:43:59 +01:00
:config
(elfeed-org))
(use-package elfeed-tube
:after elfeed
:defines (elfeed-show-mode-map
elfeed-search-mode-map)
:functions elfeed-tube-setup
:bind ( :map elfeed-show-mode-map
("F" . elfeed-tube-fetch)
([remap save-buffer] . elfeed-tube-save)
:map elfeed-search-mode-map
("F" . elfeed-tube-fetch)
([remap save-buffer] . elfeed-tube-save))
:custom
(elfeed-tube-auto-save-p nil)
(elfeed-tube-auto-fetch-p t)
:config
(elfeed-tube-setup))
2024-04-17 11:43:59 +01:00
(use-package password-store
:functions password-store-get)
2024-04-17 11:43:59 +01:00
(use-package pass
:defer t
:bind (("C-c P" . pass))
:custom
(pass-show-keybindings nil)
(pass-username-field "login"))
;; Scratch buffer shortcut
(keymap-global-set "C-c w x" #'scratch-buffer)
;; Config file shortcut
(defun my/open-init-file ()
"Open Emacs init file."
(interactive)
(find-file (locate-user-emacs-file "init.el")))
(keymap-global-set "C-c w e" #'my/open-init-file)
;; Tempel template file shortcut
(defun my/open-template-file ()
"Open `tempel' template file."
(interactive)
(require 'tempel)
(find-file tempel-path))
(keymap-global-set "C-c w t" #'my/open-template-file)
;; Org directory shortcut
(defun my/open-org-directory ()
"Open base `org-mode' directory in Dired."
(interactive)
(require 'org)
(find-file org-directory))
(keymap-global-set "C-c w o" #'my/open-org-directory)
(defun my/open-global-bibliography ()
"Open `org-cite-global-bibliography'."
(interactive)
(require 'citar)
(find-file (car org-cite-global-bibliography)))
(keymap-global-set "C-c w b" #'my/open-global-bibliography)
;; Elfeed feeds directory shortcut
(defun my/open-feeds-file ()
"Open elfeed org source file."
(interactive)
(require 'elfeed)
(require 'elfeed-org)
(find-file (car rmh-elfeed-org-files)))
(keymap-global-set "C-c w f" #'my/open-feeds-file)
(defun my/open-documents-directory ()
"Open Documents directory."
(interactive)
(find-file "~/Documents/"))
(defun my/open-downloads-directory ()
"Open Downloads directory."
(interactive)
(find-file "~/Downloads/"))
(keymap-global-set "C-c w d" #'my/open-documents-directory)
(keymap-global-set "C-c w C-d" #'my/open-downloads-directory)
(provide 'init)
;;; init.el ends here