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

failed jump to function define in another source file. #4265

Closed
2 of 12 tasks
iysheng opened this issue Sep 14, 2024 · 1 comment
Closed
2 of 12 tasks

failed jump to function define in another source file. #4265

iysheng opened this issue Sep 14, 2024 · 1 comment

Comments

@iysheng
Copy link

iysheng commented Sep 14, 2024

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) before filing your issue:

  • I have read and understood YCM's CONTRIBUTING document.
  • I have read and understood YCM's CODE_OF_CONDUCT document.
  • I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • If filing a bug report, I have included the output of vim --version.
  • If filing a bug report, I have included the output of :YcmDebugInfo.
  • If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • If filing a bug report, I have included a minimal test case that reproduces
    my issue, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what I
    expected to happen and what actually happened.
  • If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt gift of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

Provide a clear description of the problem, including the following key
questions:

  • What did you do?
    I touch two file with name a.c and b.c as below:
┗─╼[/tmp/abc]
▸ /usr/bin/cat a.c


int abc()
{

}
┏─╼[redl|openSUSE]╾─╼[07:42:05]╾─╼[0]
┗─╼[/tmp/abc]
▸ /usr/bin/cat b.c


extern int abc();

int main
{
        abc();
}

Include steps to reproduce here.

  1. I open b.c with vim
  2. I triger to jump abc defination with \jd
  3. I couldn't jump to abc function defnation in a.c file but just go to extern int abc(); line

Include description of a minimal test case, including any actual code required
to reproduce the issue.

If you made changes to vimrc_ycm_minimal, pase them here:

<contents of ycm_vimrc_minimal>
  • What did you expect to happen?

I want to achive jump to the function defined in another source fule.

  • What actually happened?

Include description of the observed behaviour, including actual output,
screenshots, etc.

Diagnostic data

Output of vim --version

▸ vim --version
VIM - Vi IMproved 9.1 (2024 Jan 02)                                                                                                                                                         Included patches: 1-330

Output of YcmDebugInfo

Printing YouCompleteMe debug information...                                                                                                                                                 -- Resolve completions: Up front
-- Client logfile: /tmp/ycm_roo7lu42.log                                                                                                                                                    -- Server Python interpreter: /usr/bin/python3.10
-- Server Python version: 3.10.14
-- Server has Clang support compiled in: False
-- Clang version: None
-- Extra configuration file found and loaded
-- Extra configuration path: /home/redl/.vim/plugged/youcompleteme/third_party/ycmd/.ycm_extra_conf.py
-- Server running at: http://127.0.0.1:47787                                                                                                                                                -- Server process ID: 23164
-- Server logfiles:
--   /tmp/ycmd_47787_stdout_is5tb3fb.log
--   /tmp/ycmd_47787_stderr_clin_a34.log
-- Semantic highlighting supported: True
-- Virtual text supported: True
-- Popup windows supported: True

Output of YcmDiags

  0 b.c|5 col 1 error| Main cannot be declared as global variable [main_global_variable]                                                                                                      1 b.c|7 col 7 error| Unexpected ';' before '}' (fix available) [unexpected_semi]
  2 b.c|9 col 1 error| Expected ';' after top level declarator (fix available) [invalid_token_after_toplevel_declarator]                                                                     

Output of git rev-parse HEAD in YouCompleteMe installation directory

b6e8c64d96b02d60b3751d6a51af7dc958054f8f

Contents of YCM, ycmd and completion engine logfiles

Reproduce the issue with vim -Nu /path/to/YCM/vimrc_ycm_minimal, which
enabled debug logging and other useful diagnostics. Include a link to a
gist containing all of the log files listed by :YcmToggleLogs.

OS version, distribution, etc.

Include system information here.

Output of build/install commands

Include link to a gist containing the invocation and entire output of
install.py if reporting an installation issue.

@bstaletic
Copy link
Collaborator

That can work, but something needs to tell clangd that the other file exists. There are two options:

  1. Generate compile_commands.json with your build system.
  2. Manually visit the other file and go back.

In other words, without compile_commands.json, only the opened files "exist" for clangd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants