Can't figure out how to get clippy warnings from rust analyzer

Hai, I’ve tried to setup rust analyzer using the rust tools plugin. It works fine for the most part, only I don’t get the clippy warnings. I get other warnings, for example missing a semicolon, but if I have an unused variable for example it won’t say anything.

This is currently how I have rust tools setup:

local rt = require("rust-tools")
rt.setup({
	server = {
		on_attach = function(_, bufnr)
			vim.keymap.set("n", "K", rt.hover_actions.hover_actions, { buffer = bufnr })
			vim.keymap.set("n", "<leader>ca", rt.code_action_group.code_action_group, { buffer = bufnr })
		end,
		settings = {
			["rust_analyzer"] = {
				cargo = { all_features = true },
				check = {
					command = "clippy",
				},
				checkOnSave = true,
			},
		},
	},
})

rt.inlay_hints.enable()

vim.diagnostic.config({
	virtual_text = true,
	signs = true,
	update_in_insert = true,
	underline = true,
	severity_sort = false,
	float = {
		focusable = false,
		style = "minimal",
		border = "rounded",
		source = "always",
		header = "",
		prefix = "",
	},
})

Note the check = { command = "clippy" } and checkOnSave = true. This is one variant I’ve tried, I’ve also tried checkOnSave = { command = "clippy" } which didn’t work either.

Am I making a dumb mistake, is this some kind of bug or is there something completely different I’m supposed to do?

Thanks in advance!

After digging through the lazyvim code I found how they did it, and that worked for me (somehow). This is what I ended up with (which works):

settings = {
	["rust-analyzer"] = {
		cargo = {
			allFeatures = true,
			loadOutDirsFromCheck = true,
			runBuildScripts = true,
		},
		-- Add clippy lints for Rust.
		checkOnSave = {
			allFeatures = true,
			command = "clippy",
			extraArgs = {
				"--",
				"--no-deps",
				"-Dclippy::correctness",
				"-Dclippy::complexity",
				"-Wclippy::perf",
				"-Wclippy::pedantic",
			},
		},
		procMacro = {
			enable = true,
			ignored = {
				["async-trait"] = { "async_trait" },
				["napi-derive"] = { "napi" },
				["async-recursion"] = { "async_recursion" },
			},
		},
	},
},

note exactly how the extra args are formatted, no spaces and the "--" at the front, otherwise it simply won’t work.

Also note that for some reason, which is far beyond my mortal understanding, this does not work while doing rustlings, as in as far as I can see clippy is not even ran :sob: