[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Questions about tree-sitter
From: |
BTuin |
Subject: |
Re: Questions about tree-sitter |
Date: |
Mon, 18 Sep 2023 19:04:02 +0200 |
User-agent: |
Mozilla Thunderbird |
Le 14/09/2023 à 06:11, Yuan Fu a écrit :
On Sep 13, 2023, at 5:43 AM, Augustin Chéneau (BTuin) <btuin@mailo.com> wrote:
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”)
Thanks. I’ve fixed that and some other problems. Please pull master and try it
out. Now bison-ts-mode works pretty well for me. I can’t reproduce the offset
problem anymore, maybe it’s fixed in some of the fixes I made. Anyway, let me
know if you observe it again.
Yuan
It indeed works much better, thanks!
I found a bug and a way to replicate it (you'll need to update your
Bison grammar):
- Open the file "treesit-bug-highlighting-demo";
- Enable bison-ts-mode;
- At the beginning of the second line (the part managed by the embedded
C parser, with "static void ..."), add a space;
=> The whole line loses its highlighting.
If you add a space again, the highlighting works correctly again.
Not a big issue, but pretty weird.
Also, I have one (last?) question:
Since the C code uses its own indentation, it's entirely independent of
Bison's nodes positions.
Is it possible to add an offset to the indentation of the embedded
parts, relative to its container node?
For instance, rather than:
%%
grammar_declaration:
grammar_rule
{
int myvar;
}
;
%%
I would like to get
%%
grammar_declaration:
grammar_rule
{
int myvar;
}
;
%%
("int myvar;" is managed by a C parser).
bison-ts-mode.el
Description: Text Data
treesit-bug-highlighting-demo
Description: Text document
- Re: Questions about tree-sitter, (continued)
- Re: Questions about tree-sitter, Yuan Fu, 2023/09/06
- Re: Questions about tree-sitter, BTuin, 2023/09/08
- Re: Questions about tree-sitter, Yuan Fu, 2023/09/08
- Re: Questions about tree-sitter, BTuin, 2023/09/09
- Re: Questions about tree-sitter, Yuan Fu, 2023/09/11
- Re: Questions about tree-sitter, BTuin, 2023/09/13
- Re: Questions about tree-sitter, Yuan Fu, 2023/09/14
- Re: Questions about tree-sitter,
BTuin <=
- Re: Questions about tree-sitter, Yuan Fu, 2023/09/19
Re: Questions about tree-sitter, Lynn Winebarger, 2023/09/06