Skip to content

Commit 60df284

Browse files
authored
feat: Add "nightly" option to rustfmt (#811)
1 parent 1bf8b5b commit 60df284

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

doc/formatter_options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ options = {
9797
options = {
9898
-- The default edition of Rust to use when no Cargo.toml file is found
9999
default_edition = "2021",
100+
-- Set to true to use the nightly version of rustfmt
101+
nightly = false,
100102
}
101103
```
102104

lua/conform/formatters/rustfmt.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ return {
1010
options = {
1111
-- The default edition of Rust to use when no Cargo.toml file is found
1212
default_edition = "2021",
13+
-- Set to true to use the nightly version of rustfmt
14+
nightly = false,
1315
},
1416
args = function(self, ctx)
1517
local args = { "--emit=stdout" }
1618
local edition = util.parse_rust_edition(ctx.dirname) or self.options.default_edition
1719
table.insert(args, "--edition=" .. edition)
1820

21+
if self.options.nightly then
22+
-- "+nightly" must be the first argument
23+
table.insert(args, 1, "+nightly")
24+
end
1925
return args
2026
end,
2127
cwd = util.root_file({

0 commit comments

Comments
 (0)