emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter api


From: Yuan Fu
Subject: Re: Tree-sitter api
Date: Fri, 3 Sep 2021 23:38:43 -0700


> On Sep 3, 2021, at 12:16 PM, Theodor Thornhill <theo@thornhill.no> wrote:
> 
> Yuan Fu <casouri@gmail.com> writes:
> 
> Hi!
> 
>> 
>> Thanks, Stefan :-) I applied your patch and fixed the two FIXME’s.
>> 
> 
> If I were to start experimenting with this in csharp-mode, how would I
> start?  

You can find the code at https://github.com/casouri/emacs.git, in “ts” branch. 
As long as tree-sitter library is in the standard path, Emacs will compile with 
tree-sitter support. Language definitions are loaded by dynamic modules. You 
can find a script for building dynamic modules at 
https://github.com/casouri/tree-sitter-module, you can even just grab the 
release file. I need to add C# to the list of languages in the build script.

Now you have Emacs and dynamic modules. You can also build the manual, I just 
wrote the manual entries for tree-sitter API, its a draft but should explain 
everything the Emacs tree-sitter API provides. To build the manual you want to 
go to /doc/listpref, and do “make -e HTML_OPTS="--html” elisp.html”, that 
should compile a manual in elisp.html directory. The tree-sitter part is in “37 
Parsing Program Source”. I attached a zip file containing the compiled manual 
on my machine, you can just use that.

I haven’t written manual for font-lock and indent support, because they are not 
settled yet. To see how they work, you can read:

1. the source of ts-c-mode in /lisp/tree-sitter.el,
2. doctoring of font-lock-tree-sitter-defaults and 
font-lock-tree-sitter-settings, and 
3. docstring of tree-sitter-simple-indent-rules

BTW, tree-sitter-inspect-mode could be helpful.

> Right now we support the rust version on melpa, but I'd rather
> move to this core-supported package.  How far are we from including this
> in core,

Some blockers that I can think of are 1) tree-sitter lacks a way to change its 
malloc behavior in run-time, I commented on their road-map issue, but no one 
has replied yet, 2) font-lock and indent support hasn’t settled, 3) writing, 
reviewing and editing the manual will take some time, 4) I need to work on a 
better way to build and distribute language dynamic modules.

> and what can I do to help?

For a starter, could you perhaps have a look at the indentation system 
(tree-sitter-simple-indent-rules and friends), and tell me if anything is 
lacking? Too complex, not powerful enough, etc. Do you have any suggestions? 
The same goes for font-lock.

Also, I’m happy to hear your suggestions on the general tree-sitter API and the 
manual.

Thank you,
Yuan

Attachment: elisp.html.zip
Description: Zip archive



reply via email to

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