Code Monkey home page Code Monkey logo

rls's Introduction

Build Status Build status

Rust Language Server (RLS)

The RLS provides a server that runs in the background, providing IDEs, editors, and other tools with information about Rust programs. It supports functionality such as 'goto definition', symbol search, reformatting, and code completion, and enables renaming and refactorings.

The RLS gets its source data from the compiler and from Racer. Where possible it uses data from the compiler which is precise and complete. Where it is not possible, (for example for code completion and where building is too slow), it uses Racer.

Since the Rust compiler does not yet support end-to-end incremental compilation, we can't offer a perfect experience. However, by optimising our use of the compiler and falling back to Racer, we can offer a pretty good experience for small to medium sized crates. As the RLS and compiler evolve, we'll offer a better experience for larger and larger crates.

The RLS is designed to be frontend-independent. We hope it will be widely adopted by different editors and IDEs. To seed development, we provide a reference implementation of an RLS frontend for Visual Studio Code.

Setup

Step 1: Install rustup

You can install rustup on many platforms. This will help us quickly install the RLS and its dependencies.

If you already have rustup installed, update to ensure you have the latest rustup and compiler:

rustup update

If you're going to use the VSCode extension, you can skip step 2.

Step 2: Install the RLS

Once you have rustup installed, run the following commands:

rustup component add rls-preview rust-analysis rust-src

Note (nightly only)

Sometimes the rls-preview component is not included in a nightly build due to certain issues. To see if the component is included in a particular build and what to do if it's not, check #641.

Running

The RLS is built to work with many IDEs and editors, we mostly use VSCode to test the RLS. The easiest way is to use the published extension.

You'll know it's working when you see this in the status bar at the bottom, with a spinning indicator:

RLS: working โ—

Once you see:

RLS

Then you have the full set of capabilities available to you. You can goto def, find all refs, rename, goto type, etc. Completions are also available using the heuristics that Racer provides. As you type, your code will be checked and error squiggles will be reported when errors occur. You can hover these squiggles to see the text of the error.

Configuration

The RLS can be configured on a per-project basis; using the Visual Studio Code extension this will be done via the workspace settings file settings.json.

Other editors will have their own way of sending the workspace/DidChangeConfiguration method.

Entries in this file will affect how the RLS operates and how it builds your project.

Currently we accept the following options:

  • unstable_features (bool, defaults to false) enables unstable features. Currently no option requires this flag.
  • sysroot (String, defaults to "") if the given string is not empty, use the given path as the sysroot for all rustc invocations instead of trying to detect the sysroot automatically
  • target (String, defaults to "") if the given string is not empty, use the given target triple for all rustc invocations
  • wait_to_build (u64, defaults to 1500) time in milliseconds between receiving a change notification and starting build
  • all_targets (bool, defaults to true) checks the project as if you were running cargo check --all-targets. I.e., check all targets and integration tests too
  • use_crate_blacklist (bool, defaults to true) if disabled, also indexes data from the blacklisted crates
  • build_on_save (bool, defaults to false) toggles whether the RLS should perform continuous analysis or only after a file is saved
  • features ([String], defaults to empty) list of Cargo features to enable
  • all_features (bool, defaults to false) enables all Cargo features
  • no_default_features (bool, defaults to false) disables default Cargo features
  • racer_completion (bool, defaults to true) enables code completion using racer (which is, at the moment, our only code completion backend)
  • clippy_preference (String, defaults to "opt-in") controls eagerness of clippy diagnostics when available. Valid values are (case-insensitive):
    • "off" Disable clippy lints.
    • "opt-in" Clippy lints are shown when crates specify #![warn(clippy)].
    • "on" Clippy lints enabled for all crates in workspace.

and the following unstable options:

  • build_lib (bool, defaults to false) checks the project as if you passed the --lib argument to cargo. Mutually exclusive with, and preferred over, build_bin.
  • build_bin (String, defaults to "") checks the project as if you passed -- bin <build_bin> argument to cargo. Mutually exclusive with build_lib.
  • cfg_test (bool, defaults to false) checks the project as if you were running cargo test rather than cargo build. I.e., compiles (but does not run) test code.

Troubleshooting

For tips on debugging and troubleshooting, see debugging.md.

Contributing

You can look in the contributing.md in this repo to learn more about contributing to this project.

If you want to implement RLS support in an editor, see clients.md.

rls's People

Contributors

aldonogueira avatar alexcrichton avatar alexheretic avatar algesten avatar autozimu avatar bvinc avatar craftytrickster avatar dspeckhals avatar fitzgen avatar frewsxcv avatar golddranks avatar ishitatsuyuki avatar johshoff avatar jonasbb avatar jwilm avatar kalitaalexey avatar khadiwala avatar kogai avatar malbarbo avatar matklad avatar mgeisler avatar nrc avatar oli-obk avatar philip-alldredge avatar sebastiencs avatar stuarth avatar tetsuharuohzeki avatar wmorgue avatar xanewok avatar zmanian avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.