summaryrefslogtreecommitdiffstats
path: root/lua/conform/formatters/yew-fmt.lua
diff options
context:
space:
mode:
authorMads Hougesen <mads@mhouge.dk>2024-05-13 19:23:40 +0200
committerGitHub <noreply@github.com>2024-05-13 11:23:40 -0600
commitb52d462cb7bea5e81174ece43eb349357add2f11 (patch)
tree4e0b9e91d6503846d3d8b7c6edbc517740e370f1 /lua/conform/formatters/yew-fmt.lua
parent40faaa8fdd0b7f98f58070943306fd93abb5caad (diff)
feat: add support for yew-fmt (#398)
* feat: add support for yew-fmt Should close #314 :) * refactor: copy rustfmt to yew-fmt * fix: use correct default_edition * refactor: extract Cargo.toml parsing into utility function * refactor: yew-fmt doesn't rely directly on rustfmt definition --------- Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
Diffstat (limited to 'lua/conform/formatters/yew-fmt.lua')
-rw-r--r--lua/conform/formatters/yew-fmt.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/lua/conform/formatters/yew-fmt.lua b/lua/conform/formatters/yew-fmt.lua
new file mode 100644
index 0000000..f441fdf
--- /dev/null
+++ b/lua/conform/formatters/yew-fmt.lua
@@ -0,0 +1,21 @@
+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,
+}