177 lines
6.4 KiB
EmacsLisp
177 lines
6.4 KiB
EmacsLisp
;; -*- lexical-binding: t; -*-
|
||
|
||
(require 'package)
|
||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
|
||
(setq package-install-upgrade-built-in t)
|
||
(package-initialize)
|
||
;(package-refresh-contents) ;; Avoid long startup times, I think this is handled by Nix anyway?
|
||
|
||
(use-package transient
|
||
:ensure t)
|
||
|
||
;; Global settings
|
||
(desktop-save-mode 1) ;; Remember window layouts and open buffers
|
||
(electric-pair-mode 1) ;; Automatic bracket matching
|
||
(global-auto-revert-mode t) ;; Automatically refresh buffers when changes on disk
|
||
(global-display-line-numbers-mode 1)
|
||
(save-place-mode 1) ;; Remember cursor/scroll position
|
||
(setq-default indent-tabs-mode nil)
|
||
|
||
;; Isolate backup and auto-save files
|
||
(setq backup-directory-alist
|
||
`(("." . ,(expand-file-name "backups" user-emacs-directory))))
|
||
(setq auto-save-file-name-transforms
|
||
`((".*" ,(expand-file-name "auto-saves/" user-emacs-directory) t)))
|
||
(setq create-lockfiles nil) ;; Disables .#filename lockfiles
|
||
|
||
;; External modules
|
||
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
|
||
(load (expand-file-name "modules/my-org.el" user-emacs-directory))
|
||
|
||
;; Search and navigation
|
||
|
||
(use-package vertico ;; https://github.com/minad/vertico
|
||
:ensure t
|
||
;:custom
|
||
;(vertico-scroll-margin 0) ;; Different scroll margin
|
||
;(vertico-count 20) ;; Show more candidates
|
||
;(vertico-resize t) ;; Grow and shrink the Vertico minibuffer
|
||
;(vertico-cycle t) ;; Enable cycling for `vertico-next/previous'
|
||
:init
|
||
(vertico-mode)
|
||
)
|
||
|
||
(use-package savehist
|
||
:init
|
||
(savehist-mode)
|
||
)
|
||
|
||
(use-package saveplace-pdf-view
|
||
:ensure t
|
||
:after (:any doc-view pdf-tools)
|
||
:demand t)
|
||
|
||
(use-package orderless
|
||
:ensure t
|
||
:custom
|
||
;; Configure a custom style dispatcher (see the Consult wiki)
|
||
;; (orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch))
|
||
;; (orderless-component-separator #'orderless-escapable-split-on-space)
|
||
(completion-styles '(orderless basic))
|
||
(completion-category-overrides '((file (styles partial-completion))))
|
||
(completion-category-defaults nil) ;; Disable defaults, use our settings
|
||
(completion-pcm-leading-wildcard t) ;; Emacs 31: partial-completion behaves like substring
|
||
)
|
||
|
||
(use-package marginalia
|
||
:ensure t
|
||
:init
|
||
(marginalia-mode)
|
||
)
|
||
|
||
(use-package emacs
|
||
:custom
|
||
;; Enable context menu. `vertico-multiform-mode' adds a menu in the minibuffer
|
||
;; to switch display modes.
|
||
(context-menu-mode t)
|
||
;; Support opening new minibuffers from inside existing minibuffers.
|
||
(enable-recursive-minibuffers t)
|
||
;; Hide commands in M-x which do not work in the current mode. Vertico
|
||
;; commands are hidden in normal buffers. This setting is useful beyond
|
||
;; Vertico.
|
||
(read-extended-command-predicate #'command-completion-default-include-p)
|
||
;; Do not allow the cursor in the minibuffer prompt
|
||
(minibuffer-prompt-properties
|
||
'(read-only t cursor-intangible t face minibuffer-prompt)))
|
||
|
||
(use-package consult ;; https://github.com/minad/consult
|
||
:ensure t
|
||
:bind (("C-x b" . consult-buffer) ;; Fuzzy find open buffers, recents, & bookmarks
|
||
("M-y" . consult-yank-pop) ;; Better paste history
|
||
("M-s r" . consult-ripgrep) ;; Search text INSIDE all your files
|
||
("M-g g" . consult-goto-line)))
|
||
|
||
;; Interaction & tools
|
||
|
||
(use-package evil
|
||
:ensure t
|
||
:init
|
||
(setq evil-shift-width 2)
|
||
:config
|
||
(evil-mode 1)
|
||
(with-eval-after-load 'evil-maps (define-key evil-motion-state-map (kbd "TAB") nil))
|
||
)
|
||
|
||
(use-package pdf-tools ;; https://github.com/vedang/pdf-tools
|
||
:ensure t
|
||
:custom
|
||
(pdf-util-convert-program "magick") ;; "The pdf-util-convert-program is unset or non-executable"
|
||
(pdf-view-incompatible-modes nil) ;; Silences the annoying warning popup
|
||
:init
|
||
(add-hook 'pdf-view-mode-hook (lambda () (display-line-numbers-mode -1)))
|
||
(add-hook 'pdf-view-mode-hook (lambda () (blink-cursor-mode -1)))
|
||
:config
|
||
(pdf-loader-install)
|
||
)
|
||
|
||
(use-package org-preview-html ;; https://github.com/jakebox/org-preview-html
|
||
:ensure t
|
||
:bind (:map org-mode-map ("C-c p" . org-preview-html-mode))
|
||
:custom
|
||
(org-preview-html-viewer 'eww) ;; Use built-in EWW browser
|
||
(org-preview-html-refresh-configuration 'save)
|
||
(add-hook 'eww-mode-hook (lambda () (display-line-numbers-mode -1)))
|
||
;; Pin the preview window layout to the right
|
||
(add-to-list 'display-buffer-alist
|
||
'("\\*eww\\*"
|
||
(display-buffer-in-direction)
|
||
(direction . right)
|
||
(window-width . 0.5)
|
||
)
|
||
)
|
||
)
|
||
|
||
(use-package olivetti
|
||
:ensure t
|
||
) ;; Activate with M-x olivetti-mode
|
||
|
||
(use-package auto-dark
|
||
:ensure t
|
||
:custom
|
||
(auto-dark-themes '((modus-vivendi) (modus-operandi)))
|
||
:hook
|
||
(auto-dark-dark-mode
|
||
. (lambda ()
|
||
(pdf-view-midnight-minor-mode 1)
|
||
))
|
||
(auto-dark-light-mode
|
||
. (lambda ()
|
||
;; something to execute when light mode is detected
|
||
(pdf-view-midnight-minor-mode -1)
|
||
))
|
||
:init
|
||
(auto-dark-mode)
|
||
)
|
||
|
||
;; TODO org-roam stores everything with a prefix. Is there a way to disable that or not?
|
||
;; TODO Put exports in their own directory? (now filename-prefix.pdf)
|
||
;; TODO Put dailies in "journals" instead of "daily"
|
||
;; TODO I store my lecture PDFs in ~/Nextcloud/Documents/UGent/<course>/theory/*.pdf, is there some way to make a shortcut for this (related to Fuzzy finding files etc.). Maybe consider integrating with Zotero and storing PDFs there?
|
||
|
||
;; Additional package to explore
|
||
;; TODO https://magit.vc/ <-> Nextcloud WebDAV? What about mobile? FolderSync seems unreliable (currently using for LogSeq, often reports failures without actually being recently modified files.) I have my own Git server, but what about keys - I don't really like just making new keysets for this..?
|
||
;; TODO I was thinking of syncing (1-way) Org TO-DO's to CalDav (Nextcloud), new calendar, so I can quickly see them in my tasklist. (https://github.com/dengste/org-caldav)
|
||
|
||
;; Turn on Auto Fill mode automatically in Text mode and related modes (see Hooks).
|
||
;; TODO (add-hook 'text-mode-hook 'auto-fill-mode)
|
||
;; Do I want this?
|
||
|
||
;; TODO Automatically save buffer when going to other file -- maybe interactively?
|
||
;; TODO Spellchecking (UK & Dutch)
|
||
|
||
;; TODO Some automation to create anki cards intext without having to write the boilerplate
|
||
|
||
;; TODO Finally, compare experience to organice https://organice.200ok.ch/
|
||
|
||
;; TODO org-compile-file: File "/tmp/nix-shell.UEk6Ye/orgtexcJso3E.dvi" wasn’t produced Please adjust ‘dvipng’ part of ‘org-preview-latex-process-alist’.
|
||
|