Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/purcell/emacs-nixfmt

Emacs package for reformatting Nix code using nixfmt
https://github.com/purcell/emacs-nixfmt

Last synced: about 2 months ago
JSON representation

Emacs package for reformatting Nix code using nixfmt

Awesome Lists containing this project

README

        

[![Melpa Status](http://melpa.org/packages/nixfmt-badge.svg)](http://melpa.org/#/nixfmt)
[![Melpa Stable Status](http://stable.melpa.org/packages/nixfmt-badge.svg)](http://stable.melpa.org/#/nixfmt)
[![Build Status](https://github.com/purcell/emacs-nixfmt/actions/workflows/test.yml/badge.svg)](https://github.com/purcell/emacs-nixfmt/actions/workflows/test.yml)
Support me

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/)