jolby / ob-zig.el

Org babel bindings for the Zig language
GNU General Public License v3.0
7 stars 5 forks source link

+TITLE: ob-zig.el - Org Babel bindings for the Zig programming language

This implementation mostly follows ob-C.el, which provides org-babel support for the C/C++/D languages.

It is also nice to have zig-mode installed for working with zig source:

+begin_src emacs-lisp

(add-to-list 'load-path "/home/path-to-where-you-checked-out-ob-zig/")

+end_src

At this point, you should be able to interactively execute zig source blocks in org mode documents.

Here is an example of a zig code block within an org-mode document:

+begin_src org

,#+source: simple ,#+begin_src zig :imports '(std) const stdout = std.io.getStdOut().writer(); try stdout.print("{s}", .{"hello"}); ,#+end_src

+end_src

If you place the cursor somewhere within the above code block, and then press the key chord: =C-c C-c=, emacs will execute that zig source code and insert the result below:

+RESULTS: simple

: hello

Read the documentation of Org Babel for more examples of what you can do with source code blocks of many different languages.

+begin_src elisp

(add-to-list 'load-path (expand-file-name "straight/repos/org/testing" doom-local-dir))

+end_src

The file test-ob-zig-runner.el has some utility functions for setting up paths and running the ERT test suite. It should be sufficient to load that file and then call the interactive function: =M-x test-ob-zig-run-tests=.