tagbar icon indicating copy to clipboard operation
tagbar copied to clipboard

Add alternate tagging source by importing from tree-sitter data

Open rpaaron opened this issue 5 years ago • 4 comments

is it possible, does it make sense to be able to dynamically generate the tags from tree-sitter?
ie https://github.com/nvim-treesitter/nvim-treesitter

rpaaron avatar Feb 10 '21 23:02 rpaaron

I'm not 100% up to speed on how treesitter works or what it can be used for, but from what I do know it might make sense if you were running it already for some reason. However this means adding an entirely new backend tags provider. This plugin is already setup to handle different backends, but all the current ones involve shell commands. You would need to write one that somehow used the in-memory structures provided by treesitter that outputs ctags format data.

I'm be happy to help get such a project upstreamed here if you (or somebody else) contributes such a thing, but I don't have the bandwidth to work on such a project.

alerque avatar Feb 11 '21 07:02 alerque

After taking a look at treesitter, that is more of a syntax parser, not a tag parser/generator. It seems to only understand the syntax of a language, not the tag information. For a simple variable or function name that would be ok to identify the type of a variable name or function name. But it doesn't have any hierarchy definition. So for example class member functions wouldn't be given proper ownership definitions so tagbar wouldn't be able to tell what class that function was a member of. So then tagbar wouldn't be able to build a tree correctly. Closing this out as it is not in the scope of what tagbar does. Basic syntax parsing and language interpretation is not enough for what tagbar needs or does with ctags as the backend.

raven42 avatar May 24 '21 14:05 raven42

I don't think that's right @raven42 , Treesitter does provide a hierarchy for symbols. The data structure of it's output is, well, a tree.

hacker-DOM avatar Jul 26 '23 23:07 hacker-DOM

@hacker-DOM I’m certainly open to correction. If it can integrate well and provide a better user experience, I’d be all for it. As @alerque said, we can help merge something in if someone wants to put in the work. That is not something I am free to do right now though.

raven42 avatar Jul 27 '23 02:07 raven42