Rust plugin for the IntelliJ Platform

Related tags

rust intellij
Overview

Rust plugin for the IntelliJ Platform

official JetBrains project Join the chat at https://gitter.im/intellij-rust/intellij-rust JetBrains plugins JetBrains plugins

Build Status
Check Check Status
Stable Stable Build Status
Beta Beta Build Status
Nightly Nightly Build Status

Installation & Usage

Available installation options and features are described on intellij-rust.github.io. All new features are announced in the changelog.

If you want to jump straight in, open Settings > Plugins > Marketplace in your IDE, search for Rust and install the plugin. To open an existing project, use File | Open and point to the directory containing Cargo.toml. For creating projects, use the Rust template. You can find more details in the Quick Start Guide.

Compatible IDEs

The plugin is compatible with all IntelliJ-based IDEs starting from the version 2020.3, with the following differences in the sets of the available features:

Open-source and Educational IDEs* CLion (commercial) IntelliJ IDEA Ultimate, PyCharm Professional, GoLand (commercial) WebStorm, PhpStorm, other commercial IDEs
Language support + + + +
Cargo support + + + +
Code coverage + + + +
Debugger - + +** -
Profiler - + - -
Valgrind Memcheck - + - -
Detecting duplicates - + + +

* IntelliJ IDEA Community Edition, PyCharm Community Edition, PyCharm Edu and IntelliJ IDEA Edu.

** Requires the Native Debugging Support plugin. LLDB only. PyCharm Professional and GoLand support debugging starting from 2021.1

TOML

If you are looking for the TOML plugin, see intellij-toml directory.

Contributing

You're encouraged to contribute to the plugin if you've found any issues or missing functionality that you would want to see. Check out CONTRIBUTING.md to learn how to set up the project and ARCHITECTURE.md to understand the high-level structure of the codebase. If you are not sure where to start, consider the issues tagged with help wanted.

Issues
  • Implement debugger

    Implement debugger

    The work has started: https://github.com/intellij-rust/intellij-rust/tree/fc2cfb8e0fc76984495a34ae6a83cbb37188c699/debugger

    State of the art

    The debugger is officially available in CLion since 2018.1. Note, CLion doesn't support debugging with msvc toolchains, so if you are using Windows, you need:

    • install gnu rust toolchain (rustup install stable-gnu)
    • setup gnu (Cygwin or MinGW) toolchains in CLion (Preferences > Build, Execution, Deployment > Toolchains).

    To debug you just need to:

    • Run debug command via gutter icon 2018-05-28 11 46 26
    • Or create Cargo Command run configurtion
    screen shot 2018-05-28 at 11 50 04 and run debugging via debug action

    2018-05-28 11 52 16

    Old content

    Old content

    If you use CLion and the nightly Cargo, you should be able to Debug Cargo configuration:

    https://zippy.gfycat.com/AcidicMediocreCoati.webm

    A major missing piece is that we don't pass command line arguments to the debuggee yet (this requires some work on the Cargo side of things first).

    Old content 2

    Currently for technical reasons (commit message) debugger is implemented as a separate plugin.

    The current build can be download from TeamCity: Download. It may work with CLion 2016.3.2 and intellij-rust 0.1.0.1611.

    Note that this is super unstable, debugger can invoke any kind of undefined behavior, including, but not limited to, summoning of nasal daemons. Most importantly, rust debugger may (though in theory it should not) break C++ debugging.

    Nonetheless, step into and local variables view more or less work :)

    debugger

    As you can see on the screenshot, at the moment you unfortunately have to create a separate Cargo debug run configuration type (as opposed to the usual Run cargo command). Also, you only can debug binaries now :(

    feature subsystem::debugger 
    opened by matklad 137
  • Contributor License Agreement

    Contributor License Agreement

    To everyone who has contributed code to IntelliJ Rust: we want to make this plugin officially supported by Jet Brains, but to do so, we need contributor license agreements signed by anyone who had added code to the plugin. If you do not wish to sign such a CLA form, let me know so that I can find a way to back out any changes you may have made.

    To sign the CLA, please follow instructions at https://www.jetbrains.com/agreements/cla/. The procedure consists of a couple clicks: no need to scan or print or snail-mail anything. Comment on this issue after signing the CLA so that I can track progress easily.

    The text of CLA can also be found here.

    It's quite possible that due to recent code rewrites, your change may not appear anymore. If that is the case, I only ask that you verify this, so I can take you off of the list of people we need CLAs from.

    Thank you all!

    Q&A:

    Q: Does this mean that IntelliJ Rust is becoming a closed source proprietary project of Jet Brains?

    A: No, IntelliJ Rust plugin will be free, open source and welcoming to contributors. However it is possible that in the future Jet Brains releases a paid product based on the IntelliJ Rust technology.

    Q: What is the purpose of CLA?

    A: This CLA is for your protection as a Contributor as well as the protection of JetBrains and its users; it does not change your rights to use your own Contributions for any other purpose.

    cc:

    • [x] @alexeykudinkin
    • [x] @alexpana
    • [x] @allengeorge
    • [x] @alobb
    • [x] @alygin
    • [x] @andruhon
    • [x] @ashleysommer
    • [x] @bgourlie
    • [x] @CGavrila
    • [x] @chriskrycho
    • [x] @contradictioned
    • [x] @d9n
    • [x] @daschl
    • [x] @Falkenfighter
    • [x] @farodin91
    • [x] @framlog
    • [x] @friedroman
    • [x] @greg-kargin
    • [x] @himikof
    • [x] @HybridEidolon
    • [x] @johnthagen
    • [x] @jonas-schievink
    • [x] @KalitaAlexey
    • [x] @Keats
    • [x] @kumbayo
    • [x] @la10736
    • [x] @LiamClark
    • [x] @Litarvan
    • [x] @madisp
    • [x] @mbStavola
    • [x] @mcarlin
    • [x] @mfarrugi
    • [x] @mitchhentges
    • [x] @mkaput
    • [x] @mrhota
    • [x] @netvl
    • [x] @ninjabear
    • [x] @oistein
    • [x] @pavel-v-chernykh
    • [x] @Shiroy
    • [x] @sirgl
    • [x] @slavam2605
    • [x] @ThoseGrapefruits
    • [x] @tigarmo
    • [x] @tov
    • [x] @Turbo87
    • [x] @Undin
    • [x] @vasily-kirichenko
    • [x] @winger
    • [x] @zjhmale

    Issue template take from https://github.com/jwiegley/use-package/issues/282 :)

    opened by matklad 61
  • Enable WSL Support

    Enable WSL Support

    Fixes #1171 and continues #4797, #4970, and #4737 (sorry, this was hard)

    feature 
    opened by akainth015 55
  • `RustImplIndex` revisited

    `RustImplIndex` revisited

    RTM

    opened by alexeykudinkin 44
  • Support symlinks better

    Support symlinks better

    Resolve all symlinks in packages and targets.

    Also, resolve symlinks before any call of LightDirectoryIndex to use the same virtual files as we use while index creation

    Should fix #2466, but I don't know how to create good tests for this case Fixes #2633

    opened by Undin 40
  • CARGO: Annotate basic docs in cargo.toml

    CARGO: Annotate basic docs in cargo.toml

    Fixes #1776 @matklad Any idea to fix the problem with the test?

    opened by farodin91 37
  • Possible regression in release 127 - rust edition not detected, file not include in module tree

    Possible regression in release 127 - rust edition not detected, file not include in module tree

    Environment

    • IntelliJ Rust plugin version: Release 127 -- also tried 0.3.128.3262-202-nightly
    • Rust toolchain version: 1.45
    • IDE name and version: IntelliJ Community 2020.2 (was also the case on 2020.1)
    • Operating system: Kubuntu Linux 19.10

    Problem description

    After updating the plugin from 126 -> 127 my project had lots of various errors. I have tried reimporting the project, re-loading the Cargo.toml from the "Cargo" menu. In Release 126, I was using the "experimental macro engine" and I didn't have any errors across my project.

    I don't really understand which of the following is a root problem, so I will just post some of the issues to give a picture of what I'm experiencing.

    Edition is not being correctly detected and async keyword is disallowed

    "This feature is only available in Edition 2018"

    image

    Source files are not being included in the module tree

    "File is not included in module tree"

    image

    Modules declared at the top level are not found

    "File not found for module"

    see first screenshot

    The one thing that makes this project different is that it is using rust-protobuf to do codegen and is including the generated code at the top of main. This means the project not only has a build.rs, but also an include! macro in main.rs.

    I downgraded the plugin to 126 in 2020.1 and the project started building properly again. I can't use plugin 126 in 2020.2. Is there a way I can get a build (or build myself) a version of 126 that I can use in 2020.2 while we work this out?

    I did try suggestions in #3628 and #4907, but have not been able to find a resolution.

    Thanks for your help, and thanks for an awesome plugin. :)

    Steps to reproduce

    Source code for project is not open source, so this may be difficult.

    bug 
    opened by clintfred 36
  • INT?: Implement trait methods and type aliases

    INT?: Implement trait methods and type aliases

    This PR extends Implement members functionality.

    1. Added automatic implementation of type aliases (with defaulting type ())
    2. Implement members quick fix now shows a chooser dialog to choose members to implement
    3. Ctrl+I (implement members code insight feature) is now available

    Example of chooser dialog: image

    Example (when all members were chosen):

    #![feature(associated_type_defaults)]
    
    trait Foo {
        type Type1 = i32;
        type Type2;
        type Type3;
        fn foo();
        fn bar();
        fn baz() {}
    }
    
    struct Bar;
    
    impl Foo for Bar {
        type Type2 = ();
        type Type3 = ();
    
        fn foo() {
            unimplemented!()
        }
    
        fn bar() {
            unimplemented!()
        }
    }
    

    Note: I commented out one test, because now quick fix does not automatically generate all members, only after dialog choosing. I don't know how to write a new version of test.

    opened by slavam2605 35
  • COMP: add all remaining arms match postfix template

    COMP: add all remaining arms match postfix template

    This PR changes match postfix template to generate all match arms instead of just a single wildcard.

    Currently, no template is used, the caret is just moved after the left brace of the first arm. Should there be some template to rename things from the generated arms? If yes, what should it rename?

    Fixes https://github.com/intellij-rust/intellij-rust/issues/6630 Fixes https://github.com/intellij-rust/intellij-rust/issues/4727

    changelog: match postfix template now generates all missing match arms by default.

    feature 
    opened by Kobzol 34
  • REF: add basic implementation of change signature refactoring

    REF: add basic implementation of change signature refactoring

    This PR adds the Change signature refactoring.

    change-signature

    The current implementation has basic functionality.

    • ~How should the user be able to enter the name and type of parameters? I suggest that we use RsPat for name and Ty or RsTypeReference for types instead of plain strings, so that after the user enters something, we try to parse it and if it fails, we will not allow the dialog to proceed.~
    • ~Currently, if a new parameter is added, it will not be filled with a default value at call sites, so that the user will not forget to update the call sites. This mirrors the behaviour of Kotlin.~
    • ~Should the dialog offer things like async, unsafe, extern or variadic args? If yes, we need to let the user enter any possible value for these attributes. I think that it's worth to do it only if we can actually refactor something after changing them. Maybe removing/adding await/unsafe from call sites?~
    • ~Originally I wanted to unify the Change signature and Extract function UI (and some data structures), but I realized that they actually differ quite a lot and it would complicate the code too much I think. I checked the Kotlin plugin and it has two different dialogs for these refactorings, so I think that it's ok.~
    • ~I wanted to move all surrounding whitespace and comments when a parameter is moved from one place to another, but I'm having a difficulty making it work. The commented code in insertItemWithComma didn't work, basically if I try to do something like this:~
    val inserted = parent.addBefore(<some whitespace>, anchor)
    

    ~the inserted will contain anchor instead of the inserted whitespace. This breaks copying of successive whitespace and comment elements, which I tried to do in a loop. Any hints of what might be wrong here?~

    I'm not a huge fan of the signature config being mutable, but it makes UI and test code simpler and it also helps with detection of modified parameters (so I don't have to generate a GUID or something like that for them).

    ~The logic about detecting moved/removed/added parameters is slightly convoluted, it could be probably simplified, but I want to leave that for a final refactoring. It's not as simple as it sounds, as we must detect what parameters were removed, what were added and what were just moved, these operations have different semantics, even if they end up with the same result in the signature (see test move and add parameter and test swap parameters).~

    Fixes: https://github.com/intellij-rust/intellij-rust/issues/4927

    changelog: Add the Change Signature refactoring for functions and methods.

    feature to be documented 
    opened by Kobzol 34
  • Support implicit named arguments in formatting macros

    Support implicit named arguments in formatting macros

    RFC: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html

    Small example:

    let (person, species, name) = ("Charlie Brown", "dog", "Snoopy");
    
    // implicit named argument `person`
    print!("Hello {person}");
    
    // implicit named arguments `species` and `name`
    format!("The {species}'s name is {name}.");
    

    Note, format_args_capture is current feature name in rustc 1.54.0-nightly

    • [ ] don't produce false-positives for name arguments #7332
    • [ ] name resolution
    • [ ] completion
    • [ ] take into account in analysis (unused variables, for example)
    • [ ] check if feature is available
    • [ ] annotate unresolved references
    feature meta rust 
    opened by Undin 2
  • plugin getting definition from wrong source

    plugin getting definition from wrong source

    Problem Description

    When I added dialoguer::Term to my imports it now things that Validator is coming from dialoguer

    ide screenshot of problem

    Steps to reproduce

    https://github.com/xenoterracide/brix-rust/blob/315f835/crates/brix_commands/src/copy_command.rs

    Environment

    • IntelliJ Rust plugin version: 0.4.148.3911-211

    • Rust toolchain version: cargo rustc -- --version # brix_commands -> main Compiling brix_commands v0.1.0 (/home/xeno/IdeaProjects/brix-rust/crates/brix_commands) rustc 1.52.1 Finished dev [unoptimized + debuginfo] target(s) in 0.05s

    • IDE name and version: IntelliJ IDEA 2021.1.2 (Ultimate Edition) Build #IU-211.7442.40, built on May 31, 2021 Licensed to Caleb Cushing Subscription is active until June 28, 2021. Runtime version: 11.0.11+9-b1341.57 amd64 VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o. Linux 5.10.36-2-manjaro GC: G1 Young Generation, G1 Old Generation Memory: 1970M Cores: 8 Registry: debugger.watches.in.variables=false, js.debugger.webconsole=false Non-Bundled Plugins: com.intellij.nativeDebug (211.7442.9), com.samvtran.plugins.macosforallkeymap (2.0.0), org.toml.lang (0.2.148.3911-211), com.codota.csp.intellij (4.2.7), com.github.bjansen.intellij.pebble (0.9), org.rust.lang (0.4.148.3911-211) Kotlin: 211-1.4.32-release-IJ7442.2 Current Desktop: GNOME

    opened by xenoterracide 0
  • Fix <enter> typing between braces in doctest injections

    Fix typing between braces in doctest injections

    //! ```
    //! fn foo() {<caret>}
    //! ```
    

    changelog: fix <enter> typing between braces in doctests

    fix 
    opened by vlad20012 0
  • ANN: fix false-positive highlighting on implicit named arguments in format macro annotations

    ANN: fix false-positive highlighting on implicit named arguments in format macro annotations

    This PR adds basic support for the format_args_capture unstable feature, just so that we avoid false positives.

    Later we can add proper support for resolving format macro arguments with a reference contributor that would resolve arguments either to named parameters or to local bindings. It would also display unresolved reference errors if no argument is found when format_args_capture is enabled.

    Fixes: https://github.com/intellij-rust/intellij-rust/issues/7332

    changelog: Do not warn about missing format macro arguments if format_args_capture feature is enabled.

    fix 
    opened by Kobzol 0
  • Wrong no named argument error highlighting with `format_args_capture` feature

    Wrong no named argument error highlighting with `format_args_capture` feature

    Environment

    • IntelliJ Rust plugin version: 0.4.148.3911-211
    • Rust toolchain version: 1.54.0-nightly-2021-05-11-x86_64-pc-windows-msvc
    • IDE name and version: PyCharm 2021.1.2 (Community Edition) (PC-211.7442.45)
    • Operating system: Windows 10 10.0.19042 Build 19042
    • Macro expansion engine: new
    • Name expansion engine: new

    Problem description

    format_args_capture feature allows you to pass implicit named args into formatting macros. The inspector doesn't recognize this feature.

    image

    Steps to reproduce

    #![feature(format_args_capture)]
    
    fn foo() {
        let output_string = String::from("I am a string");
        println!("{output_string}");
    }
    
    bug subsystem::code insight 
    opened by josem435 0
  • Ann change function parameter type fix

    Ann change function parameter type fix

    This PR adds a quick fix to change the parameter of a function if the argument has a different type. A discussion of this feature is present here.

    change-parameter

    changelog: Add quick fix to change function parameter type from function call.

    feature 
    opened by Kobzol 0
  • TOML multi-line array false positive error

    TOML multi-line array false positive error

    Environment

    • Toml/Rust plugin version: 0.4.148.3911-211
    • Rust toolchain version: 1.54.0-nightly
    • IDE name and version: CLion 2021.1.2 Build #CL-211.7442.42
    • Operating system: Ubuntu 21.04 x86_64

    Problem description

    Toml permits breaking arrays over multiple lines which also includes array inside of inline tables.

    However Toml plugin reports array breaking in dictionaries as an error as can be seen in the image: image

    Still cargo build and similar commands don't report any errors with this Toml file (i.e. Cargo.toml).

    Steps to reproduce

    Include an array broken over multiple lines in an inline table of a Toml file.

    Expected behaviour

    No errors related to it get reported.

    Actual behaviour

    Invalid syntax error gets reported.

    bug subsystem::code insight subsystem::toml 
    opened by JarvisCraft 0
  • COMP: use template builder to fill wild pats in MatchPostfixTemplate

    COMP: use template builder to fill wild pats in MatchPostfixTemplate

    This PR improves https://github.com/intellij-rust/intellij-rust/pull/6825 by letting the user change the generated wild patterns (_) with a template builder. Based on a suggestion by @Sherlock-Holo (https://github.com/intellij-rust/intellij-rust/pull/6825#issuecomment-858216675).

    changelog: Allow filling pats after generating match arms with .match postfix template.

    feature 
    opened by Kobzol 0
  • pub(crate) seen as private when used on modules within the same crate.

    pub(crate) seen as private when used on modules within the same crate.

    Environment

    • IntelliJ Rust plugin version: 0.3.146.3826-211
    • Rust toolchain version: 1.52.1 (9bc8c42bb 2021-05-09) x86_64-pc-windows-msvc
    • IDE name and version: IntelliJ IDEA 2021.1 Community Edition (IC-211.6693.111)
    • Operating system: Windows 10 10.0
    • Macro expansion engine: new
    • Name resolution engine: old

    Problem description

    Modules annotated with pub(crate) mod ... are seen as private when importing them in another module within the same crate by IntelliJ. The code is compiled successfully though (Tested with both the msvc and linux-gnu toolchain, both on stable).

    Steps to reproduce

    in src/plugin/mod.rs:

    pub(crate) mod pluginloader;
    

    in src/main.rs

    use crate::plugin::pluginloader::PluginLoader;
                                ~~~~~~~~
                                Module `pluginloader` is private [E0603]
    

    Where ~ indicates the location of the error given by IntelliJ.

    The full files: src/plugin/mod.rs src/main.rs

    Edit: It seems github shifts the ~ in my code snippet, hence the screenshot: image

    subsystem::code insight 
    opened by TheDutchMC 2
  • Bad completion recommendation for `else` statement

    Bad completion recommendation for `else` statement

    Environment

    • IntelliJ Rust plugin version: 0.4.148.3911-211
    • Rust toolchain version: 1.52.1 (9bc8c42bb 2021-05-09) x86_64-pc-windows-msvc
    • IDE name and version: CLion 2021.1.1 (CL-211.7142.21)
    • Operating system: Windows 10 10.0
    • Macro expansion engine: new
    • Name resolution engine: new

    Problem description

    I actually have no idea about what most Rustaceans are doing when trying to use else keyword, but personally, I usually just type "el" and enter: let IDE complete it.

    What makes me very uncomfortable is following image

    After if block, why in the world eprintln!() is recommended first followed by private fn and than finally and eventually else is recommended?

    image

    If I type "els" it shows me else finally, but I've always used just "el" to type else and there was no problem to type else properly except for this case in my entire programming experience. (makes me insane!)

    Can guys who work with Intellij Plugin kindly consider this when they develop it? Imo, it doesn't make any sense in the given context.

    opened by MintBee 1
Owner
IntelliJ Rust
Umbrella organization for all the projects related to IntelliJ Rust plugin
IntelliJ Rust
Vim configuration for Rust.

rust.vim Description This is a Vim plugin that provides Rust file detection, syntax highlighting, formatting, Syntastic integration, and more. It requ

The Rust Programming Language 2.6k Jun 11, 2021
NetBeans Rust plugin

Rust NetBeans Plugin A NetBeans plugin for Rust. Linux / OSX Windows Requirements NetBeans 8.2.x Java 8+ Rust Cargo Rustup Features So far, it include

drrb 47 Mar 28, 2021
Racer support for Vim

Vim Racer Plugin This plugin allows vim to use Racer for Rust code completion and navigation. Installation Build / Install Racer Install using Pathoge

null 615 Jun 14, 2021
Obsidian Plugin: Convert a URL into markdown

Obsidian Plugin: Convert a URL into markdown Transforms a URL to markdown view if the website allows it. Installation Available in the community plugi

Stephen Solka 15 May 27, 2021
Language Server Protocol (LSP) support for vim and neovim.

For legacy python implementation, see branch master. LanguageClient-neovim Language Server Protocol support for vim and neovim. More recordings at Upd

Junfeng Li 3.3k Jun 12, 2021
RustDT is an Eclipse based IDE for the Rust programming language:

Project website: http://rustdt.github.io/ As of 2017, RustDT is no longer actively maintained, see this blog post for more information. If you are int

null 350 May 11, 2021
Visual Studio extension for Rust

Visual Studio extension for Rust Currently in development, and not feature complete. Stable versions are available on the Visual Studio extension gall

PistonDevelopers 688 May 31, 2021
The official Sublime Text 3 package for the Rust Programming Language

Rust Enhanced About This is a Sublime Text 3 package which supports Rust starting with version 1.0, it makes no attempt at supporting earlier incompat

The Rust Programming Language 619 Jun 13, 2021
Kakoune Language Server Protocol Client

Kakoune Language Server Protocol Client kak-lsp is a Language Server Protocol client for Kakoune implemented in Rust. Installation Note kak-lsp.toml d

null 387 Jun 9, 2021
Rust Cargo command bindings

Vim Cargo Simple vim command bindings to quickly run cargo stuff from vim. Commands Available, mapping with their Cargo equivalant: CargoBench CargoBu

Timon Vonk 39 May 20, 2021
Eclipse Corrosion - Rust edition in Eclipse IDE

Eclipse Corrosion Rust edition and debug in Eclipse IDE Corrosion is a Rust development plugin for the Eclipse IDE, providing a rich edition experienc

Eclipse Foundation 155 Jun 5, 2021
Rust On the FLY completion for neovim

rofl.nvim Rust On the FLy completion engine for Neovim. Why Rust? It's 2021. I think the question you should be asking yourself is "Why NOT Rust?!?? (

TJ DeVries 63 Jun 13, 2021
Rust development environment for Emacs

Rustic Table of Contents Rustic Intro Installation straight Compilation Faces rustc errors Rustfmt edition 2018 LSP Server Client eglot lsp-mode lsp-e

null 387 Jun 13, 2021
Emacs configuration for Rust

Table of Contents Introduction Installation Melpa Manual installation Feature guide Indentation Code formatting Running / testing / compiling code Cli

The Rust Programming Language 716 Jun 12, 2021