├── .github
├── FUNDING.yml
└── workflows
│ └── test.yml
├── Makefile
├── README.md
└── nixpkgs-fmt.el
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | patreon: sanityinc
2 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | paths-ignore:
6 | - '**.md'
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | strategy:
12 | matrix:
13 | emacs_version:
14 | - 24.3
15 | - 24.5
16 | - 25.1
17 | - 25.3
18 | - 26.1
19 | - 26.3
20 | - 27.1
21 | - 27.2
22 | - 28.1
23 | - 28.2
24 | - snapshot
25 | steps:
26 | - uses: purcell/setup-emacs@master
27 | with:
28 | version: ${{ matrix.emacs_version }}
29 |
30 | - uses: actions/checkout@v2
31 | - name: Run tests
32 | run: make
33 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | EMACS ?= emacs
2 |
3 | # A space-separated list of required package names
4 | NEEDED_PACKAGES = package-lint reformatter
5 |
6 | INIT_PACKAGES="(progn \
7 | (require 'package) \
8 | (push '(\"melpa\" . \"https://melpa.org/packages/\") package-archives) \
9 | (package-initialize) \
10 | (dolist (pkg '(${NEEDED_PACKAGES})) \
11 | (unless (package-installed-p pkg) \
12 | (unless (assoc pkg package-archive-contents) \
13 | (package-refresh-contents)) \
14 | (package-install pkg))) \
15 | )"
16 |
17 | all: compile package-lint clean-elc
18 |
19 | package-lint:
20 | ${EMACS} -Q --eval ${INIT_PACKAGES} -batch -f package-lint-batch-and-exit nixpkgs-fmt.el
21 |
22 | compile: clean-elc
23 | ${EMACS} -Q --eval ${INIT_PACKAGES} -L . -batch -f batch-byte-compile *.el
24 |
25 | clean-elc:
26 | rm -f f.elc
27 |
28 | .PHONY: all compile clean-elc package-lint
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](http://melpa.org/#/nixpkgs-fmt)
2 | [](http://stable.melpa.org/#/nixpkgs-fmt)
3 | [](https://github.com/purcell/emacs-nixpkgs-fmt/actions/workflows/test.yml)
4 |
5 |
6 | nixpkgs-fmt.el
7 | ==============
8 |
9 | This Emacs library provides commands and a minor mode for easily reformatting
10 | Nix source code using the [nixpkgs-fmt][nixpkgs-fmt] command.
11 |
12 | Installation
13 | =============
14 |
15 | If you choose not to use one of the convenient
16 | packages in [MELPA][melpa], you'll need to
17 | add the directory containing `nixpkgs-fmt.el` to your `load-path`, and
18 | then `(require 'nixpkgs-fmt)`.
19 |
20 | Usage
21 | =====
22 |
23 | Customise the `nixpkgs-fmt-command` variable as desired, then call
24 | `nixpkgs-fmt-buffer` or `nixpkgs-fmt-region` as convenient.
25 |
26 | Enable `nixpkgs-fmt-on-save-mode` in Nix buffers like this:
27 |
28 | ```el
29 | (add-hook 'nix-mode-hook 'nixpkgs-fmt-on-save-mode)
30 | ```
31 |
32 | or locally to your project with a form in your .dir-locals.el like
33 | this:
34 |
35 | ```el
36 | ((nix-mode
37 | (mode . nixpkgs-fmt-on-save)))
38 | ```
39 |
40 | You might like to bind `nixpkgs-fmt` or `nixpkgs-fmt-buffer` to a key,
41 | e.g. with:
42 |
43 | ```el
44 | (define-key 'nix-mode-map (kbd "C-c C-f") 'nixpkgs-fmt)
45 | ```
46 |
47 | [melpa]: http://melpa.org
48 | [nixpkgs-fmt]: https://github.com/nix-community/nixpkgs-fmt
49 |
50 |