blob: 34fb09bb7a38075250ae7a4e3a4fe99cce6a69c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/rust-lang/rustfmt",
description = "A tool for formatting rust code according to style guidelines.",
},
command = "rustfmt",
options = {
-- The default edition of Rust to use when no Cargo.toml file is found
default_edition = "2021",
},
args = function(self, ctx)
local args = { "--emit=stdout" }
local manifest = vim.fs.find("Cargo.toml", { upward = true, path = ctx.dirname })[1]
if manifest then
table.insert(args, "--manifest-path=" .. manifest)
elseif self.options.default_edition then
table.insert(args, "--edition=" .. self.options.default_edition)
end
return args
end,
}
|