This is an Emacs Lisp binding for tree-sitter, an incremental parsing library. It requires Emacs 25.1 or above, built with dynamic module support.
It aims to be the foundation for a new breed of Emacs packages that understand code structurally. For example:
- Faster, fine-grained code highlighting.
- More flexible code folding.
- Structural editing (like Paredit, or even better) for non-Lisp code.
- More informative indexing for imenu.
The author of tree-sitter articulated its merits a lot better in this Strange Loop talk.
See the installation section in the documentation.
If you want to hack on
emacs-tree-sitter itself, see the next section instead.
Setup for Development
Note: On Windows, use Powershell instead of Bash or cmd.exe.
- Clone this repo with the
- Add 3 of its directories to
- Install cask.
If you want to hack on the high-level features (in Lisp) only:
- Make changes to the
- Add tests to
tree-sitter-tests.eland run them with
If you want to build additional (or all) grammars from source, or work on the core dynamic module, see the next 2 sections.
Building grammars from source
Note: If you are only interested in building the grammar binaries, not the dynamic module, check out tree-sitter-langs.
- Install tree-sitter CLI tool: (Its binary can also be downloaded directly from GitHub.) Note: version 0.20+ cannot be used, as they introduced a breaking change in binary storage location.
# For yarn user yarn global add firstname.lastname@example.org # For npm user npm install -g email@example.com
langs/script/compile. For example:
Working on the dynamic module
- Install the Rust toolchain.
- Continuously rebuild and test on change (requires cargo-watch):
To test against a different version of Emacs, set the environment variable
EMACS=/snap/bin/emacs make test).
- Tree-sitter in Emacs's core: https://github.com/casouri/emacs (the future)
- Binding through C instead of Rust: https://github.com/karlotness/tree-sitter.el (dormant)
For language-specific issues/features, please check out tree-sitter-langs instead.
Show respect and empathy towards others. Both technical empathy and general empathy are highly valued.