feat(latex): add LaTeX language support#202
Conversation
Adds syntax highlighting for LaTeX (.tex) files using the latex-lsp/tree-sitter-latex grammar (MIT, commit 7e0ecdc). highlights.scm is authored from scratch (the grammar ships no queries), using Helix's LaTeX queries as a reference with field names corrected to match the current node-types.json (e.g. curly_group_label for labels, curly_group_path_list for bibtex paths). Both corpus and grammar validation tests pass. Placed in group-willow alongside other markup languages (markdown, typst, asciidoc). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Replace dead (word)/#eq? & pattern with (delimiter) @punctuation.delimiter
The word rule excludes & by regex; & is tokenized as the delimiter node
- Remove required value: field from key_value_pair pattern so bare option
keys (e.g. \documentclass[draft]{article}) receive @variable.parameter
- Add bare-declaration pattern for new_command_definition so \newcommand\foo
receives @function.macro rather than falling back to generic @function
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Add hyperlink node captures for \url and \href — both parse as `hyperlink` not `generic_command`, so the previous generic_command #match? patterns were permanently dead code - Update CHANGELOG.md with unreleased entry for LaTeX support - Regenerate CI workflow via cargo xtask ci generate — latex was missing from the build-plugins-willow job Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Optional follow-up: LaTeX has a natural indentation boundary with Example of what it would look like: (begin_command) @indent
(end_command) @outdentLet me know! |
Adds 5 previously uncovered node types:
- verbatim_environment, listing_environment, minted_environment → @markup.raw
- subscript and superscript (math $x_i^2$) → @markup.raw
- todo (\todo{...}) → command as @comment, message as @string
Updates sample.tex with lstlisting, subscript/superscript math,
and a \todo note to exercise the new patterns.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Adds automatic indentation support: content inside LaTeX environments
indents on \begin{...} and outdents on \end{...}.
Uses @indent.begin / @indent.end capture names per arborium convention.
First group-willow language to ship indents.scm.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Update: is now included in this PR — indents and outdents using the correct |
|
Sorry Guys, I tagged you because I wasn’t sure whom to tag here. I opened this PR last week, but there haven’t been any updates on it yet. Is this project inactive now, or are updates still expected to come in? |
|
I think Amos is the only one with commit rights, and they might be on holidays or so |
Thanks mate will be waiting for an update before they return is it possible u coould review the PR once Please we could resolve the comments Before Amos Returns and keep PR ready to be merged :) |
Add LaTeX Syntax Highlighting Support to Arborium
Overview
This PR introduces syntax highlighting support for LaTeX (
.tex) files in Arborium.The implementation uses the
[latex-lsp/tree-sitter-latex](https://github.com/latex-lsp/tree-sitter-latex)grammar at commit7e0ecdc02926c7b9b2e0c76003d4fe7b0944f957(MIT licensed).Classification
Group:
group-willowTier: 3
External Scanner:
truescanner.cimplementation.Highlights Query Implementation
The upstream
tree-sitter-latexgrammar does not ship with aqueries/directory, sohighlights.scmwas implemented entirely from scratch.The query covers the following constructs:
Commands
command_name→@functionEnvironments
\begin{...}→@function.builtin\end{...}→@function.macroMath Regions
displayed_equationinline_formulamath_environmentAll mapped to:
@markup.rawSectioning
Supports:
\section\subsectionMapped using:
@namespace@markup.headingLabels & References
curly_group_label→@labelCitations
curly_group_text_list→@stringFile Inclusion
Covers:
\usepackage\inputMapped to:
@keyword.storage.type@keyword.control.importText Formatting
\textbf→@markup.bold\textit/\emph→@markup.italicAdditional Coverage
@commentGrammar Compatibility Notes
Field names were verified directly against the grammar’s
node-types.json.Some references from Helix queries required updates due to renamed fields in the upstream grammar:
curly_group_text→curly_group_labelpath:→paths:inbibtex_includeDemo & Verification
Tested locally using:
Highlighting renders correctly across multiple themes, including:
The following syntax categories were visually verified:
Tests
Files Added