emacs/init.el

1281 lines
40 KiB
EmacsLisp

;;; 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
(load-file (locate-user-emacs-file "lib/package-config.el"))
(setq custom-file (locate-user-emacs-file "custom.el"))
(when (and custom-file
(file-exists-p custom-file))
(load custom-file nil 'nomessage))
(set-default-coding-systems 'utf-8)
(setq user-full-name "Evie Litherland-Smith"
user-mail-address "evie@xenia.me.uk"
inhibit-splash-screen t
use-short-answers t
tab-always-indent 'complete
completion-cycle-threshold nil
completions-detailed t
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)
(use-package pixel-scroll
:init
(pixel-scroll-precision-mode +1))
(use-package mwheel
:custom
(mouse-wheel-scroll-amount '(1 ((shift) . 1)))
(mouse-wheel-progressive-speed nil)
(mouse-wheel-follow-mouse t))
;; 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*"))
(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")))
(use-package savehist
:demand
:config
(savehist-mode +1))
(use-package dired
:custom
(dired-auto-revert-buffer t)
(dired-dwim-target t))
(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))
;; Make `describe-*' screens more helpful
(use-package helpful
:defines helpful-mode-map
: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")))
(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...
: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))
(use-package ibuffer
:defines ibuffer-filter-groups
:bind (("C-c b" . ibuffer)))
(use-package ibuffer-project
:after (ibuffer project)
:functions ibuffer-project-generate-filter-groups
:hook
((ibuffer . (lambda () (setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups))))))
(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)))
(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)))
(use-package comint
:bind ( :map comint-mode-map
("<remap> <comint-history-isearch-backward-regexp>" . consult-history)))
(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)))
(use-package calc
:bind (("<Calculator>" . calc)))
(use-package xref
:custom
(xref-show-definitions-function 'xref-show-definitions-completing-read))
(use-package calendar
:bind (("C-c >" . calendar))
:hook ((calendar-today-visible . calendar-mark-today))
:custom
(diary-file (locate-user-emacs-file "diary.gpg"))
(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
(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))))))
(use-package appt
:custom
(appt-display-diary nil)
(appt-display-format 'echo)
:config
(appt-activate +1))
(add-hook 'prog-mode-hook #'(lambda () (display-line-numbers-mode +1)))
(use-package which-key
:functions which-key-mode
:config (which-key-mode +1))
(use-package elec-pair
:config
(electric-pair-mode +1))
(use-package paren
:config
(show-paren-mode +1))
;; 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
:defines (base16-one-light-theme-colors
my/load-theme-and-configure)
:hook (server-after-make-frame . my/load-theme-and-configure)
: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."
(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
(plist-get base16-one-light-theme-colors (cdr pairing)))))
:config
(if (display-graphic-p) (my/load-theme-and-configure)))
(use-package nerd-icons
:functions (nerd-icons-octicon))
(use-package nerd-icons-dired
:diminish
:requires nerd-icons
:hook (dired-mode))
(use-package nerd-icons-ibuffer
:diminish
:requires nerd-icons
:hook (ibuffer-mode))
(use-package nerd-icons-completion
:diminish
:functions nerd-icons-completion-mode
:requires nerd-icons
:hook (after-init . (lambda () (nerd-icons-completion-mode +1))))
(use-package ligature
:functions (ligature-set-ligatures
global-ligature-mode)
:config
(ligature-set-ligatures
'(text-mode prog-mode org-mode)
'("-<<" "-<" "-<-" "<--" "<---" "<<-" "<-" "->" "->>" "-->" "--->" "->-" ">-" ">>-"
"=<<" "=<" "=<=" "<==" "<===" "<<=" "<=" "=>" "=>>" "==>" "===>" "=>=" ">=" ">>="
"<->" "<-->" "<--->" "<---->" "<=>" "<==>" "<===>" "<====>" "::" ":::" "__"
"<~~" "</" "</>" "/>" "~~>" "==" "!=" "/=" "~=" "<>" "===" "!==" "!===" "=/=" "=!="
"<:" ":=" "*=" "*+" "<*" "<*>" "*>" "<|" "<|>" "|>" "<." "<.>" ".>" "+*" "=*" "=:" ":>"
"(*" "*)" "/*" "*/" "[|" "|]" "{|" "|}" "++" "+++" "\\/" "/\\" "|-" "-|" "<!--" "<!---"))
(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))
(use-package time
:custom
(display-time-24hr-format t))
(use-package diff-hl
:functions (diff-hl-magit-pre-refresh
diff-hl-magit-post-refresh
global-diff-hl-mode)
: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))
(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)
: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))
:custom
(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)
(org-yank-folded-subtrees nil)
(org-yank-adjusted-subtrees t)
(org-display-remote-inline-images 'cache)
(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)
;; 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
(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))
(use-package ob-core
:after org
:hook ((org-babel-after-execute . org-redisplay-inline-images)))
(use-package ob-python
:after ob-core
:custom
(org-babel-python-command "python3"))
(use-package ob-jupyter
:after (ob-core jupyter))
(with-eval-after-load 'org
(let (babel-languages)
(when (require 'ob-jupyter nil :noerror)
(push '(jupyter . t) 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 org-capture
:after org
:bind
(("C-c n" . org-capture)
("C-c C-n" . org-capture-goto-last-stored)))
(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)
("C-c r n" . org-roam-capture)
("C-c r j" . org-roam-dailies-capture-today)
("M-g j" . org-roam-dailies-goto-today)
:map org-mode-map
("C-c r b" . org-roam-buffer-toggle))
: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)))
: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)))))
(org-roam-db-autosync-mode +1))
(use-package org-roam-dailies
:custom
(org-roam-dailies-directory "./")
(org-roam-dailies-capture-templates
'(("d" "default" entry
"* %?"
:target (file+datetree "journal.org.gpg" week))
("t" "task")
("tp" "personal" entry
"* TODO [#B] %? :personal:"
:target (file+datetree "journal.org.gpg" week))
("tw" "work" entry
"* TODO [#B] %? :work:"
:target (file+datetree "journal.org.gpg" week)))))
(use-package org-agenda
:after org
:bind (("C-c a" . org-agenda))
:hook (org-agenda-mode . 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 'diary-file)
(org-agenda-include-diary t)
(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 "journal" org-directory)
(expand-file-name "roam" org-directory)
(expand-file-name "citar" org-directory))))
(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"))
(use-package org-noter
:after (org doc-view citar)
:commands org-noter
: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)
(org-noter-notes-search-path
(list (expand-file-name "notes" org-directory)
(car citar-notes-paths)))
(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)
:custom
(citar-bibliography
(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/")))
:config
(require 'org)
(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))
(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
:diminish
:requires citar
:functions citar-embark-mode
:init
(require 'embark)
:config
(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
: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)
(setq org-publish-project-alist
`(("xenia.me.uk"
:base-directory ,(expand-file-name "www/xenia.me.uk" "~/Projects/")
:base-extension "org"
:exclude "setup.org"
: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"
: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\"/>"
)))
(use-package rainbow-delimiters
:hook (prog-mode))
(use-package envrc
:hook (after-init . envrc-global-mode)
:custom
(envrc-show-summary-in-minibuffer t))
(use-package gud
:defer t
:defines gdb-many-windows
:config
(setq gdb-many-windows t))
(use-package treesit
:custom
(treesit-font-lock-level 3))
(use-package treesit-auto
:requires treesit
:functions (treesit-auto-add-to-auto-mode-alist
global-treesit-auto-mode)
: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 t)
(eldoc-echo-area-use-multiline-p nil))
(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)
(eglot-managed-mode . (lambda () (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t))))
:custom
(eglot-extend-to-xref t)
(eglot-autoshutdown t)
(eglot-autoreconnect (* 60 5))
:init
(setq eglot-stay-out-of '(flymake))
:config
(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)))
:nil ( :nix
( :maxMemoryMB nil
:flake
( :autoArchive t
:nixpkgsInputName "nixpkgs")))))
)
(use-package apheleia
:diminish
:defines (apheleia-formatters
apheleia-mode-alist)
:bind (("C-c c f" . apheleia-format-buffer))
:hook (prog-mode)
:custom (apheleia-remote-algorithm 'local)
:config
(add-to-list 'apheleia-formatters '(alejandra . ("alejandra")))
(add-to-list 'apheleia-formatters '(isort . ("isort" "--profile" "black" "-")))
(add-to-list 'apheleia-mode-alist '(nix-mode . alejandra))
(add-to-list 'apheleia-mode-alist '(python-base-mode . ruff))
(add-to-list 'apheleia-mode-alist '(python-mode . ruff))
(add-to-list 'apheleia-mode-alist '(python-ts-mode . ruff)))
(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))))
(use-package flymake-popon
:diminish
:functions flymake-popon-mode
:requires flymake
:hook (flymake-mode . (lambda () (flymake-popon-mode +1))))
(use-package flymake-shellcheck
:if (executable-find "shellcheck")
:requires flymake
: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)))))
(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 "~/.config/home-manager/" nil)
(project-remember-projects-under "~/Projects" t)
))
(use-package magit
:bind (("C-c g g" . magit-status)
("C-c g d" . magit-dispatch)
("C-c g f" . magit-file-dispatch)
("C-c g b" . magit-blame-addition)
("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)
(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
: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))))
:custom
(python-shell-interpreter "python3")
(python-indent-def-block-scale 1)
(python-check-command "mypy --check-untyped-defs --warn-unreachable --show-error-codes")
(python-flymake-command
(cond ((executable-find "ruff") '("ruff" "check" "--output-format=pylint" "--stdin-filename=stdin" "-"))
((executable-find "flake8") '("flake8" "--max-line-length" "88" "-"))
(t '("pyflakes"))))
:config
(setq python-ts-mode-hook python-mode-hook))
(use-package python-docstring
:hook python-base-mode)
(use-package files
:custom
(view-read-only t)
(enable-remote-dir-locals t))
(use-package tramp
:defer t
:custom
(tramp-default-method "scpx")
(tramp-backup-directory-alist backup-directory-alist)
(tramp-auto-save-directory (cdr (assoc "." tramp-backup-directory-alist)))
:config
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(add-to-list 'tramp-remote-path "~/.local/bin/"))
(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))
: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
:custom
(sendmail-program (executable-find "msmtp"))
(send-mail-function #'sendmail-send-it))
(use-package message
: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))
(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"))
(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))
(use-package elfeed
:bind (("C-c f" . elfeed))
:hook ((elfeed-search-mode . elfeed-update)
(elfeed-show-mode . (lambda () (visual-line-mode +1))))
:custom
(elfeed-search-filter "@2-months-ago +unread")
:config
(require 'elfeed-db)
(require 'elfeed-org))
(use-package elfeed-db
: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)))
: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))
(use-package password-store
:functions password-store-get)
(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 'org)
(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