What does your Rust coding setup look like?


Hey all,

I’ve been thinking about my work setup recently and am interested in putting in some effort to try to make myself a bit more productive. Until now, I’ve been doing all my Rust coding in neovim without any plugins in action except for rust-lang/rust.vim, which gets me nice syntax highlighting. I’ve also been installing Rust from the stable .dmg files for macOS released every six weeks. In particular, I’m hearing more about and becoming more interested in:

  • Using Rustup to keep up to date with the latest releases
  • Using Clippy to handle linting, preferably every time I save a file
  • Auto formatting. Something like gofmt- I don’t care much about style as long as its consistent and “sane”

So I’m wondering how other people do things. I want to stay in (neo)vim, because that’s just what I like, and I’d really like to emulate as much of my Go setup as possible, wherein I have auto-linting and formatting performed every time I save a .go file in neovim. My understanding is that things like Clippy require nightly Rust, so I’m hoping someone has thought about an automatic way of writing code and linting under nightly but then actually compiling under the latest stable release of Rust.

Even if you don’t have specific answers for me, it might be great to hear about your setup anyway, and if you have any little tools/scripts you’d like to share, I’m sure everyone would appreciate it.



Rust.vim contains support for rustfmt, and can run it on save.


Just Sublime Text 3, and a separate cmd or powershell window. I’ll have cargo check-on-save enabled for small projects, but nothing large (due to cargo lockout). I don’t use completion (because it’s never worked well enough to be worth it), and I don’t use rustfmt (because it’s wrong and crazy). If I’m going through a big pile of errors, I’ll build in ST3 and use “jump to next error”; otherwise I’ll just alt+tab over and build in the console.

Crazy optimised setups are nice… right up until you can’t use that editor for some reason, and then it’s hell adjusting.


vim, tmux, vim-toml
(rust-specific) rust.vim, vim-cargo, vim-racer

From my experience, vim-go is the best programming language plugin I’ve ever used.
I hope the rust plugin can add that much value one day.


I’m rather happy with atom (but I’m biased, since my keyboard does most vim-convenience in hardware)

My atom-setup is the following packages: language-rust, minimap, build, build-cargo, rustfmt

I set the build package to automatically save on build.


I’ve found intellij-rust to very helpful, especially when I was first starting out in Rust. It already supports autocompletion, code navigation (great when you want to quickly jump into a third party crate to see what’s going on), can show you the types of function parameters while you type, and much more. It would have taken me much longer to learn Piston without this tool.

You can download it in one of the free Community editions (IntelliJ Community or PyCharm Community).

Oh and there’s also a Vim emulation plugin for IntelliJ based IDEs.


Have you tried YouCompleteMe? It’s a bit of a pain to setup though but it supports Rust now using racerd. Although I only tried in in gvim/vim, not neovim. You might want to give it a try.


Emacs + rust-mode + racer here. Autocompletion only works in the most basic of cases, but I still get syntax highlighting and auto indentation.


nvim, ycm, vim-fugitive, i3, 2 monitors, cargo watch build on the 2nd monitor

I don’t really like rustfmt, it formats arrays in a weird way, I still use it sometimes to format a block of code.

Maybe it is time to open an issue for that.


Solarized Light, Pragmata Pro with programmatic ligatures

** Rust
Install Rust mode and hook in Cargo bindings.

#+BEGIN_SRC emacs-lisp
  (use-package rust-mode
    :ensure t
    :init (progn
            (add-hook 'rust-mode-hook 'cargo-minor-mode)
            (add-hook 'toml-mode-hook 'cargo-minor-mode)))

*** rustfmt

Disable ~rustfmt~ save-hook until it is closer to no-op on official Rust code.

#+BEGIN_SRC emacs-lisp
  (setq rust-format-on-save nil)

*** Ensure Cargo

Ensure that Cargo is installed.

#+BEGIN_SRC emacs-lisp
  (use-package cargo :ensure t)

*** Racer

#+BEGIN_SRC emacs-lisp
  (use-package racer
    :ensure t
    :init (progn
            (setenv "PATH" (concat (getenv "PATH") ":~/.cargo/bin"))
            (setq exec-path (append exec-path '("~/.cargo/bin")))
            (unless (getenv "RUST_SRC_PATH")
              (setenv "RUST_SRC_PATH" (expand-file-name "~/rust/src/")))
            (setq racer-cmd "~/.cargo/bin/racer")
            (setq racer-rust-src-path "~/rust/src/")
            (add-hook 'rust-mode-hook #'racer-mode)
            (add-hook 'racer-mode-hook #'eldoc-mode)
            (add-hook 'racer-mode-hook #'company-mode)))

Set up keybinding for ~racer-describe~.

#+BEGIN_SRC emacs-lisp
  (define-key rust-mode-map (kbd "C-c d") 'racer-describe)

*** Set up Yasnippet

#+BEGIN_SRC emacs-lisp
  (add-hook 'rust-mode-hook #'yas-minor-mode)

*** Cargo process extensions
Add ~cargo-process-clippy~ command.

#+BEGIN_SRC emacs-lisp
  (defcom cargo-process-clippy
    (cargo-process--start "Clippy" "cargo clippy"))

Add ~cargo-process-watch~ commands.

#+BEGIN_SRC emacs-lisp
  (defcom cargo-process-watch-test
    (cargo-process--start "Watch" "cargo watch test"))

  (defcom cargo-process-watch-check
    (cargo-process--start "Watch" "cargo watch check"))

Add ~cargo-process-check~ command.

#+BEGIN_SRC emacs-lisp
  (defcom cargo-process-check
    (cargo-process--start "Check" "cargo check"))
  (defcom cargo-process-watch-check-build
    (cargo-process-start "Check Build" "cargo watch \"do check, build\""))

*** Backtraces

Turn on backtraces.

#+BEGIN_SRC emacs-lisp
  (setenv "RUST_BACKTRACE" "1")

*** Pull Requests
Go to pull requests

#+BEGIN_SRC emacs-lisp
  (defun rust-prs (additional-query-params)
    (let ((rust-prs-url "https://github.com/rust-lang/rust/pulls?q=is%3Aopen+is%3Apr+sort%3Aupdated-asc"))
      (browse-url (concat rust-prs-url "+" additional-query-params))))

  (defcom rust-prs-mine (rust-prs "author%3Amatthew-piziak"))