docs(tree-sitter): document treesit-font-lock-level

Close: #8487
This commit is contained in:
Henrik Lissner
2025-09-11 23:35:17 -04:00
parent 05137e14a5
commit d6cdbb4d22

View File

@@ -138,28 +138,24 @@ outer}-text-objects-map~:
#+end_src
** Configuring Tree sitter highlighting
Highlighting is controlled by the variable =+tree-sitter-hl-enabled-modes=
This list allows you to whitelist, blacklist, fully enable or fully disable
tree-sitter highlighting for all major modes
Doom increases ~treesit-font-lock-level~ from its upstream default of ~3~ to ~4~ for
maximum syntax highlighting. If this is too busy or slow for you, try reducing
it:
To use highlighting in select modes add major-modes to
~+tree-sitter-hl-enabled-modes~. This disables highlighting in all other modes.
The symbol that should be used is the major mode symbol, *not the package
symbol*.
#+begin_src emacs-lisp
(setq +tree-sitter-hl-enabled-modes '(python-mode go-mode))
#+begin_src elisp
;;; add to $DOOMDIR/config.el
(after! treesit
(setq treesit-font-lock-level 3))
;; Alternatively, to only affect specific major modes:
(after! treesit
(setq treesit-font-lock-level
'((python-ts-mode . 3)
(c-ts-mode . 2)
;; Default to 4 everywhere else
(t . 4))))
#+end_src
If you want to disallow highlighting in certain modes then the car of
~+tree-sitter-hl-enabled-modes~ should be =not=. This enables highlighting in
all modes except the ones disallowed.
#+begin_src emacs-lisp
(setq +tree-sitter-hl-enabled-modes '(not web-mode typescript-tsx-mode))
#+end_src
If ~+tree-sitter-hl-enabled-modes~ is set to ~nil~ or ~t~ it will fully disable
or fully enable highlighting in every tree sitter enabled language respectively.
* Troubleshooting
[[doom-report:][Report an issue?]]