Emacs, elgot, xref, and standard lib

Hi there, is there a way to navigate to symbols in the std lib using xref? So I'm happily coding and I think "remind me what the Array methods are" so I want to type "M-x xref-somethingArray" and up pops Array. What magic do I replace ref-something with?

This works perfectly if I type Array in a .rs file in the main buffer, put my point on it, and navigate to it that way (C-h . or M-.), but I don't want to have to type the code first.

Is there a way of navigating the std lib from the command line?

Thanks!

With the LSP workspace symbol search, you can type Whatever* and it will search in all dependencies. With lsp-mode, that would be the lsp-ido-workspace-symbol or lsp-ivy-workspace-symbol command. I don't use eglot, so I don't know how it exposes this functionality (but the * thing is a rust-analyzer function and should work with every client).

1 Like

unfortunately that doesn't seem to work (C-u M-x xref-find-definitions<cr>Option*<cr>) shows "No definition found for Option*.

I'll keep playing - I might cave in and install one of the completion frameworks (Company or Vertico?) to see if that can do any magic for me...

Ah! It is *Option not Option* ;-). Thanks for the nudge @fdiebold

Both should work (RA just looks for a * anywhere in the string), but maybe xref strips it away at the end or something like that.

1 Like

(thanks @fdiebold)