feat(latex): add LaTeX language support#202
Open
NandishNaik01 wants to merge 6 commits into
Open
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>
Author
|
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>
Author
|
Update: is now included in this PR — indents and outdents using the correct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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