branch: elpa/zig-mode
commit 9f86fded13e28c6c9ccf56d417276547bac7e54e
Author: Jacob Young <jacob...@users.noreply.github.com>
Commit: Jacob Young <15544577+jacob...@users.noreply.github.com>

    format fixes
    
     * allow ast check to be configured
     * fix zon format
    
    Closes #105
---
 README.md   |  2 +-
 zig-mode.el | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 30cccf7b52..c21d887ce0 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ Then add the following to your `.emacs` file:
 (unless (version< emacs-version "24")
   (add-to-list 'load-path "~/path/to/your/zig-mode/")
   (autoload 'zig-mode "zig-mode" nil t)
-  (add-to-list 'auto-mode-alist '("\\.zig\\'" . zig-mode)))
+  (add-to-list 'auto-mode-alist '("\\.\\(zig\\|zon\\)\\'" . zig-mode))
 ```
 
 ## Testing
diff --git a/zig-mode.el b/zig-mode.el
index 30f44d825b..4499f2879b 100644
--- a/zig-mode.el
+++ b/zig-mode.el
@@ -46,6 +46,11 @@
   :type 'boolean
   :safe #'booleanp)
 
+(defcustom zig-ast-check-on-format nil
+  "Look for simple compile errors on format."
+  :type 'boolean
+  :safe #'booleanp)
+
 (defcustom zig-zig-bin "zig"
   "Path to zig executable."
   :type 'file
@@ -108,10 +113,11 @@ If given a SOURCE, execute the CMD on it."
   (zig--run-cmd "run" (file-local-name (buffer-file-name)) "-O" 
zig-run-optimization-mode))
 
 ;; zig fmt
-
 (reformatter-define zig-format
   :program zig-zig-bin
-  :args '("fmt" "--stdin")
+  :args (append '("fmt" "--stdin")
+                (when (string-match-p "\\.zon\\'" buffer-file-name) '("--zon"))
+                (when zig-ast-check-on-format '("--ast-check")))
   :group 'zig-mode
   :lighter " ZigFmt")
 

Reply via email to