diff options
Diffstat (limited to '')
-rw-r--r-- | emacs/custom/my-packages.el | 157 |
1 files changed, 93 insertions, 64 deletions
diff --git a/emacs/custom/my-packages.el b/emacs/custom/my-packages.el index da5263b..e802c14 100644 --- a/emacs/custom/my-packages.el +++ b/emacs/custom/my-packages.el @@ -5,70 +5,99 @@ ;;; Code: -(require 'straight) - -;; packages needed for LSP -(straight-use-package 'eglot) - -;; packages needed for python -(straight-use-package 'blacken) -(straight-use-package 'python-docstring) -(straight-use-package 'python-mode) - -;; packages needed for go -(straight-use-package 'go-mode) -(straight-use-package 'gotest) - -;; packages needed for nix -(straight-use-package 'nix-mode) - -;; packages needed for rust -(straight-use-package 'rustic) - -;; packages needed to work with various configuration files -(straight-use-package 'chef-mode) -(straight-use-package 'terraform-doc) -(straight-use-package 'terraform-mode) -(straight-use-package 'toml-mode) -(straight-use-package 'systemd) -(straight-use-package 'dockerfile-mode) -(straight-use-package 'hcl-mode) -(straight-use-package 'jq-format) -(straight-use-package 'yaml-mode) -(straight-use-package 'protobuf-mode) - -;; packages needed for git -(straight-use-package 'git-commit) -(straight-use-package 'git-link) -(straight-use-package 'git-modes) -(straight-use-package 'magit) - -;; packages related to elfeed -(straight-use-package 'elfeed) -(straight-use-package 'elfeed-org) - -;; packages for various text modes -(straight-use-package 'markdown-mode) -(straight-use-package 'yasnippet) - -;; packages for tree-sitter -(straight-use-package 'tree-sitter) -(straight-use-package 'tree-sitter-langs) - -;; packages for navigation -(straight-use-package 'cape) -(straight-use-package 'consult) -(straight-use-package 'corfu) -(straight-use-package 'corfu-doc) -(straight-use-package 'marginalia) -(straight-use-package 'orderless) -(straight-use-package 'vertico) -(straight-use-package 'which-key) - -;; packages for interacting with tools -(straight-use-package 'rg) -(straight-use-package 'exec-path-from-shell) -(straight-use-package 'envrc) +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) + +(defvar my/package-list + '(eglot + ;; python + blacken + python-docstring + python-mode + + ;; go + go-mode + gotest + + ;; nix + nix-mode + + ;; rust + rustic + + ;; various configuration formats + chef-mode + dockerfile-mode + hcl-mode + jq-format + protobuf-mode + systemd + terraform-doc + terraform-mode + toml-mode + yaml-mode + + ;; git + git-commit + git-link + git-modes + magit + + ;; elfeed + elfeed + elfeed-org + + ;; various text modes + markdown-mode + + ;; tree-sitter + tree-sitter + tree-sitter-langs + + ;; navigation + cape + consult + corfu + marginalia + orderless + vertico + which-key + yasnippet + + ;; themes + standard-themes + + ;; packages to interact with external tools + exec-path-from-shell + envrc + rg) + "List of packages to be installed.") + +(defun my/packages-installed-p () + "Check if all packages in `my/package-list' are installed." + (cl-every #'package-installed-p my/package-list)) + +(defun my/require-package (package) + "Install PACKAGE unless already installed." + (unless (memq package my/package-list) + (add-to-list 'my/package-list package)) + (unless (package-installed-p package) + (package-install package))) + +(defun my/require-packages (packages) + "Ensure PACKAGES are installed. +Missing packages are installed automatically." + (mapc #'my/require-package packages)) + +(defun my/install-packages () + "Install all packages listed in `my/package-list'." + (unless (my/packages-installed-p) + ;; check for new packages (package versions) + (message "%s" "Reloading packages DB...") + (package-refresh-contents) + (message "%s" " done.") + ;; install the missing packages + (my/require-packages my/package-list))) (provide 'my-packages) |