about summary refs log blame commit diff stats
path: root/.emacs.d/lisp/init-packages.el
blob: 70dc5e8ed6d62570fab0fe0f69f4becc940b329a (plain) (tree)


















                                                                                

                               















                                                                                                      
                                                                                                



                                                                                             

                                                         






                                                 
                                        


                               


                                                                                                        




                                           
;;; init-packages.el --- Package Configuration File -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

;; TODO - straight.el?

(require 'package)
(require 'url)

(setq package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("melpa-stable" . "https://stable.melpa.org/packages/")
                         ("nongnu" . "https://elpa.nongnu.org/nongnu/")
                         ("elpa" . "https://elpa.gnu.org/packages/")))

(package-initialize)

(unless package-archive-contents
  (package-refresh-contents))

(setq package-native-compile t)

(unless (package-installed-p 'use-package)
   (package-install 'use-package))
(require 'use-package)

(setq use-package-always-ensure t)

(use-package diminish)

(use-package paradox
  :config
  (paradox-enable))

(defvar vertico-extensions-dir (expand-file-name "site-lisp/vertico-extensions" user-emacs-directory))
(defvar vertico-extensions '("vertico-directory" "vertico-repeat"))

(defun fetch-vertico-extensions ()
  "Download the latest versions of the required vertico extensions into vertico-extensions-dir."
  (dolist (extension vertico-extensions)
    (let ((ext-file (format "%s.el" extension)))
      (url-copy-file
       (format "https://raw.githubusercontent.com/minad/vertico/main/extensions/%s" ext-file)
       (expand-file-name ext-file vertico-extensions-dir)
       t))))

(unless (file-directory-p vertico-extensions-dir)
  (make-directory vertico-extensions-dir t)
  (fetch-vertico-extensions))

(use-package epl
  :config
  (defvar my/system-packages '("vterm"))
  (defun my/upgrade-packages ()
    (interactive)
    (epl-refresh)
    (when-let ((upgrades (seq-filter (lambda (p) (not (member (epl-package-name p) my/system-packages)))
                                     (mapcar 'epl-upgrade-available (epl-find-upgrades)))))
      (epl-upgrade upgrades))
    (fetch-vertico-extensions)
    (message "Package upgrade finished.")))

(provide 'init-packages)
;;; init-packages.el ends here