disable formatter for php

This commit is contained in:
Alexander Navarro 2025-09-10 15:02:59 -03:00
parent 4458a8755e
commit 158e492332

View file

@ -46,15 +46,13 @@ return {
"--indent",
"2",
"--preserve-blank-lines",
"--quiet"
}
}
"--quiet",
},
},
},
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return end
return { timeout_ms = 2000, lsp_fallback = true }
end,
@ -62,6 +60,13 @@ return {
config = function(_, opts)
require("conform").setup(opts)
vim.api.nvim_create_autocmd("FileType", {
pattern = { "php" },
callback = function(bufnr)
vim.b[bufnr].disable_autoformat = true
end,
})
local function toggleAutoFormat()
-- to make this global, change b to g
if vim.b.disable_autoformat == nil then
@ -92,26 +97,21 @@ return {
return
end
if args.bang then
vim.cmd("w")
end
if args.bang then vim.cmd("w") end
end
require("conform").format(
{
require("conform").format({
async = true,
lsp_format = "fallback",
range = range,
formatters = args.fargs
},
callback
)
formatters = args.fargs,
}, callback)
end, {
range = true,
bang = true,
force = true,
desc = "Format the document",
nargs = '*',
nargs = "*",
-- complete = function()
-- local formatters = require('conform').formatters_by_ft
--