From: Yuan Fu <casouri@gmail.com>
To: Eshel Yaron <me@eshelyaron.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
Vincenzo Pupillo <v.pupillo@gmail.com>,
Emacs Devel <emacs-devel@gnu.org>,
Stefan Kangas <stefankangas@gmail.com>,
Stefan Monnier <monnier@iro.umontreal.ca>,
Dmitry Gutov <dmitry@gutov.dev>
Subject: Re: Tree-sitter central configuration variable
Date: Fri, 29 Nov 2024 00:42:34 -0800 [thread overview]
Message-ID: <94819650-70B5-4BCA-83A4-055B75929A24@gmail.com> (raw)
In-Reply-To: <m1bjxypl78.fsf@macbookpro.home>
> On Nov 28, 2024, at 11:12 PM, Eshel Yaron <me@eshelyaron.com> wrote:
>
> Hi,
>
> Yuan Fu <casouri@gmail.com> writes:
>
>> Actually, I want to expand this to something that allows users to
>> configure tree-sitter modes and toggle on/off tree-sitter features.
>>
> [...]
>>
>> What do you guys think about something like this:
>>
>> (setq treesit-global-configuration
>> '((c-ts-mode
>> ;; Set treesit-font-lock-level to 4
>> (font-lock-level . 4)
> [...]
>> )))
>>
>
> FWIW, I think tree-sitter should be treated as an implementation detail,
> not a user-facing concept. Tree-sitter empowers major mode developers,
> but users shouldn't have to know or care about tree-sitter to benefit
> from it. So a TS-specific configuration user option is not the best
> approach IMO. (For the same reason, I'm not a big fan of the "powered
> by tree-sitter" that we have today in the docstring of various modes.)
I principle, I agree, and that’s what we’ve been doing: we expose tree-sitter as a mechanism for major modes to build on. However, the reality is, something like this just aren’t going to be transparent—users know it’s powered by tree-sitter, they’ll need to have tree-sitter knowledge for non-trivial customizations (eg, add a font-lock rule or indent rule), and the major mode is tied-in with tree-sitter, implementing the major mode with another parser library would require creating a new major mode.
Once you accept that these modes are tied with tree-sitter, a TS-specific configuration starts to seem pretty reasonable. Also, think of the advantage of using a single set of configuration: no need to read the manual and learn the variables etc for each individual major modes; as long as the mode uses tree-sitter features, you learn the configuration framework once and use it on every mode.
> Instead, when it comes to settings that apply across major modes, I
> think we should focus on knobs that make sense whether or not a mode is
> TS-based, and have the TS-based modes respect such universal settings.
Perhaps you mean something that configures things like font-lock, imenu, etc? (I can’t really think of a third example). That’s a bit ambitious, the return is unclear to me, and gods bless whoever wants to fight through emacs-devel for it :-) OTOH, a tree-sitter configuration variable is pretty concrete, I know people want it, and more or less noncontroversial (I hope).
Yuan
next prev parent reply other threads:[~2024-11-29 8:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 10:30 Define treesit-font-lock-level as buffer local Vincenzo Pupillo
2024-11-07 11:03 ` Eli Zaretskii
2024-11-07 11:08 ` Vincenzo Pupillo
2024-11-09 8:36 ` Yuan Fu
2024-11-09 8:54 ` Eli Zaretskii
2024-11-10 8:04 ` Yuan Fu
2024-11-23 12:20 ` Eli Zaretskii
2024-11-29 5:49 ` Tree-sitter central configuration variable Yuan Fu
2024-11-29 7:12 ` Eshel Yaron
2024-11-29 8:42 ` Yuan Fu [this message]
2024-11-29 8:04 ` Eli Zaretskii
2024-11-29 9:07 ` Yuan Fu
2024-11-29 12:02 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=94819650-70B5-4BCA-83A4-055B75929A24@gmail.com \
--to=casouri@gmail.com \
--cc=dmitry@gutov.dev \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=me@eshelyaron.com \
--cc=monnier@iro.umontreal.ca \
--cc=stefankangas@gmail.com \
--cc=v.pupillo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).