Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jolby/ob-zig.el
Org babel bindings for the Zig language
https://github.com/jolby/ob-zig.el
Last synced: 4 days ago
JSON representation
Org babel bindings for the Zig language
- Host: GitHub
- URL: https://github.com/jolby/ob-zig.el
- Owner: jolby
- License: gpl-3.0
- Created: 2021-08-26T12:19:16.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-17T21:22:22.000Z (3 months ago)
- Last Synced: 2024-08-17T22:28:45.247Z (3 months ago)
- Language: Emacs Lisp
- Size: 126 KB
- Stars: 7
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
#+TITLE: ob-zig.el - Org Babel bindings for the Zig programming language
* Introduction
ob-zig.el provides [[https://orgmode.org/worg/org-contrib/babel/intro.html][Org Babel]] support for the [[https://ziglang.org][Zig]] programming language. Org
Babel allows you to interactively edit and execute source code for many
different languages in the same document.This implementation mostly follows ob-C.el, which provides org-babel support for
the C/C++/D languages.
* Prerequisites
- A recent zig compiler that is installed on the exec PATH. [[https://ziglang.org/download/][Download Zig]].
- org-mode/org-babel - these packages come installed with most recent emacs.It is also nice to have zig-mode installed for working with zig source:
- zig-mode.el [[https://github.com/ziglang/zig-mode][Download zig-mode]]
* Installation
#+begin_src shell
git clone https://github.com/jolby/ob-zig.el.git
#+end_src#+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.
* Usage
See the file ob-zig-test.org for examples of zig code blocks. If you place your
cursor within the code blocks you can compile and execute using the key chord:
=C-c C-c= You can also view the expanded source code block with the key chord: =C-c
C-v C-v=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
: helloRead the documentation of Org Babel for more examples of what you can do with
source code blocks of many different languages.
* Testing
ob-zig.el has a test suite that works with the [[https://www.gnu.org/software/emacs/manual/html_node/ert/index.html][ERT (Emacs Lisp Regression
Testing)]] and org-test framework that comes with emacs. The directory containing
org-test.el needs to be on the load path. In most cases this will be the
"testing" directory under the root of the main org package on your system. On my
doom-emacs setup, I needed to do this to get org-test on the load path:#+begin_src elisp
(add-to-list 'load-path (expand-file-name "straight/repos/org/testing" doom-local-dir))
#+end_srcThe 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=.