From b9e30183959c53b422c0f02db58b8cb9d8559dd0 Mon Sep 17 00:00:00 2001 From: Misha Bohdan Date: Fri, 14 Mar 2025 01:07:52 +0100 Subject: [PATCH] Added support of toolchains for rustfmt --- doc/formatter_options.md | 1 + lua/conform/formatters/rustfmt.lua | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/formatter_options.md b/doc/formatter_options.md index 5c665b21..1d1e5adb 100644 --- a/doc/formatter_options.md +++ b/doc/formatter_options.md @@ -97,6 +97,7 @@ options = { options = { -- The default edition of Rust to use when no Cargo.toml file is found default_edition = "2021", + default_toolchain = "stable" } ``` diff --git a/lua/conform/formatters/rustfmt.lua b/lua/conform/formatters/rustfmt.lua index 6978189b..bef5057b 100644 --- a/lua/conform/formatters/rustfmt.lua +++ b/lua/conform/formatters/rustfmt.lua @@ -10,9 +10,11 @@ return { options = { -- The default edition of Rust to use when no Cargo.toml file is found default_edition = "2021", + default_toolchain = "stable", }, args = function(self, ctx) - local args = { "--emit=stdout" } + local toolchain = "+" .. self.options.default_toolchain + local args = { toolchain, "--emit=stdout" } local edition = util.parse_rust_edition(ctx.dirname) or self.options.default_edition table.insert(args, "--edition=" .. edition)