GNU bug report logs -
#70361
[PATCH] Add font-locking for operators in go-ts-mode.
Previous Next
Reported by: Noah Peart <noah.v.peart <at> gmail.com>
Date: Sat, 13 Apr 2024 05:24:03 UTC
Severity: normal
Tags: patch
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #32 received at 70361 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thankyou, this all makes sense. I do think it would be nice if it was
easier to somehow
add user customizations to the font-locking, especially since it is so easy
to write tree-sitter
font-locking rules.
> We just don’t want a central tree-sitter-font-lock-feature-list that
controls
the feature list of every major mode in a single place.
What would you think of something like a `user` feature that could be
enabled
globally and users could add their mode-specific rules there? Eg.
(defvar my-treesit-font-lock-rules
(treesit-font-lock-rules
:language 'go
:feature 'user
'((identifier))
:language 'typescript
:feature 'user
'((identifier))
;; ...
))
This wouldn't work very well in certain cases where ordering of the rules
was important, however.
On Sun, Apr 14, 2024 at 4:34 PM Yuan Fu <casouri <at> gmail.com> wrote:
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> From: Noah Peart <noah.v.peart <at> gmail.com>
> >> Date: Sat, 13 Apr 2024 00:32:59 -0700
> >> Cc: 70361 <at> debbugs.gnu.org
> >>
> >> On a somewhat related note, I was wondering why the treesit modes in
> emacs
> >> define their `treesit-font-lock-feature-list`s in the mode definitions.
> >>
> >> Wouldn't it be more user-friendly to `defvar` the feature list?
> >
> > AFAIR, we do that in the mode's settings because the translation of
> > general categories into mode-specific settings is not easy, and
> > because we want users to control that via the fontification level, not
> > below that.
> >
> > What problems do you see with the current approach that would require
> > more fine-grained user control? And why do you think a defvar is the
> > proper way of providing such control?
>
> Replying to Noah, I don’t think there’s anything wrong for a major mode
> to define a xxx-mode-feature-list and assign it to
> treesit-font-lock-feature-list when setting up the major mode. We just
> don’t want a central tree-sitter-font-lock-feature-list that controls
> the feature list of every major mode in a single place.
>
> But again, even if a xxx-mode defines xxx-mode-feature-list, it would be
> a bit of a hassle to take out or remove a single feature from the list,
> since it’s a list of list. (You can just setq the whole list, but then
> you need to keep it in sync with upstream.) It’s probably easier to call
> treesit-font-lock-recompute-features in the major mode hook anyway.
>
> Yuan
>
[Message part 2 (text/html, inline)]
This bug report was last modified 1 year and 33 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.