Tree-sitter in Emacs
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-sitteritself, see the next section instead.
If you want to hack on the high-level features (in Lisp) only: - Make changes to the
.elfiles. - 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.
yarn global add tree-sitter-cli
npm install -g tree-sitter-cli ```
.\bin\ensure-lang rust ```
You can modify
tree-sitter-langs-reposif the language you need is not declared there.
clang, to generate the raw Rust binding for
bash # macOS/Linux make build
powershell # Windows .\bin\build
bash # macOS/Linux make test
powershell # Windows .\bin\test
bash # macOS/Linux make watch
powershell # Windows .\bin\test watch
To test against a different version of Emacs, set the environment variable
EMACS=/snap/bin/emacs make test).
Targeting lib authors: - Write a guide on using the tree-sitter APIs.
Targeting end users: - Pick a language, make a "killer" minor mode that extends its major mode in multiple ways. - Make minor modes for most common languages. - Extract common patterns from the language minor modes into helper language-diagnostic minor modes. - Get a language major mode to use tree-sitter for optional features.
Binding through C instead of Rust: https://github.com/karlotness/tree-sitter.el
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.