Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Rust autocomplete in Visual Studio Code for external crates such as 'gtk-rs'

Maybe this question has been done before but I can not find anything.

I would like to know what steps to follow so that Visual Studio Code can show the autocomplete window that shows Rust methods and such, for example when using ctrl+space (In many commons, editors) What I see is that it works for std but not for gtk-rs.

I was wondering if I would have to tell you in some way how to find the files or something like that.

I do not know if this will depend on each editor or all have some specific files included, my IDE is Visual Studio Code.


...you forgot to include the extensions that you have installed

kalitaalexey Rust for Visual Studio Code

Rust Language Server integration.
Autocompletion (via racer or RLS).
Go To Definition (via racer or RLS).
Go To Symbol (via rustsym or RLS).
Code formatting (via rustfmt).
Code Snippets.
//..
like image 445
Angel Angel Avatar asked May 10 '17 16:05

Angel Angel


2 Answers

Although there could be many possible causes of a problem with the Rust extension in Visual Studio Code, the following steps should help anyone with issues of this kind:

  • Do not use the old extension "Rusty Code", since it's no longer maintained. Instead, you have two options:
    • The official rust-lang.rust extension is developed by an official Rust team and is focused on Rust Language Server (RLS) integration. It is in active development.
    • The kalitaalexey.vscode-rust extension, forked from Rusty Code, is older but possibly more stable than the official extension when run in Legacy Mode. It is currently under very passive maintenance however.
  • You might need to build your project so that dependencies are downloaded and compiled locally, thus enabling the extension to retrieve additional information about them. Every time you modify your dependency list, be sure that your program is declaring them with extern crate, then run cargo build on your project. If the Code command is available, press F1 then type in "build" and enter. Don't forget to build after cleaning the project as well.
  • It's always worth making sure that the extension is up to date and properly configured. Update the extension, and check out the respective documentation for instructions on how to make it work. when using kalitaalexey.vscode-rust, see the main documentation and have it work in either Legacy mode or using the RLS.
  • The RLS has come a long way over the past few years, and should be the default choice for Visual Studio Code. The RLS can even be installed automatically from the IDE, via Rustup.
  • Check the status bar. If something is wrong, it should tell you so. Open the extension task's output window for error messages. If something still isn't right, try reloading your window.

If there's still a problem after these steps, it might actually be a bug, which should be reported.

like image 110
E_net4 stands with Ukraine Avatar answered Sep 17 '22 23:09

E_net4 stands with Ukraine


For me solution was to use Rust Analyzer extension https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer instead of rust-lang.rust https://marketplace.visualstudio.com/items?itemName=rust-lang.rust

like image 43
Lex Avatar answered Sep 20 '22 23:09

Lex