A tree-sitter grammar for Clojure and ClojureScript, packaged with WebAssembly support for portable use without requiring a C compiler.
This is a fork of sogaiu/tree-sitter-clojure that adds WASM builds, multi-language bindings (Node.js, Rust, Go, Python, C, Swift), and CI/CD workflows.
npm install @yogthos/tree-sitter-clojureconst { Parser, Language } = require("web-tree-sitter");
await Parser.init();
const parser = new Parser();
const clojure = await Language.load(
require.resolve("@yogthos/tree-sitter-clojure/tree-sitter-clojure.wasm")
);
parser.setLanguage(clojure);
const tree = parser.parse("(defn hello [name] (println name))");
console.log(tree.rootNode.toString());This repository provides some files used to create various artifacts (e.g. dynamic libraries, WebAssembly modules) used for handling Clojure and ClojureScript source code via tree-sitter.
Please see the what and why document for detailed information.
Changes may occur because:
- There may be unanticipated important use cases we may want to account for
- The grammar depends on tree-sitter which remains in flux (and is still pre 1.0)
- It's possible we missed something or got something wrong about Clojure and we might want to remedy that
Note that previously tagged versions may work fine depending on the use case. See the changelog for details.
There are some documents in the doc directory covering
topics such as:
This project is based on the original tree-sitter-clojure grammar by sogaiu. All credit for the grammar design and comprehensive test corpus goes to the original project.
Please see the credits for additional acknowledgments.