emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter api


From: Theodor Thornhill
Subject: Re: Tree-sitter api
Date: Sat, 07 Aug 2021 20:40:34 +0200

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> We should have a user option to control tree-sitter on major mode
>> level. Maybe an alist where each car is a major node symbol and each cdr is
>> a Boolean value toggling tree-sitter for that node.
>
> The more traditional approach is to use a buffer-local var set by the
> major mode or set via (add-hook '<MODE>-hook ...).
>
>> As for indentation, we could provide some infrastructure like we do for
>> font-locking, or we can just let major modes implement their indent function
>> with tree-sitter api.
>
> We should definitely provide the infrastructure (even if it's fairly
> simple) so that major modes only have to provide some rules.
>

Yeah, though that quickly becomes not so simple, considering that
different languages have their own idiosyncrasies with indentation. C#,
for instance, is a rats nest of particularities.  And this is not
considering variations of style guides etc.  It would be nice to get an
api similar to what CC mode has.  Font locking is an easier problem,
since it's just "fontify from node-start to node-end".

I'm not sure how to best provide this api, but I've worked a lot with CC
mode and the new tree-sitter-indent [1].  It quickly gets confusing and
reminds me of `display-buffer`.  Providing both a
`tree-sitter-indent-engine` mode as well as the low level api for major
mode authors would be nice as well.

Providing something too simple would just make people not use it, since
the weirder cases won't be covered.

--
Theo

[1]: https://codeberg.org/FelipeLema/tree-sitter-indent.el



reply via email to

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