BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Rust Language Server Available for Early Adopters

Rust Language Server Available for Early Adopters

Bookmarks

The Rust Language Server (RLS) aims to make it easier to build tools providing features such as code auto-complete, goto definition, reformatting, etc. RLS alpha is now available for early adopters to try on real projects and send feedback, writes Jonathan Turner, one of the main contributors to the project.

To gather information about the source code, the Rust Language Server uses both the Rust compiler and Racer, a tool meant to provide code completion for Rust code. The compiler is by definition the most authoritative source of information about a program, but, given the current lack of support for incremental compilation in Rust, it may be too slow. Racer, on the other hand, is almost always fast, says Turner, but has some limitations, such as not being able to handle macros, or only partially supporting generic types. For this reason, RLS queries both the compiler and Racer to provide the most accurate information it has available within a predefined allowed time. To make this process as efficient as possible, RLS does not control the compiler or Racer through a shell process but is linked with both.

The current release of RLS supports the following capabilities:

  • auto-completion
  • goto definition
  • goto symbol
  • find all references
  • rename/refactor
  • types on hover
  • how errors.

A key feature of RLS is it adopts Microsoft Language Server Protocol (LSP), which establishes a standard communication protocol between a client, e.g., an IDE or text editor, and a language server. This makes it possible to use RLS with a variety of IDEs or editors supporting Microsoft LSP, including Visual Studio Code, Eclipse Che, and emacs. In particular, RLS can be used with Microsoft Visual Studio Code by installing a plugin. Once the plugin is installed, Visual Studio Code will automatically start the language server and support advanced editing features for Rust.

While still in its early stages and not ready yet for real use, RLS should be able to run against most Cargo-based Rust projects, according to Turner. Developers can install it by executing the following commands:

git clone https://github.com/jonathandturner/rls
git clone https://github.com/jonathandturner/rls_vscode.git
cd rls_vscode
npm install
export RLS_ROOT=/Source/rls

And then starting VS Code. Required build-dependencies are a recent nightly rustc/cargo, git, python, node, and cmake.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT