This document covers the installation scripts and configuration files for Helix and Neovim. Both editors use tree-sitter for syntax highlighting; the installation scripts copy query files and register the grammar.
See grammar.adoc for the grammar and queries.adoc for the query files these scripts install.
Helix
Language and grammar stanza
editors/helix/languages.toml is the snippet that install.py appends to
~/.config/helix/languages.toml. It declares weaveback as a language
with a local grammar source pointing to this checkout.
GRAMMAR_DIR is a placeholder that install.py replaces with the
absolute path of the tree-sitter-weaveback/ directory at install time.
// <<ts-helix-lang-toml>>=
# editors/helix/languages.toml
#
# Append this to ~/.config/helix/languages.toml
# then run: hx --grammar build
#
# Prerequisites: a C compiler (cc) in PATH.
[[language]]
name = "weaveback"
scope = "source.weaveback"
file-types = ["weaveback"]
comment-tokens = ["%#"]
indent = { tab-width = 2, unit = " " }
grammar = "weaveback"
[[grammar]]
name = "weaveback"
source = { path = "__GRAMMAR_DIR__" }
// @
Assembly — editors/helix/languages.toml
// <<@file editors/helix/languages.toml>>=
// <<ts-helix-lang-toml>>
// @
Helix install script
The install script performs four steps:
-
Append the
+stanza to~/.config/helix/languages.toml(idempotent — skips if already present). -
Copy
queries/highlights.scmandqueries/injections.scminto the Helix runtime query directory for theweavebacklanguage. -
Append the AsciiDoc injection fragment to the Helix asciidoc query file (idempotent — skips if the injection marker is already present).
-
Run
hx --grammar build(orhelix --grammar buildon Arch Linux) to compile the grammar from source.
Step 4 may print warnings for other grammars that fail; if weaveback is
listed as built, the installation succeeded.
// <<--->>=
#!/usr/bin/env python3
# editors/helix/install.py
#
# Installs the weaveback grammar and queries for Helix.
# Run once after cloning, and again after grammar changes.
#
# Usage: python3 editors/helix/install.py
= .
= # tree-sitter-weaveback/
=
= / /
= / /
= / /
# 1. Append language + grammar config if not already present
# Substitute __GRAMMAR_DIR__ with the actual path of this checkout.
=
=
# 2. Copy weaveback query files into Helix runtime
# 3. Append weaveback injection into AsciiDoc files (once)
= / / /
=
=
# 4. Build the grammar
# Helix is installed as 'hx' on most systems, 'helix' on Arch Linux.
= or
=
# Non-zero often means *other* grammars failed; weaveback may have built fine.
// @
Assembly — editors/helix/install.py
// <<@ //>>=
// <<--->>
// @
Neovim
Neovim uses nvim-treesitter to manage tree-sitter parsers. The
installation is split across three files and one install script:
-
weaveback.lua— registers the weaveback parser from the local grammar checkout and maps the.weavebackfile extension. -
asciidoc.lua— registers the upstreamasciidocandasciidoc_inlineparsers fromcathaysia/tree-sitter-asciidoc, reusing the source already downloaded by the Helix installation if available. -
install.py— copies query files and installs the Lua plugins to~/.config/nvim/after/plugin/.
Weaveback parser registration
weaveback.lua registers the grammar from the local tree-sitter-weaveback/
checkout. The requires_generate_from_grammar = false flag tells
nvim-treesitter that src/parser.c is already generated and up to date,
so no npm or tree-sitter generate step is needed at install time.
GRAMMAR_DIR is replaced by install.py with the absolute path of the
tree-sitter-weaveback/ directory.
// <<ts-nvim-weaveback-lua>>=
-- editors/neovim/weaveback.lua
--
-- Registers the weaveback tree-sitter parser and filetype.
-- Installed by editors/neovim/install.py to:
-- ~/.config/nvim/after/plugin/weaveback.lua
--
-- Prerequisites: nvim-treesitter installed.
-- The grammar is built from the local checkout (no internet needed after clone).
--
-- Usage:
-- :TSInstall weaveback (first time, or after grammar changes)
-- :TSUpdate weaveback (re-build after grammar.js changes)
local ok, parsers = pcall(require, "nvim-treesitter.parsers")
if not ok then
vim.notify("nvim-treesitter not found — skipping weaveback parser registration", vim.log.levels.WARN)
return
end
-- Path to tree-sitter-weaveback/ inside the weaveback checkout.
-- install.py substitutes __GRAMMAR_DIR__ with the actual absolute path.
local grammar_dir = "__GRAMMAR_DIR__"
parsers.get_parser_configs().weaveback = {
install_info = {
url = grammar_dir,
files = { "src/parser.c" },
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "weaveback",
}
vim.filetype.add({
extension = { weaveback = "weaveback" },
})
// @
Assembly — editors/neovim/weaveback.lua
// <<@file editors/neovim/weaveback.lua>>=
// <<ts-nvim-weaveback-lua>>
// @
AsciiDoc parser registration
The asciidoc and asciidoc_inline parsers come from the upstream
cathaysia/tree-sitter-asciidoc repository. A specific commit is pinned
for reproducibility. If Helix was installed first and its grammar build has
already cloned the repository, the Neovim install script reuses those
sources to avoid a second download.
// <<ts-nvim-asciidoc-lua>>=
-- editors/neovim/asciidoc.lua
--
-- Registers the asciidoc + asciidoc_inline tree-sitter parsers.
-- Installed by editors/neovim/install.py to:
-- ~/.config/nvim/after/plugin/asciidoc.lua
--
-- Usage (first time or after grammar changes):
-- :TSInstall asciidoc asciidoc_inline
local ok, parsers = pcall(require, "nvim-treesitter.parsers")
if not ok then
vim.notify("nvim-treesitter not found — skipping asciidoc parser registration", vim.log.levels.WARN)
return
end
local repo = "https://github.com/cathaysia/tree-sitter-asciidoc"
local rev = "14e660bacac69a905e71ab1041eb64eb266a6112"
parsers.get_parser_configs().asciidoc = {
install_info = {
url = repo,
files = { "tree-sitter-asciidoc/src/parser.c",
"tree-sitter-asciidoc/src/scanner.c" },
location = "tree-sitter-asciidoc",
revision = rev,
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "asciidoc",
}
parsers.get_parser_configs().asciidoc_inline = {
install_info = {
url = repo,
files = { "tree-sitter-asciidoc_inline/src/parser.c",
"tree-sitter-asciidoc_inline/src/scanner.c" },
location = "tree-sitter-asciidoc_inline",
revision = rev,
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "asciidoc",
}
vim.filetype.add({
extension = {
adoc = "asciidoc",
asciidoc = "asciidoc",
},
})
// @
Assembly — editors/neovim/asciidoc.lua
// <<@file editors/neovim/asciidoc.lua>>=
// <<ts-nvim-asciidoc-lua>>
// @
Neovim install script
The install script performs five steps:
-
Copy
highlights.scmandinjections.scminto~/.config/nvim/queries/weaveback/, prepending;; extendsso that `nvim-treesitter’s built-in queries (if any) are augmented rather than replaced. -
Install
weaveback.luato~/.config/nvim/after/plugin/, substituting the grammar directory path. -
Copy the asciidoc query files from the Helix grammar cache (if already downloaded); prints a warning if not yet available.
-
Install
asciidoc.luato~/.config/nvim/after/plugin/. -
Append the AsciiDoc injection fragment to
~/.config/nvim/queries/asciidoc/injections.scm(idempotent).
After running the script, open Neovim and run :TSInstall weaveback asciidoc asciidoc_inline.
// <<--->>=
#!/usr/bin/env python3
# editors/neovim/install.py
#
# Installs the weaveback + asciidoc grammars and queries for Neovim (nvim-treesitter).
# Run once after cloning, and again after grammar changes.
#
# Usage: python3 editors/neovim/install.py
#
# Prerequisites: nvim-treesitter installed as a plugin.
# After running, open Neovim and run:
# :TSInstall weaveback asciidoc asciidoc_inline
= .
= # tree-sitter-weaveback/
=
= /
= / /
# Helix caches the asciidoc grammar source; reuse it to avoid a second download.
= / /
= / / / /
= / / / /
# ── 1. weaveback queries ──────────────────────────────────────────────────────────
= / /
= +
# ── 2. weaveback.lua ──────────────────────────────────────────────────────────────
=
# ── 3. asciidoc queries ───────────────────────────────────────────────────────
# Queries are NOT bundled with nvim-treesitter for custom parsers, so we copy
# them from Helix's already-downloaded grammar source.
= / /
continue
= / /
# ── 4. asciidoc.lua ───────────────────────────────────────────────────────────
# ── 5. weaveback injection into [source,weaveback] asciidoc blocks ───────────────────
= / / /
=
=
// @
Assembly — editors/neovim/install.py
// <<@ //>>=
// <<--->>
// @