Syntax highlighting via tree-sitter. Grammars are .so files loaded
on demand with dlopen — the editor binary doesn't bundle any
particular language; you pick what you want.
| Command | Action |
|---|---|
:ts on :ts off :ts auto |
Enable / disable / auto-detect highlighting per buffer |
:tslang <name> |
Force a language for the current buffer |
:tsi <name> |
Install a tree-sitter grammar |
Auto-detection uses the buffer's filetype (file extension or
shebang). When it fires, the plugin tries to dlopen a grammar
called tree_sitter_<name> from the configured grammar directory.
~/.config/hed/ts/<lang>.so
This is what tsi writes to. The library is the compiled grammar
for tree-sitter-<lang> (e.g., tree-sitter-c,
tree-sitter-python).
The bundled tsi helper clones the upstream tree-sitter-<lang>
repository, builds the parser as a shared library, and drops the
result into ~/.config/hed/ts/.
From the shell:
tsi python
tsi c
tsi rustOr from inside hed:
:tsi python
After :tsi, run :tslang python (or just open a Python file with
:ts auto) to start highlighting.
tsi needs git, a C compiler (cc), and network access. The
shared library is built with the same C runtime as hed, so the
grammar runs against the statically linked tree-sitter runtime
shipped in the editor binary.
Color decisions come from the queries under
queries/<lang>/highlights.scm in this repository
— the same files used by neovim's tree-sitter plugin. If you write
your own queries, drop them at ~/.config/hed/ts/queries/<lang>/
and they take precedence.
- The vendored tree-sitter runtime is statically linked into hed —
no
libtree-sittersystem package needed. - A grammar
.soonly works against a tree-sitter runtime version it was compiled for. If:ts autoreports a load failure after atsi, the grammar's tree-sitter version drifted from the one bundled in this build —:tsi <lang>again to recompile against the current runtime. - Build hed without highlighting at all:
make WITH_TREESITTER=0. The editor compiles cleanly without the plugin or the runtime.