emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter integration in python.el


From: Yuan Fu
Subject: Re: Tree-sitter integration in python.el
Date: Mon, 3 Oct 2022 15:31:53 -0700


> On Oct 3, 2022, at 3:19 PM, Matthias Meulien <orontee@gmail.com> wrote:
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
>>> From: Matthias Meulien <orontee@gmail.com>
>>> Cc: emacs-devel <emacs-devel@gnu.org>
>>> Date: Mon, 03 Oct 2022 20:07:44 +0200
>>> 
>>> I also cloned tree-sitter-python but I've no idea of what should be done
>>> with the grammar file.  I've understood that I am suppposed to convert
>>> the grammar to a shared object but I don't know how...
>>> 
>>> (I've tree-sitter-cli installed and in path, but "tree-sitter generate
>>> tree-sitter-python/grammar.js" seems to generate rust and node bindings;
>>> Am I supposed to compile the src/parser.c file?  I don't see any
>>> Makefile...).
>> 
>> Some of these lack the Makefile.  But the Makefile is standard and can
>> be taken from any other language module, for example I see on in
>> tree-sitter-ruby.  So just clone that as well, copy its Makefile into
>> tree-sitter-python, and run "make".
> 
> Thank you, Eli.  It wasn't as easy as you said but I managed to compile
> a shared object using a modified version of the Makefile found in the
> tree-sitter-ruby (using the file as is fails when building
> tree-sitter-{ruby,python} due to a missing -Wl, before -soname usage).
> 
> At first sight, moving commands and imenu seems to work as
> expected.  Fontification too.

I didn’t modify and move commands. There are a lot of them and I don’t know if 
tree-sitter would bring any improvement. Imenu and font-lock are indeed powered 
by tree-sitter.

> 
> I saw small differences between buffers fontified with
> `python-use-tree-sitter' equal to nil and t.  Attached is a screenshot
> where one can see two such differences (the third tall buffer shows the
> output of "tree-sitter highlight"):
> 
> - line 284: The self attribute

Why is the _url attribute highlighted? Other attributes don’t seem to be 
highlighted.

> 
> - line 296: The variable in the f-string

That is expected? I added that to add a bit of flair to tree-sitter font-lock 
;-)

> 
> <Capture d’écran de 2022-10-04 00-07-27.png>
> I'll keep using this branch and collect unexpected behaviors.

Thanks!

Yuan


reply via email to

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