Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 2.05 KB

README.md

File metadata and controls

55 lines (42 loc) · 2.05 KB

ruff-flymake

An emacs flymake backend for the python linter ruff.

While ruff has a language server mode that can be used via eglot or lsp-mode, eglot doesn't support running multiple servers at once in a single buffer. This package runs ruff as a separate flymake backend, allowing you to use a different python language server with eglot.

Installation

You probably want to use flymake-ruff instead, which is available in MELPA. If you really want to use this, one, you'll need to install manually by putting the ruff-flymake.el file on your load path.

Setup

This package doesn't activate anything by default. Add it to your flymake backends in your init.el (or equivalent) using:

(require 'ruff-flymake)
(add-hook 'python-mode-hook 'ruff-flymake-setup-backend)

Note that if you're using this package alongside eglot, eglot will by default disable other flymake backends. To avoid this but still get eglot output in your flymake diagnostics, put this in your init.el:

(add-to-list 'eglot-stay-out-of 'flymake)
(defun activate-eglot-flymake-backend ()
  (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t))
(add-hook 'eglot--managed-mode-hook #'activate-eglot-flymake-backend)

Configuration

ruff-flymake will attempt to find ruff on your exec path. If you don't have ruff installed in an accessible location, or if you want to force it to use a specific version, you can set the variable ruff-flymake-ruff-executable to the full path to the ruff binary.

For example (again, in init.el):

(setq ruff-flymake-ruff-executable "/path/to/ruff")

To configure ruff itself, use the standard pyproject.toml or ruff.toml configuration files.

License

This package is MIT-licensed. See the LICENSE file for details.

It's heavily based off of the example backend in the emacs documentation at https://www.gnu.org/software/emacs/manual/html_node/flymake/An-annotated-example-backend.html