Use pet for detecting python environment

This commit is contained in:
Adam Goldsmith 2024-01-18 13:22:29 -05:00
parent 7d573dc56e
commit 51b81ab100

View File

@ -1120,6 +1120,28 @@
:autoload smali-mode :autoload smali-mode
:mode "\\.smali\\'") :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 ;;; Local Variables
(add-to-list 'safe-local-eval-forms '(outline-hide-body)) (add-to-list 'safe-local-eval-forms '(outline-hide-body))
;; Local Variables: ;; Local Variables: