mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-18 19:41:34 +00:00
refactor using LOCAL and base-mode
This commit is contained in:
parent
ca226d85f7
commit
f25e06a6f5
1 changed files with 5 additions and 7 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue