Skip to content

Commit d01853e

Browse files
committed
doc: Clarify tree-sitter-hl-mode vs. tree-sitter-langs
1 parent 81a3433 commit d01853e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doc/emacs-tree-sitter.org

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ The variable ~tree-sitter-load-path~ is a list of directories that the function
167167
(tree-sitter-require 'rust)
168168
#+end_src
169169

170+
*** tree-sitter-langs
170171
The package ~tree-sitter-langs~ is a language bundle that contains shared libraries for some languages (as well as syntax highlighting queries). When it is loaded, its shared libraries are prioritized over the CLI's directory.
171172

172173
Syntax-aware language-agnostic mechanisms are meant to be defined by ~tree-sitter-mode~ and its dependent minor modes. They determine the language object to use by consulting the variable ~tree-sitter-major-mode-language-alist~. This list is empty by default, and gets populated by ~tree-sitter-langs~ when it is loaded, and by language major modes that are ~tree-sitter~-aware.
@@ -191,7 +192,7 @@ If, for some reason, you cannot update, the older binaries can be downloaded fro
191192
:EXPORT_TITLE: Syntax Highlighting
192193
:END:
193194

194-
Syntax highlighting is provided by the minor mode ~tree-sitter-hl-mode~. It overrides the regex-based highlighting provided by ~font-lock-mode~, using the syntax tree provided by ~tree-sitter-mode~. It is based on [[* Queries][*tree queries*]], a system for pattern-matching on Tree-sitter's syntax trees.
195+
The minor mode ~tree-sitter-hl-mode~ provides the framework for syntax highlighting. It overrides the regex-based highlighting provided by ~font-lock-mode~, using the syntax tree provided by ~tree-sitter-mode~. It is based on [[* Queries][*tree queries*]], a system for pattern-matching on Tree-sitter's syntax trees.
195196

196197
It can be toggled in a buffer by the command ~tree-sitter-hl-mode~, or enabled through major mode hooks:
197198
#+begin_src emacs-lisp
@@ -203,6 +204,11 @@ To enable it whenever possible (assuming the language major modes were already i
203204
(global-tree-sitter-mode)
204205
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
205206
#+end_src
207+
208+
{{% notice info %}}
209+
Like ~font-lock-mode~, ~tree-sitter-hl-mode~ provides only the mechanisms. The actual highlighting rules are provided by language-specific packages, or a language bundle like ~tree-sitter-langs~.
210+
{{% /notice %}}
211+
206212
*** tree-sitter-langs
207213
The package ~tree-sitter-langs~ provides syntax highlighting [[https://github.com/emacs-tree-sitter/tree-sitter-langs/tree/master/queries][queries]] for some languages.
208214

0 commit comments

Comments
 (0)