Add package installed check to anything that activates automatically

This commit is contained in:
Evie Litherland-Smith 2024-07-15 08:00:30 +01:00
parent 24b36c5de1
commit e31ba218c1

62
init.el
View file

@ -125,6 +125,7 @@
;; Make `describe-*' screens more helpful
(use-package helpful
:if (package-installed-p 'helpful)
:defines helpful-mode-map
:bind (("<remap> <describe-command>" . helpful-command)
("<remap> <describe-function>" . helpful-callable)
@ -148,16 +149,10 @@
: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))
(require 'ispell))
(use-package flyspell-correct
:if (package-installed-p 'flyspell-correct)
:after flyspell
:bind ( :map flyspell-mode-map
("C-;" . flyspell-correct-wrapper)))
@ -173,21 +168,24 @@
:defines ibuffer-filter-groups
:bind (("C-c b" . ibuffer)))
(use-package avy
:if (package-installed-p 'avy)
:bind (("<remap> <goto-char>" . avy-goto-char)))
(use-package ace-window
:if (package-installed-p '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
: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 avy
:bind (("<remap> <goto-char>" . avy-goto-char)))
(use-package comint
:bind ( :map comint-mode-map
("<remap> <comint-history-isearch-backward-regexp>" . consult-history)))
@ -240,6 +238,7 @@
(add-hook 'prog-mode-hook #'(lambda () (display-line-numbers-mode +1)))
(use-package which-key
:if (package-installed-p 'which-key)
:functions which-key-mode
:config (which-key-mode +1))
@ -258,6 +257,7 @@
(pulse-momentary-highlight-one-line (point)))
(use-package base16-theme
:if (package-installed-p 'base16-theme)
:demand
:defines (base16-one-light-theme-colors
my/load-theme-and-configure)
@ -287,6 +287,7 @@
(if (display-graphic-p) (my/load-theme-and-configure)))
(use-package nerd-icons
:if (package-installed-p 'nerd-icons)
:functions (nerd-icons-octicon))
(use-package nerd-icons-dired
@ -303,12 +304,14 @@
:hook (after-init . (lambda () (nerd-icons-completion-mode +1))))
(use-package minions
:if (package-installed-p 'minions)
:functions minions-mode
:hook (after-init . (lambda () (minions-mode +1)))
:custom
(minions-prominent-modes '(envrc-mode flymake-mode)))
(use-package ligature
:if (package-installed-p 'ligature)
:functions (ligature-set-ligatures
global-ligature-mode)
:config
@ -352,6 +355,7 @@
(display-time-24hr-format t))
(use-package diff-hl
:if (package-installed-p 'diff-hl)
:functions (diff-hl-magit-pre-refresh
diff-hl-magit-post-refresh
global-diff-hl-mode)
@ -523,6 +527,7 @@
"%i" :immediate-finish t))))
(use-package org-roam
:if (package-installed-p 'org-roam)
:after org
:defines org-roam-directory
:functions org-roam-db-autosync-mode
@ -555,6 +560,7 @@
(org-roam-db-autosync-mode +1))
(use-package org-roam-dailies
:requires org-roam
:custom
(org-roam-dailies-directory "./")
(org-roam-dailies-capture-templates
@ -696,6 +702,7 @@
(setq org-preview-latex-default-process 'dvisvgm)
(use-package vertico
:if (package-installed-p 'vertico)
:functions vertico-mode
:hook (after-init . (lambda () (vertico-mode +1)))
:custom
@ -704,6 +711,7 @@
(require 'vertico-directory))
(use-package marginalia
:if (package-installed-p 'marginalia)
:functions marginalia-mode
:hook (after-init . (lambda () (marginalia-mode +1)))
:custom
@ -713,6 +721,7 @@
:config (marginalia-mode +1))
(use-package orderless
:if (package-installed-p 'orderless)
:custom
(completion-styles '(orderless basic))
(completion-category-defaults nil)
@ -725,6 +734,7 @@
:requires nerd-icons)
(use-package corfu
:if (package-installed-p 'corfu)
:defines (corfu-map
corfu-mode-map
corfu-margin-formatters)
@ -777,6 +787,7 @@
:functions corfu-terminal-mode)
(use-package cape
:if (package-installed-p 'cape)
:after corfu
:functions (cape-emoji
cape-file
@ -790,6 +801,7 @@
(cape-dabbrev-min-length (+ corfu-auto-prefix 1)))
(use-package consult
:if (package-installed-p 'consult)
:functions (consult-org-heading
consult-history)
:bind (("<remap> <imenu>" . consult-imenu)
@ -809,6 +821,7 @@
:bind (("C-c s s" . consult-eglot-symbols)))
(use-package embark
:if (package-installed-p 'embark)
:functions embark-prefix-help-command
:bind (("<remap> <describe-bindings>" . embark-bindings)
("C-." . embark-act))
@ -820,6 +833,7 @@
:hook (embark-collect-mode . consult-preview-at-point-mode))
(use-package tempel
:if (package-installed-p 'tempel)
:defines tempel-path
:functions (tempel-expand
tempel-abbrev-mode)
@ -850,9 +864,11 @@
)))
(use-package rainbow-delimiters
:if (package-installed-p 'rainbow-delimiters)
:hook (prog-mode))
(use-package envrc
:if (package-installed-p 'envrc)
:hook (after-init . envrc-global-mode)
:custom
(envrc-show-summary-in-minibuffer t))
@ -868,6 +884,7 @@
(treesit-font-lock-level 3))
(use-package treesit-auto
:if (package-installed-p 'treesit-auto)
:requires treesit
:functions (treesit-auto-add-to-auto-mode-alist
global-treesit-auto-mode)
@ -882,12 +899,10 @@
(eldoc-echo-area-use-multiline-p 3))
(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))))
:hook ((eglot-managed-mode . (lambda () (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t))))
:custom
(eglot-menu-string "lsp")
(eglot-send-changes-idle-time 1)
@ -941,6 +956,7 @@
)
(use-package apheleia
:if (package-installed-p 'apheleia)
:defines (apheleia-formatters
apheleia-mode-alist)
:bind (("C-c c f" . apheleia-format-buffer))
@ -963,23 +979,27 @@
(flymake-show-diagnostics-at-end-of-line nil))
(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 (executable-find "shellcheck")
:if (and (executable-find "shellcheck")
(package-installed-p 'flymake-shellcheck))
:requires flymake
:hook (sh-mode . flymake-shellcheck-load))
(use-package flymake-yamllint
:if (executable-find "yamllint")
:if (and (executable-find "yamllint")
(package-installed-p 'flymake-yamllint))
:functions flymake-yamllint-setup
:requires flymake
:hook (yaml-ts-mode . flymake-yamllint-setup))
(use-package flymake-eslint
:if (executable-find "eslint")
:if (and (executable-find "eslint")
(package-installed-p 'flymake-eslint))
:functions flymake-eslint-enable
:requires flymake
:hook ((js-base-mode typescript-ts-base-mode) . flymake-eslint-enable))
@ -1033,12 +1053,14 @@ Calls `project-remember-projects-under' for ~/Projects/"
("\\`\\(?: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\\'"
:functions nix-prettify-global-mode
:config
@ -1067,6 +1089,7 @@ Calls `project-remember-projects-under' for ~/Projects/"
(setq python-ts-mode-hook python-mode-hook))
(use-package python-docstring
:if (package-installed-p 'python-docstring)
:hook python-base-mode)
(use-package files
@ -1104,6 +1127,7 @@ Calls `project-remember-projects-under' for ~/Projects/"
(doc-view-image-width 850))
(use-package markdown-mode
:if (package-installed-p 'markdown-mode)
:hook
((markdown-mode . turn-on-auto-fill))
:custom
@ -1117,6 +1141,7 @@ Calls `project-remember-projects-under' for ~/Projects/"
(set-face-attribute 'markdown-comment-face nil :inherit 'variable-pitch))
(use-package pandoc-mode
:if (package-installed-p 'pandoc-mode)
:after (markdown-mode)
:hook (markdown-mode . conditionally-turn-on-pandoc))
@ -1138,7 +1163,8 @@ Calls `project-remember-projects-under' for ~/Projects/"
:custom
(bbdb-file (locate-user-emacs-file "bbdb.gpg")))
(load-file (locate-user-emacs-file "modules/my-mu4e.el"))
(if (package-installed-p 'mu4e)
(load-file (locate-user-emacs-file "modules/my-mu4e.el")))
(use-package erc
:commands erc-compute-nick