refactor using LOCAL and base-mode

This commit is contained in:
Thamer Mahmoud 2025-11-14 22:52:18 +03:00 committed by GitHub
parent ca226d85f7
commit f25e06a6f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -400,15 +400,13 @@ Ruff can be utilized as a language server via [`Eglot`](https://github.com/joaot
To enable Ruff with automatic formatting on save, use the following configuration:
```elisp
(add-hook 'python-mode-hook 'eglot-ensure)
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(python-mode . ("ruff" "server")))
(add-hook 'after-save-hook
(lambda ()
(when (and (derived-mode-p 'python-base-mode)
(bound-and-true-p eglot--managed-mode))
(eglot-format-buffer)))))
'(python-base-mode . ("ruff" "server"))))
(add-hook 'python-base-mode-hook
(lambda ()
(eglot-ensure)
(add-hook 'after-save-hook 'eglot-format nil t)))
```
Ruff is available as [`flymake-ruff`](https://melpa.org/#/flymake-ruff) on MELPA: