mirror of
https://github.com/fscotto/infra.git
synced 2026-07-29 16:20:01 +00:00
Provision Emacs development tools
This commit is contained in:
@@ -40,9 +40,6 @@
|
||||
(setq-local process-environment (copy-sequence process-environment))
|
||||
(setenv "PATH" (concat venv-bin path-separator (getenv "PATH")))))
|
||||
|
||||
(defvar fscotto/python-lsp-install-asked nil
|
||||
"Non-nil if user was already asked about installing pylsp this session.")
|
||||
|
||||
(defun fscotto/resolve-pylsp ()
|
||||
"Return the pylsp binary path if found, else nil.
|
||||
Checks: project .venv, uv tool install path, and PATH."
|
||||
@@ -60,41 +57,18 @@ Checks: project .venv, uv tool install path, and PATH."
|
||||
(fscotto/resolve-pylsp))
|
||||
|
||||
(defun fscotto/python-ensure-lsp-server ()
|
||||
"Ensure a Python LSP server is installed, prompting the user if needed.
|
||||
If pylsp is already available, start LSP immediately. Otherwise, ask once
|
||||
whether to install it via uv. On confirmation, install python-lsp-server
|
||||
as a uv tool and then start LSP."
|
||||
(unless (fboundp 'lsp-deferred)
|
||||
(message "python: lsp-mode not available")
|
||||
(return-from fscotto/python-ensure-lsp-server))
|
||||
|
||||
(if (fscotto/python-lsp-server-available-p)
|
||||
(progn
|
||||
(setq lsp-pylsp-server-command (fscotto/resolve-pylsp))
|
||||
(lsp-deferred))
|
||||
(when (or fscotto/python-lsp-install-asked
|
||||
(y-or-n-p "python-lsp-server not found. Install it via uv? "))
|
||||
(setq fscotto/python-lsp-install-asked t)
|
||||
(let ((buf (current-buffer)))
|
||||
(message "Installing python-lsp-server via uv in background...")
|
||||
(make-process
|
||||
:name "uv-pylsp-install"
|
||||
:buffer (get-buffer-create " *uv-pylsp-install*")
|
||||
:command '("uv" "tool" "install" "--upgrade" "python-lsp-server")
|
||||
:sentinel
|
||||
(lambda (proc event)
|
||||
(cond
|
||||
((string-match-p "finished" event)
|
||||
(message "python-lsp-server installed.")
|
||||
(setq lsp-pylsp-server-command (fscotto/resolve-pylsp))
|
||||
(with-current-buffer buf
|
||||
(lsp-deferred)))
|
||||
((string-match-p "exited\\|failed" event)
|
||||
(with-current-buffer buf
|
||||
(message "python-lsp-server installation failed. Check *uv-pylsp-install* buffer."))))))))))
|
||||
"Start Python LSP when its Ansible-managed pylsp executable is available."
|
||||
(cond
|
||||
((not (fboundp 'lsp-deferred))
|
||||
(message "python: lsp-mode not available"))
|
||||
((fscotto/python-lsp-server-available-p)
|
||||
(setq lsp-pylsp-server-command (fscotto/resolve-pylsp))
|
||||
(lsp-deferred))
|
||||
(t
|
||||
(message "python: pylsp not found; run the desktop Ansible profile"))))
|
||||
|
||||
(defun fscotto/python-maybe-start-lsp ()
|
||||
"Start Python LSP, installing pylsp via uv if needed."
|
||||
"Start Python LSP when pylsp is available."
|
||||
(fscotto/python-ensure-lsp-server))
|
||||
|
||||
(defun fscotto/python-setup-check-command ()
|
||||
|
||||
@@ -21,4 +21,11 @@
|
||||
;; Loading DAP adapters
|
||||
;; For Python
|
||||
(require 'dap-python)
|
||||
(setq dap-python-debugger 'debugpy))
|
||||
(setq dap-python-debugger 'debugpy
|
||||
dap-python-executable
|
||||
(let ((uv-debugpy-python
|
||||
(expand-file-name
|
||||
"~/.local/share/uv/tools/debugpy/bin/python")))
|
||||
(if (file-executable-p uv-debugpy-python)
|
||||
uv-debugpy-python
|
||||
"python3"))))
|
||||
|
||||
Reference in New Issue
Block a user