I’ve written a syntax for the Perl language using a tree-sitter grammar:
So far this mostly works as expected. I’ve added symbols and folds and they are recognized correctly by the editor. Folds work fine, symbols show up in the symbol browser, all good.
However, I am having trouble with built in editor features like completions which rely on indexed symbols. In any individual file, function and class completions work based on symbols, but functions and classes from other files are not included. If I go to those files and trigger a completion, then the completions are available inside of other files. I’ve intentionally left out any
<expression> tag from the grammar completion to make this problem easier to show.
So say I have 2 files:
I open test.pl and the only completions available are the functions in that file. I navigate to test2.pl and the only completions available are from that file. I trigger a completion of a function inside of test2.pl and now when I navigate back to test1.pl I see all of the symbol based completions from test2.pl included as well.
If I reindex the project files everything is reset and the problem happens again. This also breaks go to definition, as it is based on symbols as well.
I made a screen recording of this as well:
Here is the test project I used:
I’ve found in larger projects the behavior can vary, where it might pick up some functions from other files but normally leaves out all .pm files and other perl scripts as well. So I’m not sure if this is an issue with my grammar, my completions file, some complication in trying to compete with an existing language grammar, etc… Or if it is some sort of completions/indexing bug. Any help appreciated!