[Top][All Lists]

[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: Fri, 8 Sep 2023 13:53:37 +0200
User-agent: Mozilla Thunderbird

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.


Thanks a lot!

I did some tests and it's working pretty well.

Do you think it's a good idea to add a prefix to bison feature names in font-lock settings to avoid conflicts with C names (as I did)?

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?

- When I try to indent C code by using c-ts-mode indent rules, I get the following error:

Debugger entered--Lisp error: (wrong-type-argument treesit-node-p #<treesit-parser for c>)
  treesit-node-parser(#<treesit-parser for c>)
  treesit-indent-region(1075 1176)
  indent-region(1075 1176)
  funcall-interactively(indent-for-tab-command nil)
  call-interactively(indent-for-tab-command nil nil)

There seems to be a mistake in `treesit--indent-1` in the `cond` at the line `(local-parsers (car local-parsers))`, since a parser is returned while it should be a node.

I attached a newer version of bison-ts-mode and a small patch to
c-ts-mode so I can reuse its `treesit-font-lock-feature-list`.

Attachment: bison-ts-mode.el
Description: Text Data

Attachment: 0001-Put-font-lock-features-of-c-ts-mode-in-a-variable-to.patch
Description: Text Data

reply via email to

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