So according to Avery Larsen: Enable Clippy With rust-analyzer(Larsen 2023), setting "rust-analyzer.check.command": "clippy"
in settings.json
does the trick. I think this solution is related to VSCode's setting.
In our Emacs world, there is no such a file. However we have .dir-locals.el
and Eglot neatly provides a project-specific configuration eglot-workspace-configuration
, as showed in João Távora: Eglot Manual 5.1 Project-specific configuration(Távora 2022), for tweaking this settings.json
-ish behavior.
Simply put the following in .dir-locals.el
:
((nil . ((eglot-workspace-configuration . (:rust-analyzer (:check (:command "clippy")))))))
Side notes:
- clippy's feature is a super-set of
cargo check
, so don't worry about the caveat of missing features. - in Emacs' JSON RPC GNU: 33.31 Parsing and generating JSON values(GNU 2018), false Boolean value is represented by
:false
, but somehow Eglot requires that to be:json-false
, as its document shows. Nonetheless, you can usejson-serialize
to check the plist's serialization result (with:false
replaced) to see if the output is as desired.
Reference
GNU. 2018. “33.31 Parsing and Generating Json Values.” 2018. https://www.gnu.org/software/emacs/manual/html_node/elisp/Parsing-JSON.html.
Larsen, Avery. 2023. “Enable Clippy with Rust-Analyzer.” January 3, 2023. https://averylarsen.com/posts/enable-clippy-with-rust-analyzer/.
Távora, João. 2022. “Eglot Manual.” 2022. https://joaotavora.github.io/eglot/.