Best Rust IDE for Linux, VSCode?

Hello,

I'm looking for a good resource that can show me the path to setting up VSCode on Linux with all the best bells and whistles for rust development. There seem to be many extensions and choices, but I'm mostly interested in going with the tried and true (most popular method) for things like displaying the compiler errors as I am typing the code.

Thanks so much for any advise!

There ain't no best.
That said:

  • For VSCode, the rust-analyzer extension is ubiquitous (do NOT install the most popular Rust extension - it won't work).
  • I use the crates (lists crate versions for Cargo.toml), better TOML (syntax higilighting and other stuff for Cargo.toml) and error lens (inline error definitions) extensions as well.
  • Change the rust-analyzer config, in the global settings.json, to change the "rust-analyzer.checkOnSave.command" to "clippy"
4 Likes

Thanks for the feedback!

Actually I was just about to remove this post but since you already replied I'll leave it up.

I should have mentioned that one of my basic rules has been to avoid IDEs and stay with just VIM for my development. Since it forces me to get good at all the things I need to have in my head. Over the years I've found myself becoming too dependent on the smarts of IDEs.

Then I came across this, post and decided to give NEOVIM a try.

I was just going to mention that I'm regularly using Vim for all scales of Rust (and non-Rust) development on my machine, and while I can't recommend any specific code analyzer plugin (I'm a long-time but non-expert vim user), I can say with confidence that for my workflow, it works just fine and runs with very little resource consumption.

Well, I alternate between Neovim and VSCode for Rust development - both are perfectly usable.
That said, since Neovim has native lsp now, you can use rust-analyzer and customize it to your heart's content (on Ubuntu 20.04, I think you need to compile from source - last I checked the shipped version was 0.4.x, but you need 0.5+ for native lsp).

Thanks.

At this point my most desirable feature is how to get AutoImports working. I have VSCode and rust-analyzer working. When I type it will nicely autocomplete, however for statements requiring the addition of a use import, I'm getting no response. {unknown}.

Is there some trick I'm missing on how to activate AutoImports? It appears to be a feature enabled in the settings.

You need to tab complete the thing you are typing - if you type it out by hand, it won't import.

Oh wow the third suggestion is incredibly helpful. I always manually checked with clippy after saving. :sweat_smile:

Been doing some lsp development recently entailed figuring a nice way for neovim to display diagnostics for unopened buffers, and showing progress, figured I'd mention the plugins I have been looking at...

Diagnostics

  • Plug 'nvim-telescope/telescope.nvim' GitHub - nvim-telescope/telescope.nvim: Find, Filter, Preview, Pick. All lua, all the time.

    This has a nice diagnostics picker :Telescope diagnostics, though I hope i figure out if I can configure the preview/diagnostic message to be a vertical split rather than a horizontal one.
    and :Telescope diagnostics bufnr=0 for the just the current file

  • Plug 'kyazdani42/nvim-tree.lua GitHub - kyazdani42/nvim-tree.lua: A file explorer tree for neovim written in lua

    This file tree can be configured to show diagnostic signs and highlight filenames according to diagnostic severity.

    nnoremap <leader>t <cmd>NvimTreeToggle<cr>
    lua <<EOF
    require('nvim-tree').setup{
    view = {
        signcolumn = "yes",
    },
    diagnostics = {
        enable = true,
        show_on_dirs = true
    }
    }
    EOF
    

    Edit: I really like this one even though I generally use telescope, because you can leave it open and files will show their status as diagnostics change.

Progress

Anyhow these are a few of the plugins i've tried which I thought were nice, but didn't see mentioned in that post...

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.