disable formatter for php
This commit is contained in:
parent
4458a8755e
commit
158e492332
1 changed files with 112 additions and 112 deletions
|
|
@ -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
|
||||
--
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue