Skip to content

Commit

Permalink
Update suggested config to expand proc macros
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Jun 27, 2022
1 parent 03fafb5 commit 3d1b4a1
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/building/suggested.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,42 @@ you can write: <!-- date: 2022-04 --><!-- the date comment is for the edition be
"editor.formatOnSave": true,
"rust-analyzer.cargo.buildScripts.enable": true,
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"cargo",
"./build/$TARGET_TRIPLE/stage0/bin/cargo",
"check",
"-p",
"rustc_driver",
"--message-format=json"
],
"rust-analyzer.rustc.source": "./Cargo.toml",
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.useRustcWrapperForBuildScripts": true
}
```

in your `.vscode/settings.json` file. This will ask `rust-analyzer` to use
`./x.py check` to check the sources, and the stage 0 rustfmt to format them.

> NOTE: Make sure to replace `TARGET_TRIPLE` in the `rust-analyzer.rustfmt.overrideCommand`
> setting with the appropriate target triple for your machine. An example of such
> a triple is `x86_64-unknown-linux-gnu`. An easy way to check your target triple
> is to run `rustc -vV` and checking the `host` value of its output.
> NOTE: Make sure to replace `TARGET_TRIPLE` with the appropriate target triple
> for your machine. An example of such a triple is `x86_64-unknown-linux-gnu`.
> An easy way to check your target triple is to run `rustc -vV` and checking the
> `host` value of its output.
If you're running `coc.nvim`, you can use `:CocLocalConfig` to create a
`.vim/coc-settings.json` and enter the same settings as above, but replacing
`editor.formatOnSave: true,` with
`"coc.preferences.formatOnSaveFiletypes": ["rust"],`.

> NOTE: The configuration once suggested disabling build scripts, but after
> the version `2022-04-14` this was fixed by introducing an option for customizing
> the command rust-analyzer uses to run build scripts. Please ensure that `rust-analyzer`
> is up to date before enabling these options. If you do not wish to enable
> `rust-analyzer.cargo.useRustcWrapperForBuildScripts`, the
> `rust-analyzer.cargo.buildScripts.overrideCommand` option should be set as same as
> `rust-analyzer.checkOnSave.overrideCommand` instead of the suggested value.
>
> If you are not developing for the compiler, you do not need to configure the build scripts
> like in the configuration and you can disable proc macros and build scripts.
If running `./x.py check` on save is inconvenient, in VS Code you can use a [Build
Task] instead:

Expand Down

0 comments on commit 3d1b4a1

Please sign in to comment.