Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Emacs section to IDE setup docs #505

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/src/user/setting_up_ide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ First, install [Visual Studio Code](https://code.visualstudio.com/). Then instal

`ambient new` will by default set up your project for VSCode, by creating this [.vscode/settings.json](https://github.com/AmbientRun/Ambient/blob/main/app/src/cli/new_project_template/.vscode/settings.json) file for you.

## Emacs

There are multiple ways to configure Emacs as a Rust IDE. The following assumes you are using [rustic](https://github.com/brotzeit/rustic),
[lsp-mode](https://github.com/emacs-lsp/lsp-mode) and [rust-analyzer](https://rust-analyzer.github.io/) libraries. [Robert Krahn provides a comprehensive guide to configuring Emacs for Rust development](https://robert.kra.hn/posts/rust-emacs-setup/#prerequisites)

Once you have Emacs configured for general Rust development. You need to set some explicit values for Ambient projects. 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 elisp:


``` elisp
(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 project directory that Emacs will pick up and load settings for. Similiar to the `.vscode/settings.json` an example of that file for an Ambient project:

``` elisp
((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"])))))
```

## Other IDEs

To get rust-analyzer to work, you need to make sure it's building with the `server` and `client` feature flags enabled. See [.vscode/settings.json](https://github.com/AmbientRun/Ambient/blob/main/app/src/cli/new_project_template/.vscode/settings.json) for an example.