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

How to find definition after jump to the third-party library file? #155

Open
zhongweiy opened this issue Apr 25, 2023 · 1 comment
Open

Comments

@zhongweiy
Copy link

Hi, there,

I have an issue: after jumped to a third party file (say a system include dir), how can I find further definition in that file?

the default emacs tags has this feature as described:

"For example, if you are working on a program that uses a library, you may wish to have the tags tables of both the program and the library available, so that Emacs could easily find identifiers from both." at https://www.gnu.org/software/emacs/manual/html_node/emacs/Select-Tags-Table.html.

@AmaiKinono
Copy link
Member

Hi, and sorry for the late response.

We have 2 ways to do this.

Use tags backend

First, you need to tag the system include dir together with your project. Say you are using the default configuration of Citre, then when creating a tags file by citre-update-this-tags-file or citre-create-tags-file, you'll see this in the buffer that lets you edit the options:

-R
# Add dirs/files to scan here, one line per dir/file. Leave this
# empty to scan the whole directory.

Add your project root (.) and system include dir (/usr/include/). /usr/include/ will generally be very slow to tag, so you may only want to add some files/subdirs from it.

Then you should be able to jump from your project to /usr/include/. If you want further jumping when inside /usr/include/, create a tags file for it and let Citre use it. We have an example in the user manual, but you could also call citre-create-tags-file in /usr/include/, and maybe store the tags file into the global cache directory (~/.cache/tags/ by default).

Use eglot backend

Citre now has an eglot backend, and language servers should be able to do this. I've tried in a python file (using pylsp), peeking a built-in function definition in my own project works fine. I have no experience with C/C++, but this seems to explain how to setup clangd to find system headers.

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