Add "follow reference" to go to typedef #519
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, clang_complete does not support following definitions very well in code like this:
I want to go from
foo
inmain()
to thetypedef factory<Foo, int> foo;
line. However,C-]
(org:ClangGotoDeclaration
) goes straight through the typedef to the definition offactory::factory
, which is useless. After some print-debugging, it seems that in functiongotoDeclaration
, neithercursor.get_definition()
norcursor.referenced
returns a cursor to the typedef; both return cursors to the constructor. From my limited experimentation it seems to only occur when the typedef is for a templated type.(Of course, this is a trivial example. For a challenge, I dare you to try finding the definition of
buffer
used in this function. clang_complete currently can only take you to something calledpipe_middle
which is not what you want.grep
is useless since the wordbuffer
is used all over the codebase.)Fortunately,
cursor.type.get_declaration()
goes to the typedef. This patch adds support for going to that cursor and thus fixes the problem.I've added
map \g :call g:ClangGotoDeclaration()<CR>
to myvimrc
(mimicking jedi-vim's function for that binding, and now I can go to the typedef using that binding.