Installation
For most users, you'll want to install this as a text editor extension.
Each editor has its own installation instructions to follow.
If you're looking to use tree-sitter-fastq as a library through Tree-sitter's supported language bindings, see Library installation, below.
Tree-sitter parsers are dynamic libraries compiled from C code, so you'll need a C compiler available on your system. Common choices include:
The parser is generated with tree-sitter version 0.26, which has a minimum parser application binary interface (ABI) of 13 and max parser ABI of 15.
Editor extensions
The following editors are supported:
Tree-sitter parsers are supported by the following editors, but installation is not supported at this time:
Helix
We need to add a fastq language and grammar to Helix's languages.toml configuration file.
[[language]] # (1)!
name = "fastq"
scope = "source.fastq"
file-types = ["fastq", "fq"]
roots = []
[[grammar]] # (2)!
name = "fastq"
source = { git = "https://gitlab.com/jrhawley/tree-sitter-fastq", rev = "..." } # (3)!
- This table adds a language named
fastqto Helix. - This table adds a grammar for the
fastqlanguage to Helix. - See Changelog or the git repository for the relevant revision ID.
[[language]] # (1)!
name = "fastq"
scope = "source.fastq"
file-types = ["fastq", "fq"]
roots = []
[[grammar]] # (2)!
name = "fastq"
source = { git = "https://gitlab.com/jrhawley/tree-sitter-fastq", rev = "..." } # (3)!
- This table adds a language named
fastqto Helix. - This table adds a grammar for the
fastqlanguage to Helix. - See Changelog or the git repository for the relevant revision ID.
[[language]] # (1)!
name = "fastq"
scope = "source.fastq"
file-types = ["fastq", "fq"]
roots = []
[[grammar]] # (2)!
name = "fastq"
source = { git = "https://gitlab.com/jrhawley/tree-sitter-fastq", rev = "..." } # (3)!
- This table adds a language named
fastqto Helix. - This table adds a grammar for the
fastqlanguage to Helix. - See Changelog or the git repository for the relevant revision ID.
Then fetch and build the grammars to install it into Helix's runtime directory.
hx --grammar fetch
hx --grammar build
This will store the git repository in ~/.config/helix/runtime/grammars/sources/fastq/ and compile the shared object ~/.config/helix/grammars/fastq.so.
Finally, verify that the parser is recognized by Helix:
hx --health fastq
Configured language servers: None
Configured debug adapter: None
Configured formatter: None
Tree-sitter parser: ✓ # (1)!
Highlight queries: ✓ # (2)!
Textobject queries: ✘
Indent queries: ✘
- A check mark here indicates that
~/.config/helix/runtime/grammars/fastq.sois available. -
A check mark here indicates that
~/.config/helix/runtime/queries/fastq/highlights.scmis available. If this is not checked, you may have to install the queries manually. This can be done by linking from the~/.config/helix/runtime/grammars/sources/directory.ln -s ~/.config/helix/grammars/sources/fastq/queries ~/.config/helix/queries/fastq
This will store the git repository in ~/.config/helix/runtime/grammars/sources/fastq/ and compile the shared object ~/.config/helix/grammars/fastq.so.
Finally, verify that the parser is recognized by Helix:
hx --health fastq
Configured language servers: None
Configured debug adapter: None
Configured formatter: None
Tree-sitter parser: ✓ # (1)!
Highlight queries: ✓ # (2)!
Textobject queries: ✘
Indent queries: ✘
- A check mark here indicates that
~/.config/helix/runtime/grammars/fastq.sois available. -
A check mark here indicates that
~/.config/helix/runtime/queries/fastq/highlights.scmis available. If this is not checked, you may have to install the queries manually. This can be done by linking from the~/.config/helix/runtime/grammars/sources/directory.ln -s ~/.config/helix/grammars/sources/fastq/queries ~/.config/helix/queries/fastq
This will store the git repository in %AppData%\helix\runtime\grammars\sources\fastq\ and compile the shared object %AppData%\helix\grammars\fastq.dll.
Finally, verify that the parser is recognized by Helix:
hx --health fastq
Configured language servers: None
Configured debug adapter: None
Configured formatter: None
Tree-sitter parser: ✓ # (1)!
Highlight queries: ✓ # (2)!
Textobject queries: ✘
Indent queries: ✘
- A check mark here indicates that
%AppData\helix\runtime\grammars\fastq.dllis available. -
A check mark here indicates that
%AppData%\helix\runtime\queries\fastq\highlights.scmis available. If this is not checked, you may have to install the queries manually. This can be done by linking from the%AppData%\helix\runtime\grammars\sources\directory.New-Item -Path %AppData%\helix\queries\fastq -ItemType SymbolicLink -Value %AppData\helix\grammars\sources\fastq\queries
See Helix's language configuration docs for additional details.
Note
Helix implements a hard-coded 500 ms timeout for creating and updating syntax trees (see this snippet).
If a FASTQ file is large enough, parsing the file and creating a syntax tree may take be cancelled due to running over time.
This will prevent syntax highlighting and other Tree-sitter-driven features from working.
You'll still be able to view and edit the file, but you won't get additional benefits from tree-sitter-fastq.
Zed / Gram
Zed and Gram both support the tree-sitter-fastq parser through the gram-zed-fastx extension.
Open the "Extensions" page in Zed / Gram, click "Install from URL" and provide https://gitlab.com/jrhawley/gram-zed-fastx.
This will compile the extension in the background.
A Rust toolchain must be installed on your system to compile this parser into a WebAssembly object, which Zed and Gram use to package their extensions.
See Rust's documentation for directions how to install a Rust toolchain.
Ensure the wasm32-wasip2 target is available in your toolchain by running:
rustup toolchain add wasm32-wasip2
The extension will be listed on the "Extensions" page if successfully installed.
Library installation
Tree-sitter has multiple official language bindings that allow Tree-sitter parsers to be used from other programming languages.
Below are some examples of how to load tree-sitter-fastq parsers in those languages.
Rust
Add tree-sitter and tree-sitter-fastq to your project's Cargo.toml manifest.
[dependencies]
tree-sitter = "0.26.8"
tree-sitter-fastq = { git = "https://gitlab.com/jrhawley/tree-sitter-fastq" }
Then, in your code you can add the parser.
use tree_sitter::{InputEdit, Language, Parser, Point};
let mut parser = Parser::new();
parser.set_language(&tree_sitter_fastq::LANGUAGE.into()).expect("Error loading FASTQ grammar");
let source_code = r#">chr1
ACTAGTAGTCTA"#;
let mut tree = parser.parse(source_code, None).unwrap();
let root_node = tree.root_node();
assert_eq!(root_node.kind(), "source_file");
assert_eq!(root_node.start_position().column, 0);
assert_eq!(root_node.end_position().column, 12);
See tree-sitter for details.
Warning
Change this.
Python
Install the tree-sitter package from PyPI and tree-sitter-fastq from the repository.
pip install tree-sitter
pip install git+https://gitlab.com/jrhawley/tree-sitter-fastq.git
Install the tree_sitter package from Conda Forge and tree-sitter-fastq from the repository.
conda install -c conda-forge tree_sitter
python -m pip install git+https://gitlab.com/jrhawley/tree-sitter-fastq.git
Then, in your code you can add the parser.
import tree_sitter_fastq as tsfastq
from tree_sitter import Language, Parser
FQ_LANGUAGE = Language(tsfastq.language())
parser = Parser(FQ_LANGUAGE)
source_code = """>chr1
ACTAGTAGTCTA"""
tree = parser.parse(bytes(source_code, "utf8"))
root_node = tree.root_node
assert root_node.type == "source_file"
assert root_node.start_point == (0, 0)
assert root_node.end_point == (1, 12)
See py-tree-sitter for details.
Warning
Change this.
-
Tree-sitter parsers are not natively supported by VSCode. Support is provided through the tree-sitter-vscode extension. This extension is not available for forks of VSCode, such as VSCodium. But the Syntax Highlighter extension is, which may be a suitable alternative. Additionally, extensions must be created to provide additional languages to the editor, which is not planned at this time. ↩
-
Tree-sitter parsers are not natively supported by Sublime Text, but support is provided by the TreeSitter package. ↩
-
Neovim's support for Tree-sitter parser is still experimental. Its support was provided through the nvim-treesitter project, which was archived on April 3, 2026, potentially due to abuse the project maintainer received. There are forks of the repository, such as this one. ↩
-
Lapce supports Tree-sitter parsers natively, but the parsers must be compiled manually, separated from the editor. Moreover, languages must be manually defined in the Lapce codebase prior to compilation and cannot be dynamically defined by the user. Contributing to Lapce's code isn't planned at this time. ↩
-
Emacs v29 and above support Tree-sitter parsers natively. However, features like syntax highlighting and major-mode activation upon opening a FASTQ file must be manually configured with font-locks separately from the parser. The Tree-sitter API changes greatly between Emacs versions 29, 30, and 31, and testing against each API is not planned at this time. ↩