Hot diggity darn, but minutes later I discovered a crate for that. For future people landing on this question, all I had to do was run
cargo install cargo-script
and bam you'll be off and org-babel-ing. If you've got Cargo.el installed in your profile, you can evaluate pretty quick using Cargo-run. This may become how I write Rust going forward, if I can ...
After some research, I was able to solve it by adding this to my init.el:
(define-key rust-mode-map (kbd "C-r") 'my-cargo-run))
(defun my-cargo-run ()
"Build and run Rust code."
(run-win (display-buffer (get-buffer "*Cargo Run*") nil '...
I had very similar problem. I use OSX and both cargo and rustc weren't in exec-path. Because I see you have /Users path - I assume u run emacs on OSX too.
My solution was exec-path-from-shell plugin. I added to my init.el something like this:
(if (eq system-type 'darwin)
The "best" way? Dunno. Define your criteria for "best". Looks OK to me, FWIW.
But I would probably just do this:
(define-key 'rust-mode-map ";" (lambda () ...))
That assumes the mode map is rust-mode-map. Oh, and I would also probably name the command, instead of using an anonymous function -- makes it easier to work with.
But it probably doesn't ...
Since rust-clippy normally works at compile time, it should get integrated into whatever you are using for compiling Rust code in Emacs (e.g. cargo-minor-mode). This is touched on in this blog post on setting up Emacs for Rust, in case you have not seen it already.
What is the value of company-begin-commands? It should include at least self-insert-command. Also, try changing company-idle-delay to a low value above zero.
The Rust setup I describe in my setting up Rust with Emacs guide comes with a repo that has a working auto completion config via company. When in doubt, compare with that.
Even though you've got it in your shell, it looks as though you've not got /usr/local/bin in the PATH environment variable for your Emacs. You could verify this by doing M-x getenv PATH. There might be a better way, but I use a little bit of code like the following in my Emacs init file:
(defun add-to-path (dir)
"Add DIR to PATH environment variable and ...
When you use rust-analyzer via lsp-mode you can tell it to use clippy as the default linter via (setq lsp-rust-analyzer-cargo-watch-command "clippy") (normally it would use check).
The config presented in this guide uses it by default.