emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Disable tree-sitter font-locking for smaller ranges


From: Yuan Fu
Subject: Re: Disable tree-sitter font-locking for smaller ranges
Date: Mon, 17 Oct 2022 17:20:02 -0700


> On Oct 17, 2022, at 4:02 AM, Theodor Thornhill <theo@thornhill.no> wrote:
> 
>>> BTW, if you have time and energy, could you look into separating the
>>> queries into roughly three levels: minimum, moderate, and full
>>> fontification, and mark each with the new :feature flag? Or even
>>> better, separate them into different features (as suggested in the
>>> docstring of treesit-font-lock-feature-list).
>>> 
>> 
>> I will do that promptly and attach patches for ts-mode and js-mode to
>> this thread.
>> 
>> Theo
> 
> 
> See attached patch :-)

Thanks! I think you have a bit of misunderstanding of the :feature flag. You 
should only need to change

(defvar xxx-font-lock-settings
  (treesit-font-lock-rules
   :language 'xxx
   '(1111111111111
     2222222222222
     3333333333333)))

to

(defvar xxx-font-lock-settings
  (treesit-font-lock-rules
   :language 'xxx
   :feature 'minimum
   '(1111111111111)
   :language 'xxx
   :feature 'moderate
   '(2222222222222)
   :language 'xxx
   :feature 'full
   '(3333333333333)))

Ie, no need to create separate variables. And you should set 
treesit-font-lock-feature-list to

(setq treesit-font-lock-feature-list
      '((minimum) (moderate) (full)))

Yuan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]