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-fasta as a library through Tree-sitter's supported language bindings, see Library installation.
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 fasta language and grammar to Helix's languages.toml configuration file.
[[language]] # (1)!
name = "fasta"
scope = "source.fasta"
file-types = ["fasta", "ffn", "fa", "fas", "faa", "frn", "mpfa", "fna"]
roots = []
[[grammar]] # (2)!
name = "fasta"
source = { git = "https://gitlab.com/jrhawley/tree-sitter-fasta", rev = "0110bfa32c90f12a82fe14233dbb482c4d1a4a8c" } # (3)!
- This table adds a language named
fastato Helix. - This table adds a grammar for the
fastalanguage to Helix. - See Changelog or the git repository for the relevant revision ID.
[[language]] # (1)!
name = "fasta"
scope = "source.fasta"
file-types = ["fasta", "ffn", "fa", "fas", "faa", "frn", "mpfa", "fna"]
roots = []
[[grammar]] # (2)!
name = "fasta"
source = { git = "https://gitlab.com/jrhawley/tree-sitter-fasta", rev = "0110bfa32c90f12a82fe14233dbb482c4d1a4a8c" } # (3)!
- This table adds a language named
fastato Helix. - This table adds a grammar for the
fastalanguage to Helix. - See Changelog or the git repository for the relevant revision ID.
[[language]] # (1)!
name = "fasta"
scope = "source.fasta"
file-types = ["fasta", "ffn", "fa", "fas", "faa", "frn", "mpfa", "fna"]
roots = []
[[grammar]] # (2)!
name = "fasta"
source = { git = "https://gitlab.com/jrhawley/tree-sitter-fasta", rev = "0110bfa32c90f12a82fe14233dbb482c4d1a4a8c" } # (3)!
- This table adds a language named
fastato Helix. - This table adds a grammar for the
fastalanguage 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/fasta/ and compile the shared object ~/.config/helix/grammars/fasta.so.
Finally, verify that the parser is recognized by Helix:
hx --health fasta
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/fasta.sois available. -
A check mark here indicates that
~/.config/helix/runtime/queries/fasta/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/fasta/queries ~/.config/helix/queries/fasta
This will store the git repository in ~/.config/helix/runtime/grammars/sources/fasta/ and compile the shared object ~/.config/helix/grammars/fasta.so.
Finally, verify that the parser is recognized by Helix:
hx --health fasta
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/fasta.sois available. -
A check mark here indicates that
~/.config/helix/runtime/queries/fasta/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/fasta/queries ~/.config/helix/queries/fasta
This will store the git repository in %AppData%\helix\runtime\grammars\sources\fasta\ and compile the shared object %AppData%\helix\grammars\fasta.dll.
Finally, verify that the parser is recognized by Helix:
hx --health fasta
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\fasta.dllis available. -
A check mark here indicates that
%AppData%\helix\runtime\queries\fasta\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\fasta -ItemType SymbolicLink -Value %AppData\helix\grammars\sources\fasta\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 FASTA 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-fasta.
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-fasta parsers in those languages.
Rust
Add tree-sitter and tree-sitter-fasta to your project's Cargo.toml manifest.
[dependencies]
tree-sitter = "0.26.8"
tree-sitter-fasta = { git = "https://gitlab.com/jrhawley/tree-sitter-fasta" }
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_fasta::LANGUAGE.into()).expect("Error loading FASTA 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.
Python
Install the tree-sitter package from PyPI and tree-sitter-fasta from the repository.
pip install tree-sitter
pip install git+https://gitlab.com/jrhawley/tree-sitter-fasta.git
Install the tree_sitter package from Conda Forge and tree-sitter-fasta from the repository.
conda install -c conda-forge tree_sitter
python -m pip install git+https://gitlab.com/jrhawley/tree-sitter-fasta.git
Then, in your code you can add the parser.
import tree_sitter_fasta as tsfasta
from tree_sitter import Language, Parser
FA_LANGUAGE = Language(tsfasta.language())
parser = Parser(FA_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.
-
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. ↩
-
Grammars for a language must be declared in an extension for the editor, as per Zed's documentation. No such extension is planned at this time. ↩
-
Lapce supports Tree-sitter parsers natively, but the parsers must be compiled manually, separated from the editor. Compatibility with Lapce hasn't been tested at this time. ↩
-
Emacs v29 and above support Tree-sitter parsers natively. However, features like syntax highlighting and major-mode activation upon opening a FASTA 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. ↩