/tree-sitter-langs

Language bundle for Emacs's tree-sitter package

Primary LanguageEmacs LispMIT LicenseMIT

tree-sitter-langs

This is a convenient language bundle for the Emacs package tree-sitter. It serves as an interim distribution mechanism, until tree-sitter is widespread enough for language-specific major modes to incorporate its functionalities.

For each supported language, this package provides:

  1. Pre-compiled grammar binaries for 3 major platforms: macOS, Linux and Windows, on x86_64. In the future, tree-sitter-langs may provide tooling for major modes to do this on their own.
  2. An optional highlights.scm file that provides highlighting patterns. This is mainly intended for major modes that are not aware of tree-sitter. A language major mode that wants to use tree-sitter for syntax highlighting should instead provide the query patterns on its own, using the mechanisms defined by tree-sitter-hl.

Building grammars from source

It’s more convenient to work with this repository as a submodule of emacs-tree-sitter. However, if you want to skip that, below are the steps to build grammars from source using only this repository.

Tools and dependencies

  • Install cask.
  • Install npm. (Some grammars depend on another npm-packaged grammar. For example: cpp, typescript.)
  • Install tree-sitter CLI tool (if you don’t use NodeJS, you can download the binary directly from GitHub).
  • Clone this repository and install its dependencies.
git clone https://github.com/ubolonton/tree-sitter-langs
cd tree-sitter-langs
cask install

Building a single grammar

git submodule update --init --checkout -- repos/rust
cask eval "(progn (require 'tree-sitter-langs-build) (tree-sitter-langs-compile 'rust))"

Building the whole grammar bundle

git submodule update --init --checkout
cask eval "(progn (require 'tree-sitter-langs-build) (tree-sitter-langs-create-bundle))"