summary refs log tree commit diff
path: root/emacs/init.el
blob: 058274538c18d9884518e83b13e013ee67018bb6 (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
108
109
110
111
112
113
114
115
;;; init.el --- Initialize my Emacs configuration
;;; Commentary:

;;; Code:

;; store all the customizations into that file. if the file does not
;; exists, we create an empty file, and then we load it.
(setq custom-file (expand-file-name "var/custom.el" user-emacs-directory))
(when (not (file-exists-p custom-file))
  (write-region "" nil custom-file))
(load custom-file)

(setq gc-cons-threshold 64000000)
(add-hook 'after-init-hook #'(lambda ()
                               ;; restore after startup
                               (setq gc-cons-threshold 800000)))

(require 'package)

(add-to-list 'package-archives
	     '("melpa" .
	       "https://melpa.org/packages/"))

(defvar my/package-list '(chef-mode
                          consult
                          corfu
                          dockerfile-mode
                          eglot
                          elfeed
                          elfeed-org
                          eshell-bookmark
                          exec-path-from-shell
                          git-commit
                          git-link
                          git-modes
                          go-mode
                          gotest
                          hcl-mode
                          jq-format
                          magit
                          marginalia
                          markdown-mode
                          nix-mode
                          notmuch
                          orderless
                          protobuf-mode
                          rg
                          systemd
                          terraform-doc
                          terraform-mode
                          vertico
                          which-key
                          yaml-mode
                          yasnippet)
  "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)))

;; run package installation
(my/install-packages)

(add-to-list 'load-path (expand-file-name "custom/" user-emacs-directory))
(add-to-list 'load-path (expand-file-name "elisp/" user-emacs-directory))

(require 'my-settings)
(require 'my-ui)
(require 'my-dired)
(require 'my-navigation)
(require 'my-completion)
(require 'my-edit)
(require 'my-text)
(require 'my-git)
(require 'my-org)
(require 'my-conf)
(require 'my-prog)
(require 'my-eshell)
(require 'my-tramp)
(require 'my-notmuch)
(require 'my-elfeed)

(require 'my-buffers)
(require 'my-git-extra)
(require 'my-gerrit)
(require 'my-strings)
(require 'my-web)
(require 'my-work)
(require 'my-uptime)
(require 'my-cheeseboard)
(require 'my-packages-extra)

;;; init.el ends here