shawncplus/phpcomplete.vim

Namespace jump to definition

MichaelMackus opened this issue · 6 comments

Is there any way this can be supoorted in phpcomplete? So that <C-]> jumps to the class (with namespace). Currently, it doesn't look like jump to definition is recognizing the namespace. I'd think since phpcomplete supports namespaces, this would be an awesome addition.

I'm not sure what you are asking for, so you have something like this in your code:
$TD = new SomeNamesSpace\TheBestSongInTheWorld(); or have a class imported with use ...
And you cursor is somewhere inside the class or namespace part after the new and hit ctrl+]?

Because that supposed to be supported. There's even a test for it. It uses the same logic as it would if you are trying to get completions for the $TD later on, so it's heavily dependent on your tags file.

However, it could be that the code that tries to guess the context for the symbol you are trying to jump to is buggy, or it could be that the namespace + classname pair cannot be found by the usual mechanisms (in this case it falls back to vim's default behavior for this keybinding), or it could be that I misunderstood the whole thing :-P

Can you give me an example or a little more context on this?

That's exactly what I want to work! It never seems to work for me for some reason :(

I'm on git ref 2fd6ecb of phpcomplete.vim, and using default <C-]> on a namespace never goes directly to that namespace. For example, if I have class

namespapce Acme;

use MyVendor\SubDir\Foo as BaseFoo;

class Foo extends BaseFoo {
}

<C-]> on BaseFoo does nothing. <C-]> on the use statement (MyVendor\SubDir\Foo) Foo jumps to Foo in the current file.

Also, I have patched ctags installed as per wiki of course. Still no cigar unfortunately.

<C-x><C-o> completion works fine, just jump_to_def seems off.

Yeah, this definitely seems to be a bug. Thanks for the report! I think I've managed to reproduce it, will try to look into it.

I've managed to reproduce one of the bugs you've described. The other one seems to work fine in my test environment: https://asciinema.org/a/4kqvw6dtadhhri4zqopfaongp

Maybe I'm missing something, or this sterile environment doesn't produce the second bug you are experiencing, so please pull the latest master, give it a try and see if it helps on both of the problems or just the one I've managed to track down.

I'll close this now. Please feel free to let me know if it's still relevant.