Xonsh grammar for TreeSitter
A tree-sitter grammar for xonsh, the Python-powered shell.
Overview
Xonsh extends Python 3 with shell-like syntax for subprocess execution. This grammar extends tree-sitter-python with xonsh-specific constructs.
[!IMPORTANT]
- This should be treated as experimental beta-stage software. The output tree layout would change.
- Some limitations are forced by the fact that tree-sitter is context-free while some xonsh constructs are resolvable only at runtime.
Installation
Building from source
git clone https://github.com/FoamScience/tree-sitter-xonsh
cd tree-sitter-xonsh
npm install
tree-sitter generate
tree-sitter parse <your_file>.xsh
Known Limitations
- Unknown commands parsed as Python instead of a bare subprocess command.
- Workaround: Use explicit subprocess syntax:
$[mycommand]instead of justmycommand - This is an effect of scanner-based approaches, for context-bound xonsh subprocesses.
- Workaround: Use explicit subprocess syntax:
Architecture
This grammar extends tree-sitter-python. Key components:
- grammar.js: Defines xonsh-specific rules and overrides Python rules where needed
- scanner.c: External scanner for:
- Bare subprocess detection (heuristic-based)
@symbol usage disambiguation (decorator vs@(...)vs@.attrvs@modifier)- Subprocess modifier handling (
@json,@unthread, etc.) &&/||vs&disambiguation- Brace expansion vs literal detection
- Python's indent/dedent handling (inherited)
- String delimiter handling (inherited)
- queries/highlights.scm provides syntax highlighting queries for Neovim.
- The TreeSitter CLI can read those, but will render the highlighting differently.
Currently the scanner may look-ahead a whole line, which can affect performance.
License
MIT
Metadata
Release files for tree-sitter-xonsh 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tree_sitter_xonsh-0.2.3.tar.gz | 370.8 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| tree_sitter_xonsh-0.2.3-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details |
| tree_sitter_xonsh-0.2.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| tree_sitter_xonsh-0.2.3-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 | Details |
| tree_sitter_xonsh-0.2.3-cp38-abi3-macosx_11_0_arm64.whl | CPython 3.8 | abi3 | macOS 11.0+ ARM64 | Details |
| tree_sitter_xonsh-0.2.3-cp38-abi3-macosx_10_9_x86_64.whl | CPython 3.8 | abi3 | macOS 10.9+ x86-64 | Details |
Total release size: 1.2 MB
Release files / tree_sitter_xonsh-0.2.3.tar.gz
| Download URL | tree_sitter_xonsh-0.2.3.tar.gz |
|---|---|
| Size | 370.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3179f642761ac709e4ac641c28b869e69b5e7ef855dd5779dcf135f2b717ec51
|
|
BLAKE2b-256 checksum How to use checksums |
b0a71a08999033c4a9e6d6070026938e09eba44493869c71d70d0a71dee32b09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency logRelease files / tree_sitter_xonsh-0.2.3-cp38-abi3-win_amd64.whl
| Download URL | tree_sitter_xonsh-0.2.3-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 142.3 kB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4061e867a6f25d3121e459cdfd6d30dabdce2c6210759acd8e9889cf22aa9c40
|
|
BLAKE2b-256 checksum How to use checksums |
62a757ff4fd56953fd69e319470f293d09104dfb492d4d3851fadae0f5ebc414
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency logRelease files / tree_sitter_xonsh-0.2.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | tree_sitter_xonsh-0.2.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 192.0 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a6b876a31c1b6b5777b0e01d280aef333e4433f80a1b3718df49ae2c5f454f00
|
|
BLAKE2b-256 checksum How to use checksums |
844f6117d47fe920247cd88d043f412e88f8e73d4c89016052415d95d21d4e70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency logRelease files / tree_sitter_xonsh-0.2.3-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | tree_sitter_xonsh-0.2.3-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 180.6 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
001c3a7637d7984395cd2628efb1128ab2da32f3c929a0b91ea0eff64c9cd78d
|
|
BLAKE2b-256 checksum How to use checksums |
09029f1b7d1fd731d4241d432304f64e6c49495f6a6797b268f115f815192470
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency logRelease files / tree_sitter_xonsh-0.2.3-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | tree_sitter_xonsh-0.2.3-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 151.4 kB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c542edf6a9d0f9e047acd20c2370835db1acc4351ee4f1128a8e4368ea4e8a12
|
|
BLAKE2b-256 checksum How to use checksums |
fffa46b3e07b766f34b07411c47ac7be5a079ef0f5a9c090302a8326a752294e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency logRelease files / tree_sitter_xonsh-0.2.3-cp38-abi3-macosx_10_9_x86_64.whl
| Download URL | tree_sitter_xonsh-0.2.3-cp38-abi3-macosx_10_9_x86_64.whl |
|---|---|
| Size | 138.9 kB |
| Tags | CPython 3.8 abi3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
bcfddac4e4ccf54661008817533440bc7981e0b5f34c58c04d8946387c4b250a
|
|
BLAKE2b-256 checksum How to use checksums |
ac01847472d13aed1809bf7835b0b34f7a697df2cebc4fa9082653620460dd5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency log