fordon_greeman / voidfiles

Branch: main
Switch branches/tags
main
theidioticdev add emacs 2079ec5 1d ago
77 lines · 2.5 KB Rendered Raw Blame History
1 # zig-mode
2
3 Syntax highlighting and automatic indentation for the [Zig programming
4 language](http://ziglang.org) in Emacs. Requires Emacs 24.3 or later.
5
6 ## Installation
7
8 [![NonGNU ELPA](https://elpa.nongnu.org/nongnu/zig-mode.svg)](https://elpa.nongnu.org/nongnu/zig-mode.html)
9 [![MELPA](https://melpa.org/packages/zig-mode-badge.svg)](https://melpa.org/#/zig-mode)
10
11 Simply install the `zig-mode` package via [NonGNU ELPA](https://elpa.nongnu.org/) or
12 [MELPA](https://melpa.org/#/getting-started).
13
14 ### Manual install
15
16 Alternatively, you can `git clone` the `zig-mode` repository somewhere
17 (e.g. under your `~/.emacs.d/`). `zig-mode` depends on
18 [reformatter](https://github.com/purcell/emacs-reformatter) for
19 formatting buffers with `zig fmt`.
20
21 `reformatter` can be installed from MELPA or installed manually in a
22 similar fashion to `zig-mode`. For this method, clone the
23 `reformatter` git repository and add the path to the repository to
24 your `load-path`.
25
26 Then add the following to your `.emacs` file:
27
28 ```elisp
29 (unless (version< emacs-version "24")
30 (add-to-list 'load-path "~/path/to/your/zig-mode/")
31 (autoload 'zig-mode "zig-mode" nil t)
32 (add-to-list 'auto-mode-alist '("\\.zig\\'" . zig-mode)))
33 ```
34
35 ## Testing
36
37 [![CI](https://github.com/ziglang/zig-mode/actions/workflows/main.yml/badge.svg)](https://github.com/ziglang/zig-mode/actions/workflows/main.yml)
38
39 To run all unit tests with `emacs`, run:
40
41 ```bash
42 ./run_tests.sh
43 ```
44
45 Note that Emacs 24.3 or later is required. If you need to specify which Emacs
46 binary to use, you can do that by setting the `EMACS` environment variable,
47 e.g.:
48
49 ```bash
50 EMACS=/usr/bin/emacs24 ./run_tests.sh
51 ```
52
53 ## Optional Configuration
54
55 `zig-mode` used to enable coloration of the compilation buffer using
56 ANSI color codes, but this affected *all* compilation buffers, not just
57 zig compilation output.
58 If you want to restore this behavior, you can add the following snippet
59 to your `init.el` or `.emacs` file:
60
61 ```elisp
62 (if (>= emacs-major-version 28)
63 (add-hook 'compilation-filter-hook 'ansi-color-compilation-filter)
64 (progn
65 (defun colorize-compilation-buffer ()
66 (let ((inhibit-read-only t))
67 (ansi-color-apply-on-region compilation-filter-start (point))))
68 (add-hook 'compilation-filter-hook 'colorize-compilation-buffer)))
69 ```
70
71 ## License
72
73 `zig-mode` is distributed under the terms of the GNU General Public License as
74 published by the Free Software Foundation; either version 3, or (at your
75 option) any later version.
76
77 See the [LICENSE](LICENSE) file for details.