Skip to content

Commit 946ef65

Browse files
authored
Recommend rust analyzer settings in environment setup guide (#2538)
1 parent 89d9530 commit 946ef65

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

docs/developer_guide/environment_setup.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,79 @@ List of commands are:
150150

151151
1. `nautilus database init`: Will bootstrap schema, roles and all sql files located in `schema` root directory (like `tables.sql`)
152152
2. `nautilus database drop`: Will drop all tables, roles and data in target Postgres database
153+
154+
## Rust analyzer settings
155+
156+
Rust analyzer is a popular language server for Rust and has integrations for many IDEs. It is recommended to configure rust analyzer to have same environment variables as `make build-debug` for faster compile times. Below tested configurations for VSCode and Astro Nvim are provided. For more information see [PR](https://github.com/nautechsystems/nautilus_trader/pull/2524) or rust analyzer [config docs](https://rust-analyzer.github.io/book/configuration.html).
157+
158+
### VSCode
159+
160+
You can add the following settings to your VSCode `settings.json` file:
161+
162+
```
163+
"rust-analyzer.restartServerOnConfigChange": true,
164+
"rust-analyzer.linkedProjects": [
165+
"Cargo.toml"
166+
],
167+
"rust-analyzer.cargo.features": "all",
168+
"rust-analyzer.check.workspace": false,
169+
"rust-analyzer.check.extraEnv": {
170+
"VIRTUAL_ENV": "<path-to-your-virtual-environment>/.venv",
171+
"CC": "clang",
172+
"CXX": "clang++"
173+
},
174+
"rust-analyzer.cargo.extraEnv": {
175+
"VIRTUAL_ENV": "<path-to-your-virtual-environment>/.venv",
176+
"CC": "clang",
177+
"CXX": "clang++"
178+
},
179+
"rust-analyzer.runnables.extraEnv": {
180+
"VIRTUAL_ENV": "<path-to-your-virtual-environment>/.venv",
181+
"CC": "clang",
182+
"CXX": "clang++"
183+
},
184+
"rust-analyzer.check.features": "all",
185+
"rust-analyzer.testExplorer": true
186+
```
187+
188+
### Astro Nvim (Neovim + AstroLSP)
189+
190+
You can add the following to your astro lsp config file:
191+
192+
```
193+
config = {
194+
rust_analyzer = {
195+
settings = {
196+
["rust-analyzer"] = {
197+
restartServerOnConfigChange = true,
198+
linkedProjects = { "Cargo.toml" },
199+
cargo = {
200+
features = "all",
201+
extraEnv = {
202+
VIRTUAL_ENV = "<path-to-your-virtual-environment>/.venv",
203+
CC = "clang",
204+
CXX = "clang++",
205+
},
206+
},
207+
check = {
208+
workspace = false,
209+
command = "check",
210+
features = "all",
211+
extraEnv = {
212+
VIRTUAL_ENV = "<path-to-your-virtual-environment>/.venv",
213+
CC = "clang",
214+
CXX = "clang++",
215+
},
216+
},
217+
runnables = {
218+
extraEnv = {
219+
VIRTUAL_ENV = "<path-to-your-virtual-environment>/.venv",
220+
CC = "clang",
221+
CXX = "clang++",
222+
},
223+
},
224+
testExplorer = true,
225+
},
226+
},
227+
},
228+
```

0 commit comments

Comments
 (0)