aboutsummaryrefslogtreecommitdiffstats
path: root/lua/conform/formatters/yew-fmt.lua
blob: cb94a56a894c53e71c5dcb1e2f1da39b1e4c1fc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
local util = require("conform.util")

---@type conform.FileFormatterConfig
return {
  meta = {
    url = "https://github.com/schvv31n/yew-fmt",
    description = "Code formatter for the Yew framework.",
  },
  command = "yew-fmt",
  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 edition = util.parse_rust_edition(ctx.dirname) or self.options.default_edition
    table.insert(args, "--edition=" .. edition)

    return args
  end,
  cwd = util.root_file({
    "rustfmt.toml",
    ".rustfmt.toml",
  }),
}