From: "Augustin Chéneau (BTuin)" <btuin@mailo.com>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Questions about tree-sitter
Date: Wed, 13 Sep 2023 14:43:09 +0200 [thread overview]
Message-ID: <9fef551c-3a8d-4df8-ac1d-a9884b73da5d@mailo.com> (raw)
In-Reply-To: <2E2323FB-1A32-48B6-992E-66F474427199@gmail.com>
Le 12/09/2023 à 02:22, Yuan Fu a écrit :
>
>
>> On Sep 9, 2023, at 9:39 AM, Augustin Chéneau (BTuin) <btuin@mailo.com> wrote:
>>
>> Le 08/09/2023 à 18:43, Yuan Fu a écrit :
>>>> On Sep 8, 2023, at 4:53 AM, Augustin Chéneau (BTuin) <btuin@mailo.com> wrote:
>>>>
>>>> Le 06/09/2023 à 06:07, Yuan Fu a écrit :
>>>>> I added local parser support to master. If everything goes right, you just need to add a :local t flag in treesit-range-rules. Check out the modified bision-ts-mode.el that I hacked up for an example. BTW, it’s vital that you define treesit-language-at-point-function for a multi-language mode.
>>>>> Yuan
>>>>
>>>> Thanks a lot!
>>>>
>>>> I did some tests and it's working pretty well.
>>> Awesome!
>>
>>
>> It seems I spoke a bit too soon :(
>> When I edit the buffer, sometimes there is an offset between the text and the nodes after modifying the buffer, or the syntax highlighting breaks in C code.
>>
>> I attached an example Bison file if needed.
>
> Thanks. I was able to reproduce this, but then can’t. I’ll keep looking into this, if you found out something new please let me know.
>
It may be unrelated, but I have this popping in *Messages* sometimes:
Error during redisplay: (jit-lock-function 1410) signaled
(treesit-load-language-error not-found ("libtree-sitter-nil"
"libtree-sitter-nil.0" "libtree-sitter-nil.0.0" "libtree-sitter-nil.so"
"libtree-sitter-nil.so.0" "libtree-sitter-nil.so.0.0") "No such file or
directory")
>>
>>>> I have a few issues though:
>>>>
>>>> - I first defined `treesit-language-at-point-function` using
>>>> `treesit-node-at`. However, `treesit-node-at` itself uses
>>>> `treesit-language-at-point-function` which causes an infinite recursion.
>>>> So I instead used `treesit-local-parsers-at` to check if a local parser is used. Is it a good solution?
>>> No no, you should use the host langauge’s parser (bison) and see if point is in an undelimited_code_block, and return c or bison accordingly. I’m highlight this in the docstring, thanks.
>>
>> So I need to call `treesit-node-at` with `'bison` as the value for PARSER-OR-LANG to see in which node I am?
>> Then I think there is a problem with `treesit-node-at`, because it always call `treesit-language-at` even if PARSER-OR-LANG is provided.
>> I propose a fix in the attached patch.
>
> You are right. I applied a similar fix. It should be good now. Thanks!
Thanks!
next prev parent reply other threads:[~2023-09-13 12:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 21:26 Questions about tree-sitter Augustin Chéneau (BTuin)
2023-08-30 7:03 ` Yuan Fu
2023-08-30 11:28 ` Augustin Chéneau (BTuin)
2023-09-06 4:07 ` Yuan Fu
2023-09-08 11:53 ` Augustin Chéneau (BTuin)
2023-09-08 16:43 ` Yuan Fu
2023-09-09 16:39 ` Augustin Chéneau (BTuin)
2023-09-12 0:22 ` Yuan Fu
2023-09-13 12:43 ` Augustin Chéneau (BTuin) [this message]
2023-09-14 4:11 ` Yuan Fu
2023-09-18 17:04 ` Augustin Chéneau (BTuin)
2023-09-19 4:00 ` Yuan Fu
2023-09-01 2:39 ` Madhu
2023-09-01 6:53 ` Eli Zaretskii
2023-09-01 9:15 ` Madhu
2023-09-01 10:45 ` Dmitry Gutov
2023-09-01 10:58 ` Eli Zaretskii
2023-11-27 7:16 ` Madhu
2023-09-06 16:11 ` Lynn Winebarger
2023-09-07 23:42 ` Yuan Fu
2023-09-08 0:11 ` Lynn Winebarger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9fef551c-3a8d-4df8-ac1d-a9884b73da5d@mailo.com \
--to=btuin@mailo.com \
--cc=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).