preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.1k stars 485 forks source link

typescript tags generated uncorrected #808

Open wzprichardwzp opened 2 years ago

wzprichardwzp commented 2 years ago

Im using universal ctags with tagbar, and tagbar is not generating the type information correctly. I checked and tagbar is indeed using the correct executable (not the one mac has by default).

Screen Shot 2022-02-19 at 10 38 21 PM Screen Shot 2022-02-19 at 10 39 50 PM
raven42 commented 2 years ago

@richardwzp I am not very familiar with typescript. Can you describe what it is you are expecting to see?

wzprichardwzp commented 2 years ago

I was kind of expecting the tags to capture the annotated type

raven42 commented 2 years ago

Currently the way tagbar functions with regard to the type is one of two ways. The first and more accurate way is if ctags gives us the type. This is seen with the --fields=t output from ctags.

This field isn't supported by all languages in ctags though, so that gives the second approach. If bot found, tagbar will do its best to try and guess at the type. To be consistent, it will extract the contents of the line preceding the tag and use that as the datatype. This cor was added as part of #698, specifically the s:getDataType() routine.

It is not really feasible to create a separate parser for each language within tagbar itself, so the best bet would be to work with the ctags team to add datatype support the typescript language. If that was done, then tagbar should be able to get the type correctly.