From aec8ecac63d8a9eb7992156ea39bb8da92fcf7ba Mon Sep 17 00:00:00 2001 From: Grant Hunter <5445379+grantdhunter@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:40:22 -0700 Subject: [PATCH] run fixall on save in python --- private_dot_emacs.d/init.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/private_dot_emacs.d/init.el b/private_dot_emacs.d/init.el index 6d12ecd..1f74bdc 100644 --- a/private_dot_emacs.d/init.el +++ b/private_dot_emacs.d/init.el @@ -467,8 +467,17 @@ The DWIM behaviour of this command is as follows: python :after lsp-mode :ensure flycheck - :hook ((before-save . lsp-format-buffer) - (before-save . lsp-organize-imports))) + :preface + (defun lsp-fix-all () + (interactive) + (condition-case nil + (lsp-execute-code-action-by-kind "source.fixAll") + (lsp-no-code-actions + (when (called-interactively-p 'any) + (lsp--info "source.fixAll action not available"))))) + :hook ((before-save . lsp-fix-all) + (before-save . lsp-organize-imports) + (before-save . lsp-format-buffer))) (use-package lsp-pyright :after lsp-mode