Emacs, rust, jump to dependency

I am considering switching from IntelliJ back to Emacs.

One of my favorite feature sin IntelliJ is that I can put the cursor over a function / struct of a dependency (i.e. code I did not write), and jump to it's definition. This involves IntelliJ unzipping the dependency sources somewhere and indexing it.

Question: is there a way to achieve this in Emacs? (If so, can you share relevant sections of ~/.emacs.d/init.el)

I know the vim rust-analyzer plugins claim to have this ability, though I don't really use it myself. Presumably whatever emacs uses is also communicating with rust-analyzer, so I'd assume it can do the same.

Edit: I just saw the part about dependencies. I have no idea on that part.

Yes, by default Racer binds this to M-., and rust-analyzer has a jump-to-def feature as well. My configuration, in case you need help getting started:

and someone who's probably done it better than I:

2 Likes

Just to add to @thor314 ’s great answer: xref-find-definitions (M-.) and xref-pop-mark-stack (M-, or “go back”) work in a broad variety of lsp and non-lsp modes (sometimes natively and sometimes via etags/gtags) and are excellent tools for navigating unfamiliar code in lots of languages.