diff --git a/docs/editors/setup.md b/docs/editors/setup.md index 2a59fc3a24..88c12251b3 100644 --- a/docs/editors/setup.md +++ b/docs/editors/setup.md @@ -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: