when using PHP namespaces the code I work on uses a large number of namespace aliases, e.g.
<?php
namespace foo;
use bar\baz\qux as bazQux;
...
$a = new bazQux();
Is it possible to configure Exuberant Ctags to index the use of these namespace aliases so that I can jump from a line where the alias is used (the instantiation above) straight to the real class? If that's not possible, what's the best compromise that can be achieved?
I've seen somewhere a not-yet-integrated patch for ctags to use a PHP tokenizer for PHP support instead of the current regex-based implementation; I'd like to continue to use a stock ctags if possible though, rather than having to patch and compile a version myself.
I don't know well about php but I guess
use bar/baz/qux as bazQux;
should be
use bar\baz\qux as bazQux;
After replacing / with \ Universal-ctags(https://ctags.io) can capture bazQux well:
[jet@localhost]~/var/ctags% cat foo.php
cat foo.php
<?php
namespace foo;
use bar\baz\qux as bazQux;
[jet@localhost]~/var/ctags% ./ctags -o - foo.php
./ctags -o - foo.php
bazQux foo.php /^use bar\\baz\\qux as bazQux;$/;" a namespace:foo typeref:unknown:bar\\baz\\qux
foo foo.php /^namespace foo;$/;" n
For those, who don't wait in limbo, there is solution:
You can try improved PHP omni complete for ViM: https://github.com/shawncplus/phpcomplete.vim.
This project supports also things like "use" keyword and namespaces, but it unfortunately depends on patched version of CTags.
Here are instructions how to prepare ctags version, that support namespaces: https://github.com/shawncplus/phpcomplete.vim/wiki/Patched-ctags
I know it's not a braindead solution, and it requires making your hands dirty with your own compilation of ctags, but it worked for me perfectly :)
This is the official changelog: http://ctags.sourceforge.net/news.html
They don't seem to merged yet this patch:
http://sourceforge.net/mailarchive/message.php?msg_id=30749245
So I don't think you can find a prebuilt package with php namespace support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With