VIM: hack ctags or tweak tagbar for better PHP support

亡梦爱人 提交于 2019-12-24 03:14:14

问题


Recently, i gave up Taglist for Tagbar. Tagbar works as expected for all languages except PHP. It lists class, methods and variables into their respective categories instead of displaying methods and variables into their respective scope.

I came to know that ctags has poor support for PHP.

Is there any way to improve ctags and Tagbar's support for PHP? I am hopping for some kind of hack or tweak, or any other way around.


回答1:


I have just using PHP_Parser as syntax parsing backend written a tool called phpctags to generate ctags compatiable index file and an addon plugin for tagbar called tagbar-phpctags to enhance the PHP suport for tagbar.

Methods and properties even local variables assigned in functions could be listed in their own scope now as well as their access information.

Maybe these could help.




回答2:


Unfortunately there is no easy answer to this. The ctags PHP parser just uses regular expressions, and the result -- as you noticed -- is that support for scopes is missing.

There would be two ways to get proper scope support working: someone has to write either an actual recursive parser module for ctags, or some other program that can output tags in a ctags compatible format. That could theoretically even be written in PHP, which might make it easier -- maybe there already is some functionality available that allows access to the AST, which would then just need to be printed out in the correct format. But until someone does that I'm afraid there's no real way to properly display PHP scopes in Tagbar, since it has to rely on the information that ctags hands to it.



来源:https://stackoverflow.com/questions/11290352/vim-hack-ctags-or-tweak-tagbar-for-better-php-support

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!