feat: migrate old config
This commit is contained in:
1 parent
1a2ce09da2
commit
92c21d8d6a
31 files changed
+918
-38
No files matched your search
+25
-2
@@ -1,3 +1,11 @@
|
||||
-- mago reads a mago.{toml,yaml,yml,json} found above the file.
|
||||
local function find_mago_config(filename)
|
||||
return vim.fs.find(function(name)
|
||||
local ext = name:match("%.([^.]+)$")
|
||||
return name:lower():find("mago", 1, true) ~= nil and vim.tbl_contains({ "toml", "yaml", "yml", "json" }, ext)
|
||||
end, { path = filename, upward = true })[1]
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
@@ -28,7 +36,7 @@ return {
|
||||
sh = { "shfmt" },
|
||||
bash = { "shfmt" },
|
||||
yaml = { "prettierd" },
|
||||
json = { "prettierd" },
|
||||
json = { "jq" },
|
||||
jsonc = { "prettierd" },
|
||||
markdown = { "prettierd" },
|
||||
rust = { "rustfmt" },
|
||||
@@ -38,7 +46,22 @@ return {
|
||||
typescript = { "prettierd" },
|
||||
typescriptreact = { "prettierd" },
|
||||
python = { "ruff_format" },
|
||||
php = { "php_cs_fixer" },
|
||||
php = { "mago" },
|
||||
},
|
||||
formatters = {
|
||||
mago = {
|
||||
command = "mago",
|
||||
args = function(_, ctx)
|
||||
local config = find_mago_config(ctx.filename)
|
||||
local args = { "format", "--stdin-input", "--stdin-filepath", "$FILENAME" }
|
||||
if config then
|
||||
table.insert(args, 1, config)
|
||||
table.insert(args, 1, "--config")
|
||||
end
|
||||
return args
|
||||
end,
|
||||
stdin = true,
|
||||
},
|
||||
},
|
||||
format_on_save = function(buf)
|
||||
if vim.b[buf].disable_autoformat or vim.b[buf].bigfile then
|
||||
|
||||
Reference in new issue
Block a user