summary refs log tree commit diff
path: root/emacs/custom/my-packages.el
blob: dca13d12e8316d10d1f110db42acacc493a0d691 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
;;; my-packages.el --- List of packages to install -*- lexical-binding: t -*-
;; Author: Franck Cuny <franck@fcuny.net>

;;; Commentary:

;;; Code:

(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

    ;; org-mode
    org-cliplink

    ;; 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)

;;; my-packages.el ends here