Add :lang zig module

This commit is contained in:
Benjamin Tan 2021-03-20 15:11:04 +08:00
parent ce65645fb8
commit 28705030e0
No known key found for this signature in database
GPG key ID: A853F0716C413825
5 changed files with 53 additions and 0 deletions

View file

@ -151,6 +151,7 @@ Modules that bring support for a language or group of languages to Emacs.
+ terra - TODO
+ web =+lsp= - HTML and CSS (SCSS/SASS/LESS/Stylus) support.
+ [[file:../modules/lang/yaml/README.org][yaml]] =+lsp= - TODO
+ [[file:../modules/lang/zig/README.org][zig]] =+lsp= - Zig support.
* :os

View file

@ -167,6 +167,7 @@
;;terra ; Earth and Moon in alignment for performance.
;;web ; the tubes
;;yaml ; JSON, but readable
;;zig ; C, but simpler
:email
;;(mu4e +gmail)

View file

@ -0,0 +1,34 @@
;;; lang/zig/config.el -*- lexical-binding: t; -*-
(after! projectile
(pushnew! projectile-project-root-files "build.zig"))
;;
;; zig-mode
(use-package! zig-mode
:mode "\\.zig$"
:hook (zig-mode . rainbow-delimiters-mode)
:config
;; Disable zig-mode's default format on save behaviour.
(setq zig-format-on-save nil)
(when (featurep! +lsp)
(add-hook 'zig-mode-local-vars-hook #'lsp!)))
(map! :localleader
(:after zig-mode
:map zig-mode-map
"b" #'zig-compile
"f" #'zig-format-buffer
"r" #'zig-run
"t" #'zig-test-buffer))
(when (featurep! :checkers syntax)
(flycheck-define-checker zig
"A zig syntax checker using the zig-fmt interpreter."
:command ("zig" "fmt" (eval (buffer-file-name)))
:error-patterns
((error line-start (file-name) ":" line ":" column ": error: " (message) line-end))
:modes zig-mode)
(add-to-list 'flycheck-checkers 'zig))

View file

@ -0,0 +1,13 @@
;; -*- lexical-binding: t; no-byte-compile: t; -*-
;;; lang/zig/doctor.el
(assert! (or (not (featurep! +lsp))
(featurep! :tools lsp))
"This module requires (:tools lsp)")
(unless (executable-find "zig")
(warn! "Couldn't find zig binary"))
(when (featurep! +lsp)
(unless (executable-find "zls")
(warn! "Couldn't find zls binary")))

View file

@ -0,0 +1,4 @@
;; -*- no-byte-compile: t; -*-
;;; lang/zig/packages.el
(package! zig-mode :pin "6f10653cc17b9c74150ac2f6833eaaaf55488398")