From 03346eeaeb68633a50d6687659cbcdf46d243d36 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 25 Sep 2023 01:02:13 -0600 Subject: [PATCH] [Emacs] Add autoflake and isort --- dotfiles/emacs.d/README.org | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 45f410fe..6e511598 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -2171,8 +2171,6 @@ I don't use auto-complete at all, so I have set up a hook to automatically disab ** apheleia #+begin_src emacs-lisp (use-package apheleia - :init - (defvar imalison:apheleia-allowed nil) :config (progn (setq-default apheleia-inhibit t) @@ -2284,7 +2282,6 @@ I don't use auto-complete at all, so I have set up a hook to automatically disab *** python #+BEGIN_SRC emacs-lisp (defvar imalison:use-lsp-python t) -(defvar imalison:use-black nil) (use-package python :commands python-mode @@ -2293,12 +2290,22 @@ I don't use auto-complete at all, so I have set up a hook to automatically disab (defun imalison:python-mode () (add-hook 'hack-local-variables-hook (lambda () - (when imalison:use-black - (setq imalison:apheleia-allowed t)) (when imalison:use-lsp-python (lsp-deferred))) nil t)) :config (progn + (use-package apheleia + :config + (progn + (setf (alist-get 'isort apheleia-formatters) + '("isort" "--stdout" "-")) + (setf (alist-get 'autoflake apheleia-formatters) + '("autoflake" "--stdout" "--remove-all-unused-imports" + "--ignore-init-module-imports" "-")) + (setf (alist-get 'python-mode apheleia-mode-alist) + '(autoflake isort black)) + (setf (alist-get 'python-ts-mode apheleia-mode-alist) + (alist-get 'python-mode apheleia-mode-alist)))) (use-package lsp-mode :config (progn