Fix formatting of bigfile json files

This commit is contained in:
2026-09-03 10:32:39 -04:00
parent 6c3df7e81d
commit dcdef2ebc2
2 changed files with 23 additions and 14 deletions
+14 -5
View File
@@ -8,17 +8,26 @@ local oxfmt_owned = {
"vue",
}
local function oxfmt_with_prettier_fallback()
return { "oxfmt", "prettier", stop_after_first = true }
end
return {
"stevearc/conform.nvim",
opts = function(_, opts)
opts.formatters_by_ft = opts.formatters_by_ft or {}
for _, ft in ipairs(oxfmt_owned) do
local formatters = opts.formatters_by_ft[ft]
if formatters then
opts.formatters_by_ft[ft] = vim.tbl_filter(function(formatter)
return formatter ~= "prettier"
end, formatters)
opts.formatters_by_ft[ft] = oxfmt_with_prettier_fallback()
end
-- snacks.bigfile uses "bigfile" as the buffer filetype and preserves the
-- original filetype in 'syntax'. Let Conform format supported big files
-- without re-enabling Treesitter, LSP, and the other disabled features.
opts.formatters_by_ft.bigfile = function(bufnr)
if vim.tbl_contains(oxfmt_owned, vim.bo[bufnr].syntax) then
return oxfmt_with_prettier_fallback()
end
return {}
end
end,
}