Provision Emacs development tools

This commit is contained in:
Fabio Scotto di Santolo
2026-06-21 18:41:48 +02:00
parent ae8a6161cd
commit 2fdda39395
5 changed files with 54 additions and 38 deletions

View File

@@ -30,7 +30,18 @@ desktop_source_tools:
desktop_binary_tools: [] desktop_binary_tools: []
desktop_npm_packages: "{{ ai_agents_npm_packages + [] }}" desktop_npm_packages: >-
{{
ai_agents_npm_packages
+ [
{'name': '@mermaid-js/mermaid-cli', 'state': 'latest'},
{'name': 'vscode-langservers-extracted', 'state': 'latest'}
]
}}
desktop_uv_tools:
- debugpy
- python-lsp-server
desktop_common_dotfiles: desktop_common_dotfiles:
- name: XDG autostart entries - name: XDG autostart entries

View File

@@ -170,11 +170,13 @@ desktop_hyprland_packages:
profile_packages: profile_packages:
- alacritty - alacritty
- bash-language-server
- bluez - bluez
- bridge-utils - bridge-utils
- ctags - ctags
- firefox - firefox
- deluge-gtk - deluge-gtk
- delve
- dnsmasq - dnsmasq
- emacs-pgtk - emacs-pgtk
- poppler-glib - poppler-glib
@@ -186,6 +188,9 @@ profile_packages:
- gvfs-mtp - gvfs-mtp
- gvfs-smb - gvfs-smb
- gufw - gufw
- golangci-lint
- gopls
- hunspell
- libvirt - libvirt
- libspa-bluetooth - libspa-bluetooth
- libreoffice - libreoffice
@@ -209,6 +214,7 @@ profile_packages:
- ristretto - ristretto
- rsync - rsync
- shotwell - shotwell
- shfmt
- ruff - ruff
- terminus-font - terminus-font
- texlive - texlive

View File

@@ -552,3 +552,21 @@
when: desktop_npm_packages | length > 0 when: desktop_npm_packages | length > 0
loop_control: loop_control:
label: "{{ item.name }}" label: "{{ item.name }}"
- name: Install desktop Python tools with uv
tags: [packages, emacs]
ansible.builtin.command:
cmd: "uv tool install --upgrade {{ item }}"
become: true
become_user: "{{ username }}"
environment:
HOME: "{{ user_home }}"
register: profile_desktop_common_uv_tool_install
changed_when: >-
(profile_desktop_common_uv_tool_install.stdout | default('')
+ profile_desktop_common_uv_tool_install.stderr | default(''))
is regex('(?i)installed|updated')
loop: "{{ desktop_uv_tools | default([]) }}"
when: desktop_uv_tools | default([]) | length > 0
loop_control:
label: "{{ item }}"

View File

@@ -40,9 +40,6 @@
(setq-local process-environment (copy-sequence process-environment)) (setq-local process-environment (copy-sequence process-environment))
(setenv "PATH" (concat venv-bin path-separator (getenv "PATH"))))) (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 () (defun fscotto/resolve-pylsp ()
"Return the pylsp binary path if found, else nil. "Return the pylsp binary path if found, else nil.
Checks: project .venv, uv tool install path, and PATH." 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)) (fscotto/resolve-pylsp))
(defun fscotto/python-ensure-lsp-server () (defun fscotto/python-ensure-lsp-server ()
"Ensure a Python LSP server is installed, prompting the user if needed. "Start Python LSP when its Ansible-managed pylsp executable is available."
If pylsp is already available, start LSP immediately. Otherwise, ask once (cond
whether to install it via uv. On confirmation, install python-lsp-server ((not (fboundp 'lsp-deferred))
as a uv tool and then start LSP." (message "python: lsp-mode not available"))
(unless (fboundp 'lsp-deferred) ((fscotto/python-lsp-server-available-p)
(message "python: lsp-mode not available") (setq lsp-pylsp-server-command (fscotto/resolve-pylsp))
(return-from fscotto/python-ensure-lsp-server)) (lsp-deferred))
(t
(if (fscotto/python-lsp-server-available-p) (message "python: pylsp not found; run the desktop Ansible profile"))))
(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."))))))))))
(defun fscotto/python-maybe-start-lsp () (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)) (fscotto/python-ensure-lsp-server))
(defun fscotto/python-setup-check-command () (defun fscotto/python-setup-check-command ()

View File

@@ -21,4 +21,11 @@
;; Loading DAP adapters ;; Loading DAP adapters
;; For Python ;; For Python
(require 'dap-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"))))