npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coc-rls

v1.1.6

Published

Rust language support - code completion, Intellisense, refactoring, reformatting, errors, snippets. A client for the Rust Language Server, built by the RLS team.

Downloads

249

Readme

Rust support for coc.nvim

NPM version

It's fork of rls-vscode.

Adds language support for Rust to coc.nvim. Supports:

  • code completion
  • jump to definition, peek definition, find all references, symbol search
  • types and documentation on hover
  • code formatting
  • refactoring (rename, deglob)
  • error squiggles and apply suggestions from errors
  • snippets

Rust support is powered by the Rust Language Server (RLS). If you don't have it installed, the extension will install it for you.

For support, please file an issue on the repo or talk to us on Gitter or in #rust-dev-tools on IRC (Mozilla servers). There is also some troubleshooting and debugging advice.

Note: multiple projects is not supported, you have to use different vim instances.

Quick start

  • Install rustup (Rust toolchain manager).

  • Install this extension in your vim by:

    :CocInstall coc-rls
  • (Skip this step if you already have Rust projects that you'd like to work on.) Create a new Rust project by following these instructions.

  • Open a Rust project. Open the folder for the whole project (i.e., the folder containing 'Cargo.toml'), not the 'src' folder.

  • You'll be prompted to install the RLS. Once installed, the RLS should start building your project.

NixOS

NixOS users should use nix-shell or direnv for development. Follow these instructions to set them up first.

Then create two files:

  1. An .envrc file containing use_nix.
  2. And shell.nix containing:
let
  moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
  nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
  #rustNightlyChannel = (nixpkgs.rustChannelOf { date = "2019-01-26"; channel = "nightly"; }).rust;
  rustStableChannel = nixpkgs.latest.rustChannels.stable.rust.override {
    extensions = [
      "rust-src"
      "rls-preview"
      "clippy-preview"
      "rustfmt-preview"
    ];
  };
in
  with nixpkgs;
  stdenv.mkDerivation {
    name = "moz_overlay_shell";
    buildInputs = [
      rustStableChannel
      rls
      rustup
    ];
  }

Enter the shell in current directory and enjoy developing rust apps + coc.nvim + coc-rls :)

Tip: If you want to use nightly channel uncomment that line and use it :)

Configuration

This extension provides some options into coc-settings.json. These options have names which start with rust.. Install coc-json for auto completion support.

  • "rust-client.logToFile":

    When set to true, RLS stderr is logged to a file at workspace root level. Requires reloading extension after change., default: false

  • "rust-client.setLibPath"

    When set to false, environment variable DYLD_LIBRARY_PATH & LD_LIBRARY_PATH are kept for rls, default: true

  • "rust-client.rustupPath":

    Path to rustup executable. Ignored if rustup is disabled., default: "rustup"

  • "rust-client.rlsPath":

    Override RLS path. Only required for RLS developers. If you set this and use rustup, you should also set rust-client.channel to ensure your RLS sees the right libraries. If you don't use rustup, make sure to set rust-client.disableRustup., default: null

  • "rust-client.revealOutputChannelOn":

    Specifies message severity on which the output channel will be revealed. Requires reloading extension after change., default: "never"

    Valid options: ["info","warn","error","never"]

  • "rust-client.updateOnStartup":

    Update the RLS whenever the extension starts up., default: false

  • "rust-client.disableRustup":

    Disable usage of rustup and use rustc/rls from PATH., default: false

  • "rust-client.channel":

    Rust channel to invoke rustup with. Ignored if rustup is disabled. By default, uses the same channel as your currently open project., default: null

    Valid options: ["stable","beta","nightly"]

  • "rust-client.trace.server":

    Traces the communication between VS Code and the Rust language server., default: "off"

    Valid options: ["off","messages","verbose"]

  • "rust.sysroot":

    --sysroot, default: null

  • "rust.target":

    --target, default: null

  • "rust.rustflags":

    Flags added to RUSTFLAGS., default: null

  • "rust.clear_env_rust_log":

    Clear the RUST_LOG environment variable before running rustc or cargo., default: true

  • "rust.build_lib":

    Specify to run analysis as if running cargo check --lib. Use null to auto-detect. (unstable), default: null

  • "rust.build_bin":

    Specify to run analysis as if running cargo check --bin <name>. Use null to auto-detect. (unstable), default: null

  • "rust.cfg_test":

    Build cfg(test) code. (unstable), default: false

  • "rust.unstable_features":

    Enable unstable features., default: false

  • "rust.wait_to_build":

    Time in milliseconds between receiving a change notification and starting build., default: 1500

  • "rust.show_warnings":

    Show warnings., default: true

  • "rust.crate_blacklist":

    Overrides the default list of packages for which analysis is skipped.

    Available since RLS 1.38, default: ["cocoa","gleam","glium","idna","libc","openssl","rustc_serialize","serde","serde_json","typenum","unicode_normalization","unicode_segmentation","winapi"]

  • "rust.build_on_save":

    Only index the project when a file is saved and not on change., default: false

  • "rust.features":

    A list of Cargo features to enable., default: []

  • "rust.all_features":

    Enable all Cargo features., default: false

  • "rust.no_default_features":

    Do not enable default Cargo features., default: false

  • "rust.racer_completion":

    Enables code completion using racer., default: true

  • "rust.clippy_preference":

    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. You need to install clippy via rustup if you haven't already., default: "opt-in"

    Valid options: ["on","opt-in","off"]

  • "rust.jobs":

    Number of Cargo jobs to be run in parallel., default: null

  • "rust.all_targets":

    Checks the project as if you were running cargo check --all-targets (I.e., check all targets and integration tests too)., default: true

  • "rust.target_dir":

    When specified, it places the generated analysis files at the specified target directory. By default it is placed target/rls directory., default: null

  • "rust.rustfmt_path":

    When specified, RLS will use the Rustfmt pointed at the path instead of the bundled one, default: null

  • "rust.build_command":

    EXPERIMENTAL (requires unstable_features)

    If set, executes a given program responsible for rebuilding save-analysis to be loaded by the RLS. The program given should output a list of resulting .json files on stdout. Implies rust.build_on_save: true., default: null

  • "rust.full_docs":

    Instructs cargo to enable full documentation extraction during save-analysis while building the crate., default: null

  • "rust.show_hover_context":

    Show additional context in hover tooltips when available. This is often the type local variable declaration., default: true

Features

Snippets

Snippets are code templates which expand into common boilerplate. Intellisense includes snippet names as options when you type; select one by confirm the completion. You can move to the next 'hole' in the template by pressing '' (by default). We provide the following snippets:

  • for - a for loop
  • unimplemented
  • unreachable
  • println
  • assert and assert_eq
  • macro_rules - declare a macro
  • if let Option - an if let statement for executing code only in the Some case.
  • spawn - spawn a thread
  • extern crate - insert an extern crate statement

This extension is deliberately conservative about snippets and doesn't include too many. If you want more, check out Trusty Rusty Snippets.

Format on save

To enable formatting on save, open coc-settings.json by :CocConfig, then add "rust" to coc.preferences.formatOnSaveFiletypes field.

Requirements

  • Unless you have "rust-client.disableRustup": true, install Rustup required.
  • A Rust toolchain (the extension will configure this for you, with permission),
  • RLS (currently rls-preview), rust-src, and rust-analysis components (the extension will install these for you, with permission).

Implementation

This extension almost exclusively uses the RLS for its feature support (snippets are provided client-side). The RLS uses the Rust compiler (rustc) to get data about Rust programs. It uses Cargo to manage building. Both Cargo and rustc are run in-process by the RLS. Formatting and code completion are provided by rustfmt and Racer, again both of these are run in-process by the RLS.

LICENSE

MIT