mirror of
https://github.com/doomemacs/doomemacs.git
synced 2025-12-15 23:00:52 -08:00
feat(python): add uv virtual environment support
This commit is contained in:
parent
ead254e152
commit
beed37ad83
5 changed files with 47 additions and 0 deletions
26
modules/lang/python/autoload/uv.el
Normal file
26
modules/lang/python/autoload/uv.el
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
;;; lang/python/autoload/uv.el -*- lexical-binding: t; -*-
|
||||
;;;###if (modulep! +uv)
|
||||
|
||||
;;;###autoload
|
||||
(defvar +uv--project nil)
|
||||
|
||||
;;;###autoload
|
||||
(defun +python-uv-mode-set-auto-h ()
|
||||
"Set uv-mode virtualenv from buffer-local variable."
|
||||
(when (memq major-mode '(python-mode python-ts-mode))
|
||||
(when (not (local-variable-p '+uv--project))
|
||||
(make-local-variable '+uv--project)
|
||||
(setq +uv--project (+python-uv-read-project-from-file)))
|
||||
(if +uv--project
|
||||
(uv-mode-set)
|
||||
(uv-mode-unset))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +python-uv-read-project-from-file ()
|
||||
"Read uv project root from .venv directory presence."
|
||||
(when-let (root-path (projectile-locate-dominating-file default-directory ".venv"))
|
||||
(let ((venv-path (expand-file-name ".venv" root-path)))
|
||||
(if (file-directory-p venv-path)
|
||||
root-path
|
||||
(message "uv: .venv directory not found in `%s'." root-path)
|
||||
nil))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue