https://github.com/purcell/emacs-nixfmt
Emacs package for reformatting Nix code using nixfmt
https://github.com/purcell/emacs-nixfmt
Last synced: over 1 year ago
JSON representation
Emacs package for reformatting Nix code using nixfmt
- Host: GitHub
- URL: https://github.com/purcell/emacs-nixfmt
- Owner: purcell
- Created: 2024-07-24T15:26:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-07T07:25:49.000Z (over 1 year ago)
- Last Synced: 2025-03-25T03:31:26.830Z (over 1 year ago)
- Language: Emacs Lisp
- Size: 7.81 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
[](http://melpa.org/#/nixfmt)
[](http://stable.melpa.org/#/nixfmt)
[](https://github.com/purcell/emacs-nixfmt/actions/workflows/test.yml)

nixfmt.el
==============
This Emacs library provides commands and a minor mode for easily reformatting
Nix source code using the [nixfmt][nixfmt] command.
Installation
=============
If you choose not to use one of the convenient
packages in [MELPA][melpa], you'll need to
add the directory containing `nixfmt.el` to your `load-path`, and
then `(require 'nixfmt)`.
Usage
=====
Customise the `nixfmt-command` variable as desired, then call
`nixfmt-buffer` or `nixfmt-region` as convenient.
Enable `nixfmt-on-save-mode` in Nix buffers like this:
```el
(add-hook 'nix-mode-hook 'nixfmt-on-save-mode)
```
or locally to your project with a form in your .dir-locals.el like
this:
```el
((nix-mode
(mode . nixfmt-on-save)))
```
You might like to bind `nixfmt` or `nixfmt-buffer` to a key,
e.g. with:
```el
(define-key 'nix-mode-map (kbd "C-c C-f") 'nixfmt)
```
[melpa]: http://melpa.org
[nixfmt]: https://github.com/nixos/nixfmt
[💝 Support this project and my other Open Source work](https://www.patreon.com/sanityinc)
[💼 LinkedIn profile](https://uk.linkedin.com/in/stevepurcell)
[✍ sanityinc.com](http://www.sanityinc.com/)