emacs-devel
[Top][All Lists]
Advanced

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

Tree-sitter api (Was: Re: How to add pseudo vector types)


From: Fu Yuan
Subject: Tree-sitter api (Was: Re: How to add pseudo vector types)
Date: Sat, 7 Aug 2021 00:31:36 -0500

> 在 2021年8月6日,上午1:37,Eli Zaretskii <eliz@gnu.org> 写道:
> 
> 
>> 
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Thu, 5 Aug 2021 23:22:17 -0400
>> Cc: cpitclaudel@gmail.com, stephen_leake@stephe-leake.org,
>> Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
>> 
>> I’ve added bindings for set_ranges and pushed the latest code to 
>> https://github.com/casouri/emacs/tree/ts
>> 
>> As for now, I’ve created bindings for most of the functions I want to 
>> expose. Next I’ll probably write some more tests (in addition to responding 
>> reviews and comments).
> 
> Thanks.
> 
> We should probably start thinking how to integrate TS-related
> functionalities into Emacs in general.  E.g., should there be an
> option to activate it? should this option be per major mode? something
> else?

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.

We also need tree-sitter-maximum-buffer-size, so that buffer larger than this 
size won’t enable tree-sitter. (And we need to make sure we never use 
tree-sitter on buffers larger than 4GB because tree-sitter uses unint32.)

And we can provide a function free-sitter-should-activate-p that computes if we 
should enable tree-sitter in the current buffer by variables mentioned above, 
that can be used by major-modes when setting up.

I’m also thinking about having a tree-sitter-defaults that’s analogous to 
font-lock-defaults, that is set by each major node and used to generate 
tree-sitter-font-lock-settings.

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.

Yuan


reply via email to

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