Question about the Rust documentation read by Emacs (lsp-ui-doc)

Hello everyone

My working environment:

OS: Linux Ubuntu 20.04 (x86_64)
rustc --version: rustc 1.48.0 (7eac88abb 2020-11-16)
cargo --version: argo 1.48.0 (65cbdd2dc 2020-10-14)
Emacs version: 27.1 (64 bits)

I would like to ask a question about installing locally the Rust documentation and use it in Emacs. According to the online installation guide, once you install Rust, it is possible to have the documentation locally and this can be verified by running the following command:

rustup doc

This opens a web browser with the index page of the documentation (offline), so that means that I have managed to successfully install the documentation.

Now my question is:

Is there any other documentation in either txt format or man page format that should be installed? The reason that I ask this question is that I use lsp-ui in Emacs. This has a very interesting functionnality : lsp-ui-doc so that when you put the cursor let's say on the name of a function that you have defined a popup will show the documentation of the function, which is quite handy. However I noticed that the package does this solely for my own development and not for example for the standard library. So for example if at the first line of my program I have

use std::thread;

And then I put the cursor at the beginning of the word thread, then lsp-ui-doc doesn't show any documentation. So I was woundering whether I have missed something in the installation so that the required documentation might be missing and as a result lsp-ui-doc cannot find it.

I would appreciate if you could kindly make some clarification.

Regards.

Most LSPs will find the documentation by inspecting the item's source code and looking for doc comments. You might need to install a copy of the standard library's source code (rustup component add rust-src) then tell the Emacs plugin where this is, if it doesn't automatically detect it.

I'm guessing the plugin will have instructions for this, otherwise you may need to create a ticket on their issue tracker.

2 Likes

I can confirm that

Running

rustup component add rust-src

solved the problem and Emacs detected automatically the documentation.

Thank you very much for your help.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.