arnaud-lb / vim-php-namespace

PHP namespace support for VIM. Types "use" statements for you
256 stars 29 forks source link

Any plan to support universal-ctags? #29

Closed rawaludin closed 7 years ago

rawaludin commented 7 years ago

I found generate use statement using universal ctags is broken. Any plan to support it?

https://github.com/universal-ctags/ctags

arnaud-lb commented 7 years ago

Hi

The module uses vim's tags support (it uses the :pta command), and doesn't touch the tags file directly. I guess it should work with anything supported by vim :)

I'll try universal-ctags as soon as I find some free time.

arnaud-lb commented 7 years ago

I've just tried universal-ctags, and I didn't noticed any issue. Could you give some details about your issue ?

rawaludin commented 7 years ago

I use ctags -R --languages=php in universal-tags to generate my tag.

For example, when I tried to add use statement for UserInterface,

Old ctags give me this (its correctly on position 1):

  # pri kind tag               file
  1 F   i    UserInterface     src/Domains/User/Contracts/UserInterface.php
               interface UserInterface extends BaseEntityInterface,
  2 F   i    UserInterface     /Users/rahmatawaludin/Code/hydrogen-crm/vendor/kwri/hydrogen-crm-foundation/src/Domains/User/Contracts/UserInterface.php
               interface UserInterface extends BaseEntityInterface,
  3 F   i    UserInterface     /Users/rahmatawaludin/Code/hydrogen-crm/vendor/tymon/jwt-auth/src/Providers/User/UserInterface.php
               interface UserInterface
Type number and <Enter> (empty cancels):

while using universal-ctags give me this (its on 193):

  # pri kind tag               file
  1 F   a    UserInterface     src/Domains/Action/ActionExecutor.php
               namespace:CRMFoundation\\Domains\\Action typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
  2 F   a    UserInterface     src/Domains/Action/Contracts/ActionExecutorInterface.php
               namespace:CRMFoundation\\Domains\\Action\\Contracts typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
  3 F   a    UserInterface     src/Domains/Action/ResourceFinder.php
               namespace:CRMFoundation\\Domains\\Action typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
  4 F   a    UserInterface     src/Domains/AgentLogin/AgentLoginEloquent.php
               namespace:CRMFoundation\\Domains\\AgentLogin typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
  5 F   a    UserInterface     src/Domains/AgentLogin/Contracts/AgentLoginInterface.php
               namespace:CRMFoundation\\Domains\\AgentLogin\\Contracts typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
  6 F   a    UserInterface     src/Domains/BaseServiceTrait.php
               namespace:CRMFoundation\\Domains typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
  7 F   a    UserInterface     src/Domains/CommunicationTemplate/CommunicationTemplateEloquent.php
               namespace:CRMFoundation\\Domains\\CommunicationTemplate typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
  8 F   a    UserInterface     src/Domains/CommunicationTemplate/Contracts/CommunicationTemplateInterface.php
               namespace:CRMFoundation\\Domains\\CommunicationTemplate\\Contracts typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
  9 F   a    UserInterface     src/Domains/Connector/ConnectionEloquent.php
               namespace:CRMFoundation\\Domains\\Connector typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
....
....
....
 190 F   a   UserInterface     tests/Jobs/User/UserJobsTest.php
               namespace:Test\\Jobs\\User typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
 191 F   a   UserInterface     tests/Observers/Referral/ReferralObserverTest.php
               namespace:Test\\Observers\\Referral typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
 192 F   a   UserInterface     tests/Observers/User/UserObserverTest.php
               namespace:Test\\Observers\\User typeref:unknown:CRMFoundation\\Domains\\User\\Contracts\\UserInterface
               use CRMFoundation\Domains\User\Contracts\UserInterface;
 193 F   i   UserInterface     /Users/rahmatawaludin/Code/hydrogen-crm/vendor/kwri/hydrogen-crm-foundation/src/Domains/User/Contracts/UserInterface.php
               interface UserInterface extends BaseEntityInterface,
 194 F   i   UserInterface     /Users/rahmatawaludin/Code/hydrogen-crm/vendor/tymon/jwt-auth/src/Providers/User/UserInterface.php
               interface UserInterface
Type number and <Enter> (empty cancels):
arnaud-lb commented 7 years ago

Ho wow :)

It looks like that universal-ctags is generating a tag for every use of an interface or class, by default. Try the --php-kinds parameter:

ctags -R --language=php --php-kinds=cfit

This will generate tags only for classes, functions, interfaces, and traits.

rawaludin commented 7 years ago

It works. Thanks! :)