mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-15 22:14:44 +00:00
Add Eglot setup guide for Emacs editor (#12426)
## Summary The purpose of this change is to explain how to use ruff as a language server in Eglot with automatic formatting because I've struggle to use it with Eglot. I've search it online and found that there are some people also struggle too. (See [this reddit post](https://www.reddit.com/r/emacs/comments/118mo6w/eglot_automatic_formatting/) and https://github.com/astral-sh/ruff-lsp/issues/19#issuecomment-1435138828) ## Test Plan I've use this setting myself. And I will continue maintain this part as long as I use it. --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
This commit is contained in:
parent
143e172431
commit
a9f8bd59b2
1 changed files with 11 additions and 0 deletions
|
|
@ -333,6 +333,17 @@ IntelliJ Marketplace (maintained by [@koxudaxi](https://github.com/koxudaxi)).
|
|||
|
||||
## Emacs
|
||||
|
||||
Ruff can be utilized as a language server via [`Eglot`](https://github.com/joaotavora/eglot), which is in Emacs's core.
|
||||
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 'eglot-format))
|
||||
```
|
||||
|
||||
Ruff is available as [`flymake-ruff`](https://melpa.org/#/flymake-ruff) on MELPA:
|
||||
|
||||
```elisp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue