First alpha release of the Rust Language Server is here
The Rust Language Server is a way of providing editors and IDEs with a range of functionality. It should now be able to run against most Cargo-based Rust projects.
According to the official announcement, “the Rust Language Server is a way of providing editors and IDEs with a range of functionality. Rather than leaving each editor plugin to have to parse and understand the types in your program and provide you with capabilities like refactoring, the RLS centralizes all this logic and provides it to the editor via a standard language server protocol.”
Rust Language Server overview
Jonathan Turner, Engineer at Mozilla working on Rust, encouraged early adopters to “try on real projects” and send them feedback. In the first alpha release of the RLS, editors and IDEs can share the following capabilities:
- auto-completion – allows the user to complete symbols and press ‘.’ for member lists
- goto definition – jump to the definition of a given symbol
- goto symbol – jump to the definition of a symbol you know the name of
- find all references – show all the locations a given symbol is referenced
- rename/refactor – rename all instances of a given symbol to a new name
- types on hover – get the type of a symbol
- show errors – as the user types, get live analysis showing errors as they happen
The current version is built from a combination of two tools: racer and the Rust compiler. The former allows the team to get quick-and-dirty completions while allowing the user to get completion results in sub-second times. However, this also means that results are not as accurate. The RLS uses the Rust compiler for tasks which require higher accuracy, such as safe refactoring or code navigation; even though it is more accurate, the downside is that it takes longer to complete, so the RLS tells the editor when the analysis has successfully completed.
SEE ALSO: What to expect from Rust in 2017
Turner also explained that the Rust Language Server is closely tied to particular versions of rustc, so rustup users should know that the DLLs it needs are managed by rustup. In this case, an error like this might appear if you run the rls by hand:
jturner-23759:rls jturner$ ~/.cargo/bin/rls dyld: Library not loaded: @rpath/librustc_driver-6eb85298.dylib Referenced from: /Users/jturner/.cargo/bin/rls Reason: image not found Abort trap: 6
When users encounter this error, the best way to handle it is to run the rls by instead of running the command
cargo run in the rls directory. Turner also promised that as the team improves the rls integration with the main Rust tools, this will no longer be an issue.
The beta will be the first that will be distributed as a binary and will be much closer to final 1.0 experience in terms of ease-of-install and ease-of-use, Turner wrote. The RLS must go through a stabilization period before it’s ready for 1.0.