emacs-devel
[Top][All Lists]
Advanced

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

Re: Average-user-facing interface for tree-sitter


From: Yuan Fu
Subject: Re: Average-user-facing interface for tree-sitter
Date: Fri, 28 Oct 2022 01:02:25 -0700


> On Oct 27, 2022, at 8:29 AM, Dmitry Gutov <dgutov@yandex.ru> wrote:
> 
> On 27.10.2022 18:21, Stefan Monnier wrote:
>>> Yes, there are indeed some non-trivial tradeoffs here.
>> Reading some old bug report made me realize another problem: what if
>> a derived-mode of js-mode, A-mode expects cc-mode stuff to be setup by
>> js-mode, but js-mode doesn’t setup cc-mode because it’s using tree-sitter?
> 
> js2-mode also derives from js-mode, and I think it might be rather surprised 
> to encounter TreeSitter integration in its buffers.
> 
> Not sure how much it's going to conflict in practice, but using two different 
> parsers at the same time sounds problematic.

Yes, I think there are roughly two types of derived modes, one that only add 
minor change or even personal settings to the parent mode, like python-mode w/ 
my-python-mode; the other derives from a mode that is essentially another 
language, like ts-mode w/ js-mode, or json-mode with js-mode.

The first kind probably wants parent mode’s tree-sitter setup (if it is enabled 
by the user), but the second one probably don’t, and they might need 
non-tree-sitter setup made by the parent mode.

I think derived major modes should have a way to opt-in to parent mode’s 
tree-sitter setups. It doesn’t need to be a user-facing option, but something a 
major mode configures upon definition.

Yuan


reply via email to

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