mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-19 03:48:29 +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:
|
To enable Ruff with automatic formatting on save, use the following configuration:
|
||||||
|
|
||||||
```elisp
|
```elisp
|
||||||
(add-hook 'python-mode-hook 'eglot-ensure)
|
|
||||||
(with-eval-after-load 'eglot
|
(with-eval-after-load 'eglot
|
||||||
(add-to-list 'eglot-server-programs
|
(add-to-list 'eglot-server-programs
|
||||||
'(python-mode . ("ruff" "server")))
|
'(python-base-mode . ("ruff" "server"))))
|
||||||
(add-hook 'after-save-hook
|
(add-hook 'python-base-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(when (and (derived-mode-p 'python-base-mode)
|
(eglot-ensure)
|
||||||
(bound-and-true-p eglot--managed-mode))
|
(add-hook 'after-save-hook 'eglot-format nil t)))
|
||||||
(eglot-format-buffer)))))
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Ruff is available as [`flymake-ruff`](https://melpa.org/#/flymake-ruff) on MELPA:
|
Ruff is available as [`flymake-ruff`](https://melpa.org/#/flymake-ruff) on MELPA:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue