diff --git a/init.el b/init.el index 23d5982..bc96acd 100644 --- a/init.el +++ b/init.el @@ -1,12 +1,7 @@ ;;; 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: -;; Stop popups for warning messages, keep in log buffer -(setopt warning-minimum-level :error) - ;; Customise `use-package' behaviour, must be set before first time ;; it's used. Configure packages archives with priority (setopt use-package-check-before-init t @@ -21,24 +16,32 @@ :custom (package-archive-priorities '(("melpa" . 1) ("stable" . 2) ("nongnu" . 3) ("gnu" . 4))) (package-selected-packages - '(;; Theme - base16-theme + '( ;; UI - all-the-icons nerd-icons nerd-icons-completion nerd-icons-corfu nerd-icons-dired nerd-icons-ibuffer - minions ligature page-break-lines helpful which-key ace-window link-hint diff-hl + base16-theme all-the-icons nerd-icons nerd-icons-completion + nerd-icons-corfu nerd-icons-dired nerd-icons-ibuffer minions + ligature which-key diff-hl + ;; Completion vertico orderless marginalia cape corfu corfu-terminal - consult consult-eglot consult-flyspell embark embark-consult - flyspell-correct tempel + consult consult-eglot flyspell-correct tempel + ;; IDE - treesit-auto magit forge flymake-popon flymake-shellcheck flymake-yamllint flymake-clippy flymake-eslint - apheleia envrc rainbow-delimiters aggressive-indent python-docstring nix-mode lua-mode - ;; Writing - markdown-mode pandoc-mode auctex htmlize)) + treesit-auto magit apheleia envrc rainbow-delimiters + flymake-shellcheck flymake-yamllint flymake-clippy flymake-eslint + markdown-mode pandoc-mode python-docstring nix-mode lua-mode + + )) :config (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/")) - (package-initialize)) + (package-initialize) + + (defun my/package-ensure () + "Update package archives and ensure packages are installed." + (package-refresh-contents) + (package-install-selected-packages) + (package-autoremove))) (set-default-coding-systems 'utf-8) @@ -120,19 +123,6 @@ :config (auth-source-pass-enable)) -;; Make `describe-*' screens more helpful -(use-package helpful - :if (package-installed-p 'helpful) - :defines helpful-mode-map - :bind ((" " . helpful-command) - (" " . helpful-callable) - (" " . helpful-key) - (" " . helpful-symbol) - (" " . helpful-variable) - ("C-h F" . helpful-function) - :map helpful-mode-map - (" " . helpful-update))) - ;; Bind extra `describe-*' commands (keymap-global-set "C-h K" #'describe-keymap) @@ -156,39 +146,10 @@ :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 avy - :if (package-installed-p 'avy) - :bind ((" " . avy-goto-char))) - -(use-package ace-window - :if (package-installed-p 'ace-window) - :bind ((" " . ace-window)) - :custom - (aw-scope 'frame) - (aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))) - -(use-package link-hint - :if (package-installed-p '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 comint - :bind ( :map comint-mode-map - (" " . consult-history))) - (use-package shell :bind (("C-c t s" . shell))) @@ -690,14 +651,6 @@ citar-indicator-notes-icons citar-indicator-cited-icons))) -(use-package citar-embark - :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) @@ -814,24 +767,14 @@ ("C-c s e" . consult-flymake) ("C-c s i" . consult-info) :map minibuffer-local-map - (" " . consult-history))) + (" " . consult-history) + :map comint-mode-map + (" " . consult-history))) (use-package consult-eglot :after (consult eglot) :bind (("C-c s s" . consult-eglot-symbols))) -(use-package embark - :if (package-installed-p 'embark) - :functions embark-prefix-help-command - :bind ((" " . 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 :if (package-installed-p 'tempel) :defines tempel-path @@ -904,21 +847,21 @@ ("C-c c r" . eglot-rename)) :hook ((eglot-managed-mode . (lambda () (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t))) (nix-mode . (lambda () (if (and (project-current nil) - (executable-find "nil" t)) - (eglot-ensure)))) + (executable-find "nil" t)) + (eglot-ensure)))) (python-base-mode . (lambda () (if (and (project-current nil) - (or (executable-find "pyright" t) - (executable-find "pylsp" t))) - (eglot-ensure)))) + (or (executable-find "pyright" t) + (executable-find "pylsp" t))) + (eglot-ensure)))) (lua-mode . (lambda () (if (and (project-current nil) - (executable-find "lua-language-server" t)) - (eglot-ensure)))) + (executable-find "lua-language-server" t)) + (eglot-ensure)))) ((rust-ts-mode rust-mode) . (lambda () (if (and (project-current nil) - (executable-find "rust-analyzer" t)) - (eglot-ensure)))) + (executable-find "rust-analyzer" t)) + (eglot-ensure)))) ((js-base-mode typescript-ts-base-mode) . (lambda () (if (and (project-current nil) - (executable-find "typescript-language-server" t)) - (eglot-ensure)))) + (executable-find "typescript-language-server" t)) + (eglot-ensure)))) ) :custom (eglot-menu-string "lsp") @@ -995,38 +938,33 @@ (flymake-no-changes-timeout 1) (flymake-show-diagnostics-at-end-of-line 'short)) -(use-package flymake-popon - :if (package-installed-p 'flymake-popon) - :functions flymake-popon-mode - :requires flymake - :hook ((flymake-mode . (lambda () (flymake-popon-mode +1))))) - (use-package flymake-shellcheck - :if (and (executable-find "shellcheck") - (package-installed-p 'flymake-shellcheck)) + :if (package-installed-p 'flymake-shellcheck) + :functions flymake-shellcheck-load :requires flymake - :hook (sh-mode . flymake-shellcheck-load)) + :hook (sh-mode . (lambda () (if (executable-find "shellcheck" t) + (flymake-shellcheck-load))))) (use-package flymake-yamllint - :if (and (executable-find "yamllint") - (package-installed-p 'flymake-yamllint)) + :if (package-installed-p 'flymake-yamllint) :functions flymake-yamllint-setup :requires flymake - :hook (yaml-ts-mode . flymake-yamllint-setup)) + :hook (yaml-ts-mode . (lambda () (if (executable-find "yamllint" t) + (flymake-yamllint-setup))))) (use-package flymake-clippy - :if (and (executable-find "clippy") - (package-installed-p 'flymake-clippy)) + :if (package-installed-p 'flymake-clippy) :functions flymake-clippy-setup-backend :requires flymake - :hook (rust-mode . flymake-clippy-setup-backend)) + :hook (rust-mode . (lambda () (if (executable-find "clippy" t) + (flymake-clippy-setup-backend))))) (use-package flymake-eslint - :if (and (executable-find "eslint") - (package-installed-p 'flymake-eslint)) + :if (package-installed-p 'flymake-eslint) :functions flymake-eslint-enable :requires flymake - :hook ((js-base-mode typescript-ts-base-mode) . flymake-eslint-enable)) + :hook ((js-base-mode typescript-ts-base-mode) . (lambda () (if (executable-find "eslint" t) + (flymake-eslint-enable))))) (use-package project :functions (project-forget-zombie-projects @@ -1076,13 +1014,6 @@ Calls `project-remember-projects-under' for ~/Projects/" ("\\`\\(?:sourcehut:\\|sh:\\)\\([^:]+\\)\\'" "git.sr.ht" "sourcehut.user") ("\\`\\(?:gitea:\\|gt:\\)\\([^:]+\\)\\'" "git.xenia.me.uk" "gitea.user")))) -(use-package aggressive-indent - :if (package-installed-p 'aggressive-indent) - :hook (elisp-mode - lisp-mode - lisp-data-mode - rust-mode)) - (use-package nix-mode :if (package-installed-p 'nix-mode) :mode "\\.nix\\'" @@ -1170,27 +1101,14 @@ Calls `project-remember-projects-under' for ~/Projects/" :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)) +(if (package-installed-p 'mu4e) + (load-file (locate-user-emacs-file "modules/my-mu4e.el"))) (use-package bbdb :bind (("M-g b" . bbdb-display-all-records)) :custom (bbdb-file (locate-user-emacs-file "bbdb.gpg"))) -(if (package-installed-p 'mu4e) - (load-file (locate-user-emacs-file "modules/my-mu4e.el"))) - (use-package erc :commands erc-compute-nick :custom diff --git a/modules/my-mu4e.el b/modules/my-mu4e.el index 3037838..3c42f0e 100644 --- a/modules/my-mu4e.el +++ b/modules/my-mu4e.el @@ -1,14 +1,21 @@ ;;; my-mu4e.el -- mu4e -*- lexical-binding: t -*- ;;; Commentary: ;;; Code: -(setq sendmail-program (executable-find "msmtp") - send-mail-function #'sendmail-send-it - 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 - mail-user-agent 'mu4e-user-agent + +(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)) + +(setq mail-user-agent 'mu4e-user-agent read-mail-command 'mu4e) (use-package mm-decode