diff --git a/docs/modules.org b/docs/modules.org index 5b0834ca9..998c5286b 100644 --- a/docs/modules.org +++ b/docs/modules.org @@ -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 diff --git a/init.example.el b/init.example.el index 0e3cddb28..3d518d354 100644 --- a/init.example.el +++ b/init.example.el @@ -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) diff --git a/modules/lang/zig/config.el b/modules/lang/zig/config.el new file mode 100644 index 000000000..bf3008765 --- /dev/null +++ b/modules/lang/zig/config.el @@ -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)) diff --git a/modules/lang/zig/doctor.el b/modules/lang/zig/doctor.el new file mode 100644 index 000000000..ecbeca1a1 --- /dev/null +++ b/modules/lang/zig/doctor.el @@ -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"))) diff --git a/modules/lang/zig/packages.el b/modules/lang/zig/packages.el new file mode 100644 index 000000000..b309a6a34 --- /dev/null +++ b/modules/lang/zig/packages.el @@ -0,0 +1,4 @@ +;; -*- no-byte-compile: t; -*- +;;; lang/zig/packages.el + +(package! zig-mode :pin "6f10653cc17b9c74150ac2f6833eaaaf55488398")