From 51b81ab1006bd3ee54a5991b3925809b631f8586 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 18 Jan 2024 13:22:29 -0500 Subject: [PATCH] Use pet for detecting python environment --- .emacs.d/init.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index fb7ccc7..1ab1640 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1120,6 +1120,28 @@ :autoload smali-mode :mode "\\.smali\\'") +(use-package pet :demand :if (package-installed-p 'pet) + :delight + :config + (defun pet--python-shell-setup () + (setq-local python-shell-interpreter (pet-executable-find "python") + python-shell-virtualenv-root (pet-virtualenv-root))) + (setq pet-toml-to-json-program "yq" + pet-toml-to-json-program-arguments '("-p" "toml" "-o" "json") + pet-yaml-to-json-program "yq" + pet-yaml-to-json-program-arguments '("-p" "yaml" "-o" "json")) + (add-hook 'python-base-mode-hook 'pet-mode -10) + (add-hook 'python-base-mode-hook 'pet--python-shell-setup) + (add-hook 'python-base-mode-hook 'pet-flycheck-setup) + + (when (boundp 'apheleia-formatters) + (setf (car (alist-get 'black apheleia-formatters)) + '(pet-executable-find "black")) + (setf (car (alist-get 'djlint apheleia-formatters)) + '(pet-executable-find "djlint")) + (setf (car (alist-get 'isort apheleia-formatters)) + '(pet-executable-find "isort")))) + ;;; Local Variables (add-to-list 'safe-local-eval-forms '(outline-hide-body)) ;; Local Variables: