GitHub - JoshHayes/emacs-ruff-format: Format Python source in Emacs using Ruff (original) (raw)

Melpa Status

ruff-format.el

This Emacs library provides commands and a minor mode for easily reformatting Python source code using Ruff.

Installation

If you choose not to use one of the convenient packages inMELPA, you'll need to add the directory containing ruff-format.elto your load-path, and then (require 'ruff-format).

reformatter is required.

Usage

Customise the ruff-format-command variable as desired, then callruff-format-buffer or ruff-format-region as convenient.

Enable ruff-format-on-save-mode in Python mode buffers like this:

(add-hook 'python-mode-hook 'ruff-format-on-save-mode)

...or locally to your project with a form in your .dir-locals.ellike this:

((python-mode (mode . ruff-format-on-save)))

License

SPDX-License-Identifier: GPL-3.0-or-later