Skip to content

Changing the formatter for a single project

Daniel Perez Alvarez edited this page Jan 18, 2025 · 1 revision

To change the formatter for a major mode in a single project add a .dir-locals.el file (or run M-x add-dir-local-variable). See https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html

Examples

Python - Ruff

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((python-mode . ((apheleia-formatter . ruff)))
 (python-ts-mode . ((apheleia-formatter . ruff))))

Typescript - Deno

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((typescript-ts-mode . ((apheleia-formatter . denofmt)
                        (lsp-enabled-clients . 'deno-ls))))

Typescript - Biome

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((json-ts-mode . ((apheleia-formatter . biome)))
 (js-ts-mode . ((apheleia-formatter . biome)))
 (tsx-ts-mode . ((apheleia-formatter . biome)))
 (typescript-ts-mode . ((apheleia-formatter . biome))))