Skip to content

Commit 9f86fde

Browse files
committed
format fixes
* allow ast check to be configured * fix zon format Closes #105
1 parent c46d024 commit 9f86fde

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Then add the following to your `.emacs` file:
2929
(unless (version< emacs-version "24")
3030
(add-to-list 'load-path "~/path/to/your/zig-mode/")
3131
(autoload 'zig-mode "zig-mode" nil t)
32-
(add-to-list 'auto-mode-alist '("\\.zig\\'" . zig-mode)))
32+
(add-to-list 'auto-mode-alist '("\\.\\(zig\\|zon\\)\\'" . zig-mode))
3333
```
3434

3535
## Testing

zig-mode.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
:type 'boolean
4747
:safe #'booleanp)
4848

49+
(defcustom zig-ast-check-on-format nil
50+
"Look for simple compile errors on format."
51+
:type 'boolean
52+
:safe #'booleanp)
53+
4954
(defcustom zig-zig-bin "zig"
5055
"Path to zig executable."
5156
:type 'file
@@ -108,10 +113,11 @@ If given a SOURCE, execute the CMD on it."
108113
(zig--run-cmd "run" (file-local-name (buffer-file-name)) "-O" zig-run-optimization-mode))
109114

110115
;; zig fmt
111-
112116
(reformatter-define zig-format
113117
:program zig-zig-bin
114-
:args '("fmt" "--stdin")
118+
:args (append '("fmt" "--stdin")
119+
(when (string-match-p "\\.zon\\'" buffer-file-name) '("--zon"))
120+
(when zig-ast-check-on-format '("--ast-check")))
115121
:group 'zig-mode
116122
:lighter " ZigFmt")
117123

0 commit comments

Comments
 (0)