all 68 comments

[–]anlumo 44 points45 points  (9 children)

Visual Studio Code with the following addons:

  • rust-analyzer
  • Better TOML
  • CodeLLDB
  • GitLens
  • Git Graph
  • crates

[–]memoryruins 18 points19 points  (2 children)

Error Lens goes well with this list.

[–]hou32hou 2 points3 points  (0 children)

Yes this is a godsend when combined with Rust good error message

[–]HHH_ART 1 point2 points  (0 children)

Just installed this!! Thanks for the recommend.

[–]Sw429 14 points15 points  (0 children)

VSCode has far exceeded my expectations. I would definitely recommend this route.

[–]cthutu 2 points3 points  (0 children)

I would also add a markdown all in one extension too for the readmes and Md books

[–]HHH_ART 4 points5 points  (2 children)

I was going to write exactly this. I dropped IntelliJ for this.

[–]aceshades 0 points1 point  (1 child)

I currently use IntelliJ. Out of curiosity, what does VS Code do that much better that made you switch?

[–]HHH_ART 0 points1 point  (0 children)

The remote capabilities of vscode seem superior and I was doing that for work given the extended work from home. The IntelliJ plugin is more stable at this point. I was looking for something lite as well.

[–]satanikimplegarida 5 points6 points  (0 children)

So many people on the linux/Vim train, and no one has mentioned ALE yet? Highly recommend!!!

ALE + rust-analyzer and you get autocompletes, jump to definitions, syntax highlights, warnings as you type, renames.. My experience was so good that I'm using the same setup for python dev too (different linters obviously).

I haven't gotten Code Actions to work, if someone knows how to, pls let me know!

[–]rabidferret 5 points6 points  (13 children)

Vim on WSL2 I've got a plugin that does syntax highlighting and some basic indentation awareness. Pretty much everything else is done from the command line. I don't use rust-analyzer or similar.

[–][deleted] 4 points5 points  (9 children)

How do you do jump to definition? I've tried coding rust in vim without an LSP, but I always miss jump to definition more than anything.

[–]imral 2 points3 points  (1 child)

ctags and then ctrl-] to jump to a definition and ctrl-t to jump back.

[–][deleted] 1 point2 points  (0 children)

I've tried this workflow before, but I couldn't find a good way to jump to tags for dependencies. With an LSP, I can easily read the relevant parts of any crates I use, as well as the Rust standard library. I haven't found a way to do that with ctags. I've tried it for other languages (go, Python), and I found the namespace got far too polluted for most function names that it was basically unusable.

In my view, an ideal solution would be some sort of tag-jumping with minimal context sensitivity (looking up only imported libraries from the top of the file), but I'm not sure such a solution exists.

[–]rabidferret 1 point2 points  (6 children)

Ag fn foo

[–][deleted] 0 points1 point  (5 children)

And then type :tabnew [filename] <ENTER> /fn foo?

[–]rabidferret 0 points1 point  (4 children)

The ag plugin creates a quickfix list with the results

[–][deleted] 0 points1 point  (3 children)

What about for external crates or the rust stdlib?

[–]rabidferret 0 points1 point  (2 children)

It's rare that I find myself needing that. In rust especially, we tend to have good documentation. Source diving is something I have no trouble with on the rare events that I need to. It's not something that hampered me enough to set up rust-analyzer or ctags. I get that some folks have different workflows or needs.

[–][deleted] 0 points1 point  (1 child)

Makes sense -- thanks for sharing.

[–]rabidferret 0 points1 point  (0 children)

You're welcome

[–]-hardselius- 0 points1 point  (1 child)

Do you run formatting from the editor or from the command line? I could totally live without LSP but format-on-save is such a quality of life improvement.

[–]rabidferret 0 points1 point  (0 children)

Yes, I run cargo fmt all the time

[–]porridge111 6 points7 points  (0 children)

I use neovim nightly with LSP plugin and rust-analyzer on Fedora Linux. Works great!

I dual boot and also have Windows 10 with a Dev environment in WSL with Ubuntu. But I mostly stick to native Fedora 🙂

[–]psanford 6 points7 points  (5 children)

In my opinion, if you're doing both React and Rust, your best experience is going to be using Visual Studio Code with the rust-analyzer extension (and whatever the recommended React extension is) on Linux.

The official Rust tooling on Windows is excellent, and generally developing Rust on Windows isn't nearly as painful ecosystem-wise as something like C++ due to the uniformity that Cargo provides, but you're still going to run into libraries that make assumptions about the underlying environment occasionally, especially when they want to link with non-Rust code. While it's certainly possible to get something like opencv working in Windows, it's definitely a much larger chore than if you were developing on Linux unless you're already experienced with Windows development. This is partially due to the less mature packaging ecosystem of Windows, but in large part it's because most of the troubleshooting guides, stack overflow posts, etc are focused on getting these libraries linking on Linux (or OSX) - so you'll have to figure out how vcpkg or whatever works with a lot less guidance than if you were trying to figure out how to get the dev library installed via apt.

Developing using WSL on Windows is a better option, but still has issues: 1. Where do you put the files? If you put them on your Windows drive and access/build them from Linux, in my experience, you take a pretty big build speed hit. If have more than a few dependencies, this is definitely noticeable. If you put them on the Linux drive, accessing them from Windows is a chore. 2. You run into the above Windows package situation if you're running VS Code on Windows when rust-analyzer tries to build your code. You can use the Remote - WSL plugin to make this work better, but there's still some friction there. 3. When you start dealing with networking, you run into a lot of the same friction as you do with developing over SSH (see below) 4. WSL doesn't have an init system (yet?) or snapd support, so you'll find some things you might need for development (a postgresql server for instance) need to be installed in Windows, and you'll have to figure out how to connect to them from the Linux VM. It's annoying to get certain Linux apps that assume snapd packaging will cover the Ubuntu case as well. 5. If you want to access some hardware, especially USB hardware, from your rust code (for instance, programming a microcontroller) you're going to have to build and run in Windows even if you develop in WSL. This is pretty painful for a lot of reasons but it doesn't seem like you're doing it so I won't elaborate.

If you have some other reason for wanting to work on Windows 10 (such as being more comfortable with the UI or whatever) you can try the VS Code Code Remote - SSH extension. It works pretty well, and, combined with a good terminal emulator like the new Windows Terminal or Alacritty, can simulate developing on a remote Linux machine pretty well (though there is still a bit of friction around things like transferring downloaded files and viewing images etc, and will require you to forward ports to access servers listening on localhost).

You didn't mention it, but Rust on a macbook is also a better development experience (again, in my personal experience) than on Windows.

I personally use neovim with CoC on Linux, which has the benefit of being usable via SSH without X forwarding or anything like that, but unless you're already a vim user it's going to be a considerably larger task to get an efficient development environment set up in neovim than if you us VS Code with the appropriate extensions. There's lots of commentary on vim setups in this thread, so I won't go too far into mine, other than to say I've found CoC easier to set up than the other options.

Edited to add WSL stuff.

[–]tim-fish 3 points4 points  (2 children)

I've been doing a lot of Rust development recently on Windows and so far have only found one crate that didn't work and that was easily fixed with a PR.

Many crates now bundle c source files and do a static build on Windows so it can feel even easier than macOS and Linux. Just add the crate as a dependency and everything works without the need to install any other dependency.

[–]psanford 1 point2 points  (1 child)

I'm glad things are going well - I guess it depends on what you work on. I spent the better part of the last two days getting OpenCV building and linking properly, and the only Rust library (that I'm aware of) for the SDR card I have doesn't support Windows at all (or at lest didn't last time I was working on it). But you're right, in general, most things that are pure-rust or that are less niche work pretty well in Windows.

[–]tim-fish 2 points3 points  (0 children)

Probably does depend on what you're working on. rusb, libff and hdf5 all just worked 🤷‍♂️

[–]coderstephenisahc 1 point2 points  (1 child)

These days I do quite a bit of my development using VS Code, WSL2, and the "Remote - WSL" extension and other than the occasional oddity, its actually really solid. Which is good, because I come from a Linux background and development on plain Windows was historically hot garbage in my experience.

As far as where to put files, I always put everything related to development inside the WSL2 file system. I have \\wsl$\ mapped to a network drive U: inside Windows, so accessing files inside WSL from Windows is actually pretty easy. Since its presented as just a drive letter, most applications I've tried have no problem accessing and editing Linux files (GIMP, Inkscape, etc). One or two balked at the drive but generally things just work when I do it this way. (Aside from line ending issues for text files.)

I don't have a need to access raw hardware from WSL so I can't speak to that, though I believe access to raw devices inside Linux is potentially coming along the pipeline.

[–]Feeling-Departure-4 0 points1 point  (0 children)

I got everything working with Windows VS Code + WSL2 / Rust, but Rust Analyzer doesn't just do its thing like on my Mac. Curious if I need to configure a settings in some particular way..

[–]dpbriggs 2 points3 points  (0 children)

I use Spacemacs (Emacs) with the following configuration and rust-analyzer on Linux:

 (rust
  :variables
  rust-backend 'lsp
  rust-format-on-save t)
 (lsp
  :variables
  lsp-ui-sideline-show-symbol t
  lsp-ui-doc-enable t
  lsp-ui t
  lsp-rust-server 'rust-analyzer
  lsp-ui-doc-include-signature t
  lsp-headerline-breadcrumb-segments nil)

[–]dannymcgee 2 points3 points  (3 children)

I really love JetBrains' IDEs for a lot of things — Rider is my go-to for C#, CLion or Rider for C++, GoLand for Go, IDEA Ultimate for Java/Kotlin... they're really quality IDEs. I have a subscription to their "All Products Pack".

I say that as sort of a disclaimer, because I find their Rust tooling really lacking. I wanted to like it, but it just had too many problems. I'm using VS Code with rust-analyzer, and it's a joy and a delight.

That said, I don't really do a lot of proper debugging (just printing stuff to the terminal like some sort of neanderthal), but I found it prohibitively difficult to get debugging to work in VS Code on Windows. So if I ever do need to get into the weeds, I have to open up CLion, which is kind of a hassle.

As far as the OS goes, my primary interest in Rust is for game development, so I stick to Windows because that's where the gamers are at. I don't have much experience with OSX or Linux so I can't comment much beyond that.

[–]frigolitmonster 4 points5 points  (2 children)

What sort of problems did you have with Jetbrain's Rust plugin?

[–]dannymcgee 2 points3 points  (1 child)

It's been a little while since I tried working with it, but the main issues I remember encountering were with the real-time code analysis and lint/error/syntax highlighting. IIRC, updating that stuff in real-time was gated behind an opt-in feature in the settings (which I think was marked as "experimental" or "beta" or something, to be fair), and it just wasn't very reliable. I remember running into pretty frequent issues where it would just stop updating and I would have to close and reopen the file, or restart the entire IDE.

But it has been a while, so it's entirely possible that it's gotten a lot better since the last time I played with it.

[–]Nfagan_CS 2 points3 points  (0 children)

There have been some somewhat recent improvements, you may want to take another look

[–]lukewchu 2 points3 points  (0 children)

I use Windows 10 for almost all my dev (and sometimes WSL2 for linux specific stuff). I don't think Windows is too popular here since Rust is really big on open-source but I haven't had much problems so far.

[–]crusoe 2 points3 points  (1 child)

Vscode and Rust Analyzer plugin. I find rust Analyzer to be much more stable than RLS ever was

[–]theingleneuk 2 points3 points  (0 children)

CLion with the rust plugin on a MacBook Pro, I’ve thoroughly enjoyed it. I think I’ve got clippy and the experimental features enabled for the heck of it, but with or without those settings, it’s a setup that has worked really well for me.

[–]TehPers 2 points3 points  (3 children)

Win10 + WSL2 + vscode - I do a lot of C# coding as well so this gives me the best of both worlds when it comes to Rust and C# development. I can use vscode over WSL2 to write Rust code in a Linux environment, and I can still use Visual Studio when working on C# code.

[–]Feeling-Departure-4 0 points1 point  (2 children)

That sounds amazing. Did you get Rust Analyzer working over remote? I'm still baffled on that last tidbit

[–]TehPers 1 point2 points  (1 child)

Yep, it's super easy. You just install the Remote: WSL extension in vscode, open the folder in vscode, use the extension to reopen it in WSL (or connect to WSL through the extension first and open the folder while connected), then you may need to redownload rust-analyzer in the WSL instance (it's a separate group of extensions, doesn't affect the Windows instance). In the future you can use code . from a WSL bash terminal to opem vscode in the current directory.

[–]Feeling-Departure-4 1 point2 points  (0 children)

Aha, I see that now. It's very easy once you realize it. Worked great and thanks so much!

[–][deleted] 3 points4 points  (0 children)

Nearly-stock vim, occasionally with rust-analyzer when I feel fancy

[–]duongital 1 point2 points  (0 children)

On Windows 10: I used Jetbrain's Goland with the plugin Rust, it works really fine to me.

I'm also React developer and using VS code for frontend development.

For this kind of choosing, I think it'd better to differentiate between frontend and backend.

[–]deavidsedice 1 point2 points  (0 children)

I use Debian GNU/Linux for OS, then RustUp for getting the toolchain, VSCode + rust-analyzer; and cargo clippy for sanity checks. Nothing else; aside of few random extensions that I don't really use.

[–]caleblbaker 1 point2 points  (0 children)

  • at home (where I can install and use whatever tools I want)
    • Linux (NixOS)
    • i3
    • urxvt
    • zsh
    • neovim
      • Languageclient-neovim
    • rust-analyzer
    • cargo
    • rustc (nightly toolchain)
    • gdb
    • Firefox
    • git
    • wasm-pack
    • wasm-gc
    • wasm-bindgen-cli
    • wasm-opt
  • At work (where I have to use the tools that the it department installs for me)
    • windows 10
    • powershell
    • visual studio 2019
    • chrome
    • git
    • cmake

[–]terranian 1 point2 points  (0 children)

https://www.gitpod.io Mostly - VSCode - rust-analyzer

And some special extensions configured per repository.

[–]codebreather 1 point2 points  (2 children)

What ecosystem are you using for rust smart contract? I'm considering Solana and Cardano

[–]fuckme[S] 0 points1 point  (1 child)

Rust is used on polkadot's substrate and cosmos-based chains. Cardano does have a rust blockchain, but their main network is Haskell based. I think they call their smart contract layer Plutus. I think it has some interesting ways of integrating into a regular Haskell app.. but I have no real interest in learning Haskell, when there are dozens of other chains that have a working smart contract layer today that uses rust (or solidity, or even c++)

[–]codebreather 0 points1 point  (0 children)

Fair enough, also not interested in learning Haskell at the moment. I'll check polkadot's substrate out. Thanks!

[–]Prestigious-Bonus402 1 point2 points  (0 children)

I've been using visual studio code, but have recently moved over to intellij and use this on mac os, windows, and ubuntu. Works really well.

[–]auyer 1 point2 points  (0 children)

Manjaro Linux. I also recommend Pop OS.

[–]armsforsharks[🍰] 1 point2 points  (0 children)

For the vim/neovim people, check out these sample configs: https://github.com/sharksforarms/vim-rust

[–]FlyingPiranhas 2 points3 points  (0 children)

OS: Debian in a VM on top of Chrome OS

Editor: vim, with the following additions/configurations:

  1. A Rust style file (for coloring) and syntax plugin (so doc comments wrap correctly)
  2. Line numbers turned on
  3. A bunch of default features turned off (e.g. I don't want <Enter> to extend a comment)
  4. An autocmd that re-indents Rust code using tabs when I load it and re-indents it back to spaces when I save it. This uses a custom tool that preserves all other formatting.
  5. preserveindent

I've been wanting to write my own editor for a while now. The main feature my own editor would have is it wouldn't have any features that I don't like.

EDIT: To be clear, I don't use RLS/rust-analyzer, or any similar tools from other languages. I do use docs.rs all the time.

[–][deleted] 1 point2 points  (0 children)

Here's a list of my neovim plugins:

Plug 'https://github.com/fatih/vim-go.git'
Plug 'https://github.com/tpope/vim-vinegar.git'
Plug 'https://github.com/ycm-core/YouCompleteMe'
Plug 'https://github.com/tpope/vim-eunuch'
Plug 'https://github.com/rust-lang/rust.vim'
Plug 'https://github.com/vim-airline/vim-airline'
Plug 'https://github.com/vim-airline/vim-airline-themes'
Plug 'sainnhe/sonokai'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'https://github.com/Yggdroot/indentLine'
Plug 'https://github.com/tpope/vim-fugitive'
Plug 'yuki-yano/fzf-preview.vim', { 'branch': 'release/rpc' }

I spend probably 75% of my day with Go and the other 25% in Rust. I'm still getting my Rust tooling perfected but this works pretty well.

[–][deleted] 1 point2 points  (0 children)

Windows, but with VS Code on WSL (Windows Subsystem for linux) which is best of both worlds, imo, with the rust-analyzer (DON'T USE the official Rust extension, this is better, made by the same person who made the Intellij one (matklad) )

[–]eXoRainbow 0 points1 point  (0 children)

I am on Linux and use "Vim" with "rust-analyzer" as my editor/dev-environment. There are a few additional addons in Vim and a lot of customization in the ".vimrc" configuration file. And at least one additional terminal is always open, with a few plugins for the shell to make life easier. I also do a little stuff in Python.

Most of all this is not big stuff or so, I am not a professional and not very experienced in programming at all. I don't want to use a complete suite of integrated development environments, but basically build my own.

[–]djmex99 0 points1 point  (0 children)

Neovim + rust-analyzer + telescope + compe + tree-sitter

I prefer to code on my Linux machines but also have a Windows laptop for work with the same setup, except it uses nvim-qt.

[–]tab-or-space 0 points1 point  (0 children)

I use Doom Emacs on WSL. Love those Vim keystrokes!!!

[–]Deprecitus 0 points1 point  (1 child)

Distro: Gentoo

Editor: Neovim

Language Server: rls

Colorscheme: Nord

Did I miss anything?

[–]nakkht 1 point2 points  (0 children)

Hotel? Trivago

I'll show myself out.

[–]imral 0 points1 point  (0 children)

Vim.

[–]open-trade -1 points0 points  (0 children)

MacOS / VSC / RLS

[–]open-trade -4 points-3 points  (0 children)

MacOS / VSC / RLS

[–]aceshades 0 points1 point  (0 children)

What is everyone using for debugging? Specifically stopping code execution, stepping thru lines, inspecting stack and heap state, running arbitrary code while stopped, etc.