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:
tree-sitter-langs
may provide tooling for major modes to do this on their own.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.tree-sitter
, such as code folding, evil text objects… As with highlighting patterns, major modes that are directly aware of tree-sitter
should provide the query patterns on their own.Highlighting query patterns for a language are in the file queries/<lang>/highlights.scm
. Most of them are intentionally different from those from upstream repositories, which are more geared towards GitHub’s use cases. We try to be more consistent with Emacs’s existing conventions. (For some languages, this is WIP, so their patterns may look similar to upstream’s.)
In general, try to follow what the docstrings of tree-sitter-hl-face:
faces say. Most importantly:
@function
vs. @function.call
.@method
vs. @method.call
.@type.parameter
vs. @type.argument
.@variable
and @variable.parameter
should be applied only to declarations/definitions/bindings/mutations (writes), not usage (reads).@function.macro
, @type.builtin
, @variable.special
.Some languages are associated with multiple major modes. Mode-specific highlighting patterns are provided by the files queries/<lang>/highlights.<major-mode>.scm
. These are combined with the base highlighting patterns in queries/<lang>/highlights.scm
, but have higher precedence.
Note: If you also plan to work on elisp-tree-sitter, it might be more convenient to work with this repository as a submodule.
To build a specific language’s grammar, run script/compile
. (See the list of registered languages in repos/.) For example:
To build all registered languages, and creating the bundle:
# git submodule add -b <branch> -- <git-url> repos/<lang> git submodule add -b master -- https://github.com/tree-sitter/tree-sitter-rust repos/rust
update = none ignore = dirty
script/compile rust script/test rust
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4