From 651fe54d12f07dd98ff94f8a8cea2469e746a590 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sun, 30 Nov 2025 15:00:14 -0500 Subject: add clippy-json target Add a clippy-json target to the ninja script. This is useful for rust-analyzer, which requires an "external check command" to function when not using cargo. Also we add a "clippy-json-prereq" target, and invoke it in the clippy.py script. The prereq target tries to build as much of the project as possible with "-k0". --- docs/markdown/Rust.md | 7 +++++++ docs/markdown/snippets/clippy-json.md | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 docs/markdown/snippets/clippy-json.md (limited to 'docs/markdown') diff --git a/docs/markdown/Rust.md b/docs/markdown/Rust.md index 67bbdec5b..69dbc038f 100644 --- a/docs/markdown/Rust.md +++ b/docs/markdown/Rust.md @@ -91,6 +91,13 @@ write files into the source directory). [See the upstream docs](https://rust-analyzer.github.io/book/non_cargo_based_projects.html) for more information on how to configure that. +### Clippy +You can use the "clippy-json" build target as rust-analyer's "check command" to recieve clippy diagnostics in your editor. + +Without overriding the check command, the LSP will function in a limited state, only showing certain errors (for example, no borrow checking errors are shown). + +[Non cargo based projects](https://rust-analyzer.github.io/book/non_cargo_based_projects.html) shows how to override the check command, you probably want to set it to `ninja clippy-json -C build`. + ## Linking with standard libraries Meson will link the Rust standard libraries (e.g. libstd) statically, unless the diff --git a/docs/markdown/snippets/clippy-json.md b/docs/markdown/snippets/clippy-json.md new file mode 100644 index 000000000..3b8ae370c --- /dev/null +++ b/docs/markdown/snippets/clippy-json.md @@ -0,0 +1,9 @@ +# New "clippy-json" Ninja Target For rust-analyzer + +A new `clippy-json` ninja target will now be generated for rust projects. + +rust-analyzer supports non-cargo based projects so long as you provide it with a `rust-project.json` file and a custom "check command" to provide compiler errors. + +Meson already for some time has generated a `rust-project.json` file for rust-analyzer, but had no way to hook up its rustc/clippy output to rust-analyzer. + +To use the new feature, you want to override the rust-analyzer check command as shown [here](https://rust-analyzer.github.io/book/non_cargo_based_projects.html), and set it to `ninja clippy-json -C build` or something to the same effect. -- cgit v1.2.3