Our recommended IDE is Visual Studio Code (VSCode).
Install Visual Studio Code, then install the following plugins:
- rust-analyzer, as described here.
- CodeLLDB. This one is optional, but with it you can launch your package from with VSCode by pressing F5.
ambient new will set up your package for VSCode by default, by creating a
.vscode/settings.json for you.
There are multiple ways to configure Emacs as a Rust IDE. The following assumes you are using rustic, lsp-mode and rust-analyzer libraries. Robert Krahn provides a comprehensive guide to configuring Emacs for Rust development
Once you have Emacs configured for general Rust development, you need to set some explicit values for Ambient packages. Ambient uses some custom
cargo configuration values that Emacs and rust-analyzer need to know about. You can manually set these variables with the following
(setq lsp-rust-analyzer-cargo-target "wasm32-wasi" lsp-rust-analyzer-cargo-watch-args ["--features" "client server"] lsp-rust-features ["client" "server"])
Furthermore, you can add a
.dir-locals.el file to your Ambient package directory that Emacs will pick up and load settings for. This is similar to the
.vscode/settings.json that is created by default. This is an example
((rustic-mode . ((eval . (setq-local lsp-rust-analyzer-cargo-target "wasm32-wasi")) (eval . (setq-local lsp-rust-analyzer-cargo-watch-args ["--features" "client server"])) (eval . (setq-local lsp-rust-features ["client" "server"])))))
To get rust-analyzer to work, you need to make sure it’s building with the
client feature flags enabled. See .vscode/settings.json for an example.