Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(C/C++) GoToDefinition cannot jump to source file in different directory #722

Closed
ghqhxnfizloub opened this issue Dec 13, 2013 · 6 comments
Closed

Comments

@ghqhxnfizloub
Copy link

For example, the project file tree is like this:

|- a
| |- a.c (where the definition of function a() is)
| \- a.h (where the declaration of function a() is)
|
|- b
| \- b.c (calls function a())
|
\- .ycm_extra_conf.py (directory 'a' is added into the flags)

If :GoToDefinition is called in b.c, an error about not being able to jump to definition is raised. If :GoToDefinitionElseDeclaration is called, Vim will jump to a.h but not a.c.

Thanks!

@Valloric
Copy link
Member

From the YCM docs:

For C-family languages [GoToDefinition] only works in certain situations, namely when the definition of the symbol is in the current translation unit. A translation unit consists of the file you are editing and all the files you are including with #include directives (directly or indirectly) in that file.

@ghqhxnfizloub
Copy link
Author

Not considering to add some project-scope code navigation feature? For example, add a funtion, say, GetSources(), in .ycm_extra_conf.py to get the list of source file names? Thanks!

@Valloric
Copy link
Member

Maybe some time in the future, but not any time soon; it's difficult to implement well.

@ghqhxnfizloub
Copy link
Author

Thanks for the reply. Maybe I will continue to use ctags and cscope to achieve that at the moment.

@sshsu
Copy link

sshsu commented Dec 20, 2018

Is it implemented? such feature is really playing a important role

@bstaletic
Copy link
Collaborator

No, but once clangd gets this ability, it will be in YCM.
For now you can jump to declaration and then open the corresponding source file and find the definition. Or you can get clever with your extra conf and automate that process.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants