Variable: treesit-font-lock-level

treesit-font-lock-level is a customizable variable defined in treesit.el.gz.

Value

3

Documentation

Decoration level to be used by tree-sitter fontifications.

Major modes categorize their fontification features into levels, from 1 which is the absolute minimum, to 4 that yields the maximum fontifications.

Level 1 usually contains only comments and definitions. Level 2 usually adds keywords, strings, data types, etc. Level 3 usually represents full-blown fontifications, including assignments, constants, numbers and literals, etc. Level 4 adds everything else that can be fontified: delimiters, operators, brackets, punctuation, all functions, properties, variables, etc.

The value of this variable can be either a number representing a level, or an alist of (MAJOR-MODE . LEVEL), where MAJOR-MODE is major mode symbols, or t (meaning the default), and LEVEL is the font-lock level for that mode. For example,

    ((c-ts-mode . 3) (c++-ts-mode . 4) (t . 3))

Major mode is checked with derived-mode-p.

In addition to the decoration level, individual features can be turned on/off by calling treesit-font-lock-recompute-features. Changing the decoration level requires calling treesit-font-lock-recompute-features to have an effect, unless done via customize-variable.

To see which syntactical categories are fontified by each level in a particular major mode, examine the buffer-local value of the variable treesit-font-lock-feature-list.

This variable was added, or its default value changed, in Emacs 29.1.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defcustom treesit-font-lock-level 3
  "Decoration level to be used by tree-sitter fontifications.

Major modes categorize their fontification features into levels,
from 1 which is the absolute minimum, to 4 that yields the maximum
fontifications.

Level 1 usually contains only comments and definitions.
Level 2 usually adds keywords, strings, data types, etc.
Level 3 usually represents full-blown fontifications, including
assignments, constants, numbers and literals, etc.
Level 4 adds everything else that can be fontified: delimiters,
operators, brackets, punctuation, all functions, properties,
variables, etc.

The value of this variable can be either a number representing a level,
or an alist of (MAJOR-MODE . LEVEL), where MAJOR-MODE is major mode
symbols, or t (meaning the default), and LEVEL is the font-lock level
for that mode.  For example,

    ((c-ts-mode . 3) (c++-ts-mode . 4) (t . 3))

Major mode is checked with `derived-mode-p'.

In addition to the decoration level, individual features can be
turned on/off by calling `treesit-font-lock-recompute-features'.
Changing the decoration level requires calling
`treesit-font-lock-recompute-features' to have an effect, unless
done via `customize-variable'.

To see which syntactical categories are fontified by each level
in a particular major mode, examine the buffer-local value of the
variable `treesit-font-lock-feature-list'."
  :type 'integer
  :set #'treesit--font-lock-level-setter
  :version "29.1")